Skip to content

Commit

Permalink
[mlir] Reland 5a6e52d with update (NFC)
Browse files Browse the repository at this point in the history
Excluded updates to mlir/lib/AsmParser/Parser.cpp ,
which caused LIT failure "FAIL: MLIR::completion.test" on multiple buildbots.
  • Loading branch information
JOE1994 committed Sep 16, 2024
1 parent 0c55ad1 commit 095b41c
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions mlir/lib/Bindings/Python/IRAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class PyDenseElementsAttribute
llvm::raw_string_ostream os(message);
os << "Expected a static ShapedType for the shaped_type parameter: "
<< py::repr(py::cast(*explicitType));
throw py::value_error(os.str());
throw py::value_error(message);
}
shapedType = *explicitType;
} else {
Expand All @@ -732,7 +732,7 @@ class PyDenseElementsAttribute
os << "All attributes must be of the same type and match "
<< "the type parameter: expected=" << py::repr(py::cast(shapedType))
<< ", but got=" << py::repr(py::cast(attrType));
throw py::value_error(os.str());
throw py::value_error(message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/TableGen/CodeGenHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,5 @@ std::string mlir::tblgen::escapeString(StringRef value) {
std::string ret;
llvm::raw_string_ostream os(ret);
os.write_escaped(value);
return os.str();
return ret;
}
2 changes: 1 addition & 1 deletion mlir/lib/TableGen/Predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static std::string combineBinary(ArrayRef<std::string> children,
for (unsigned i = 1; i < size; ++i) {
os << ' ' << combiner << " (" << children[i] << ')';
}
return os.str();
return str;
}

// Prepend negation to the only condition in the predicate expression list.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVM/ModuleToObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ ModuleToObject::translateToISA(llvm::Module &llvmModule,

codegenPasses.run(llvmModule);
}
return stream.str();
return targetISA;
}

void ModuleToObject::setDataLayoutAndTriple(llvm::Module &module) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void registerFromLLVMIRTranslation() {
std::string errStr;
llvm::raw_string_ostream errStream(errStr);
err.print(/*ProgName=*/"", errStream);
emitError(UnknownLoc::get(context)) << errStream.str();
emitError(UnknownLoc::get(context)) << errStr;
return {};
}
if (llvm::verifyModule(*llvmModule, &llvm::errs()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static std::string diagStr(const llvm::Type *type) {
std::string str;
llvm::raw_string_ostream os(str);
type->print(os);
return os.str();
return str;
}

/// Get the declaration of an overloaded llvm intrinsic. First we get the
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mlir::LLVM::createSourceLocStrFromLocation(Location loc,
std::string locStr;
llvm::raw_string_ostream locOS(locStr);
locOS << loc;
return builder.getOrCreateSrcLocStr(locOS.str(), strLen);
return builder.getOrCreateSrcLocStr(locStr, strLen);
}

llvm::Constant *
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Target/LLVMIR/ModuleImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static std::string diag(const llvm::Value &value) {
std::string str;
llvm::raw_string_ostream os(str);
os << value;
return os.str();
return str;
}

// Utility to print an LLVM metadata node as a string for passing
Expand All @@ -66,7 +66,7 @@ static std::string diagMD(const llvm::Metadata *node,
std::string str;
llvm::raw_string_ostream os(str);
node->print(os, module, /*IsForDebug=*/true);
return os.str();
return str;
}

/// Returns the name of the global_ctors global variables.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Serializer::processSpecConstantOperationOp(spirv::SpecConstantOperationOp op) {
std::string enclosedOpName;
llvm::raw_string_ostream rss(enclosedOpName);
rss << "Op" << enclosedOp.getName().stripDialect();
auto enclosedOpcode = spirv::symbolizeOpcode(rss.str());
auto enclosedOpcode = spirv::symbolizeOpcode(enclosedOpName);

if (!enclosedOpcode) {
op.emitError("Couldn't find op code for op ")
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ uint32_t Serializer::prepareConstantInt(Location loc, IntegerAttr intAttr,
value.print(rss, /*isSigned=*/false);

emitError(loc, "cannot serialize ")
<< bitwidth << "-bit integer literal: " << rss.str();
<< bitwidth << "-bit integer literal: " << valueStr;
return 0;
}
}
Expand Down Expand Up @@ -968,7 +968,7 @@ uint32_t Serializer::prepareConstantFp(Location loc, FloatAttr floatAttr,
value.print(rss);

emitError(loc, "cannot serialize ")
<< floatAttr.getType() << "-typed float literal: " << rss.str();
<< floatAttr.getType() << "-typed float literal: " << valueStr;
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Tools/PDLL/Parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ class Parser {
std::string docStr;
{
llvm::raw_string_ostream docOS(docStr);
std::string tmpDocStr = doc.str();
raw_indented_ostream(docOS).printReindented(
StringRef(tmpDocStr).rtrim(" \t"));
StringRef(docStr).rtrim(" \t"));
}
return docStr;
}
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
FallbackAsmResourceMap fallbackResourceMap;
ParserConfig parseConfig(&roundtripContext, /*verifyAfterParse=*/true,
&fallbackResourceMap);
roundtripModule =
parseSourceString<Operation *>(ostream.str(), parseConfig);
roundtripModule = parseSourceString<Operation *>(buffer, parseConfig);
if (!roundtripModule) {
op->emitOpError() << "failed to parse " << testType
<< " content back, cannot verify round-trip.\n";
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Transforms/ViewOpGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static std::string strFromOs(function_ref<void(raw_ostream &)> func) {
std::string buf;
llvm::raw_string_ostream os(buf);
func(os);
return os.str();
return buf;
}

/// Escape special characters such as '\n' and quotation marks.
Expand Down Expand Up @@ -199,7 +199,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
std::string buf;
llvm::raw_string_ostream ss(buf);
attr.print(ss);
os << truncateString(ss.str());
os << truncateString(buf);
}

/// Append an edge to the list of edges.
Expand Down Expand Up @@ -262,7 +262,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
std::string buf;
llvm::raw_string_ostream ss(buf);
interleaveComma(op->getResultTypes(), ss);
os << truncateString(ss.str()) << ")";
os << truncateString(buf) << ")";
}

// Print attributes.
Expand Down

0 comments on commit 095b41c

Please sign in to comment.