[Mlir-commits] [mlir] 61ff1cb - Revert "[mlir] Nits on uses of llvm::raw_string_ostream (NFC)"
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Sep 15 19:09:18 PDT 2024
Author: JOE1994
Date: 2024-09-15T22:09:11-04:00
New Revision: 61ff1cb452e49d41e63061bac4aebafe2e9e2209
URL: https://github.com/llvm/llvm-project/commit/61ff1cb452e49d41e63061bac4aebafe2e9e2209
DIFF: https://github.com/llvm/llvm-project/commit/61ff1cb452e49d41e63061bac4aebafe2e9e2209.diff
LOG: Revert "[mlir] Nits on uses of llvm::raw_string_ostream (NFC)"
This reverts commit 5a6e52d6ef96d2bcab6dc50bdb369662ff17d2a0.
"FAIL: MLIR::completion.test" on multiple buildbots.
Added:
Modified:
mlir/lib/AsmParser/Parser.cpp
mlir/lib/Bindings/Python/IRAttributes.cpp
mlir/lib/TableGen/CodeGenHelpers.cpp
mlir/lib/TableGen/Predicate.cpp
mlir/lib/Target/LLVM/ModuleToObject.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
mlir/lib/Target/LLVMIR/ModuleImport.cpp
mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
mlir/lib/Tools/PDLL/Parser/Parser.cpp
mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
mlir/lib/Transforms/ViewOpGraph.cpp
Removed:
################################################################################
diff --git a/mlir/lib/AsmParser/Parser.cpp b/mlir/lib/AsmParser/Parser.cpp
index 43139c67f0f821..2e4c4a36d46b9b 100644
--- a/mlir/lib/AsmParser/Parser.cpp
+++ b/mlir/lib/AsmParser/Parser.cpp
@@ -2439,8 +2439,8 @@ ParseResult OperationParser::codeCompleteSSAUse() {
if (it.second.size() > 1)
detailOS << ", ...";
- state.codeCompleteContext->appendSSAValueCompletion(it.getKey(),
- detailData);
+ state.codeCompleteContext->appendSSAValueCompletion(
+ it.getKey(), std::move(detailOS.str()));
}
}
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index ead81a76c0538d..bfdd4a520af275 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -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(message);
+ throw py::value_error(os.str());
}
shapedType = *explicitType;
} else {
@@ -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(message);
+ throw py::value_error(os.str());
}
}
diff --git a/mlir/lib/TableGen/CodeGenHelpers.cpp b/mlir/lib/TableGen/CodeGenHelpers.cpp
index 2f13887aa0bbeb..7e7640303a1256 100644
--- a/mlir/lib/TableGen/CodeGenHelpers.cpp
+++ b/mlir/lib/TableGen/CodeGenHelpers.cpp
@@ -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 ret;
+ return os.str();
}
diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp
index 3c3c475f4d3659..8beb7720cb3147 100644
--- a/mlir/lib/TableGen/Predicate.cpp
+++ b/mlir/lib/TableGen/Predicate.cpp
@@ -301,7 +301,7 @@ static std::string combineBinary(ArrayRef<std::string> children,
for (unsigned i = 1; i < size; ++i) {
os << ' ' << combiner << " (" << children[i] << ')';
}
- return str;
+ return os.str();
}
// Prepend negation to the only condition in the predicate expression list.
diff --git a/mlir/lib/Target/LLVM/ModuleToObject.cpp b/mlir/lib/Target/LLVM/ModuleToObject.cpp
index 77391341adaad2..d94c10de8d7c42 100644
--- a/mlir/lib/Target/LLVM/ModuleToObject.cpp
+++ b/mlir/lib/Target/LLVM/ModuleToObject.cpp
@@ -182,7 +182,7 @@ ModuleToObject::translateToISA(llvm::Module &llvmModule,
codegenPasses.run(llvmModule);
}
- return targetISA;
+ return stream.str();
}
void ModuleToObject::setDataLayoutAndTriple(llvm::Module &module) {
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 0784c3c95e47e2..7e2da1e0303c74 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -50,7 +50,7 @@ void registerFromLLVMIRTranslation() {
std::string errStr;
llvm::raw_string_ostream errStream(errStr);
err.print(/*ProgName=*/"", errStream);
- emitError(UnknownLoc::get(context)) << errStr;
+ emitError(UnknownLoc::get(context)) << errStream.str();
return {};
}
if (llvm::verifyModule(*llvmModule, &llvm::errs()))
diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
index d948ff5eaf1769..bdb15a290209b8 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -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 str;
+ return os.str();
}
/// Get the declaration of an overloaded llvm intrinsic. First we get the
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
index 1595bd28a7609b..2145b953b64e62 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
@@ -25,7 +25,7 @@ mlir::LLVM::createSourceLocStrFromLocation(Location loc,
std::string locStr;
llvm::raw_string_ostream locOS(locStr);
locOS << loc;
- return builder.getOrCreateSrcLocStr(locStr, strLen);
+ return builder.getOrCreateSrcLocStr(locOS.str(), strLen);
}
llvm::Constant *
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index 21f2050cbceb9c..d1732cb808928a 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -55,7 +55,7 @@ static std::string diag(const llvm::Value &value) {
std::string str;
llvm::raw_string_ostream os(str);
os << value;
- return str;
+ return os.str();
}
// Utility to print an LLVM metadata node as a string for passing
@@ -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 str;
+ return os.str();
}
/// Returns the name of the global_ctors global variables.
diff --git a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
index 4c15523a05fa82..6c28c04fc1e087 100644
--- a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
@@ -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(enclosedOpName);
+ auto enclosedOpcode = spirv::symbolizeOpcode(rss.str());
if (!enclosedOpcode) {
op.emitError("Couldn't find op code for op ")
diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
index 7719eb68b2c2e0..b0feda0517caa6 100644
--- a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
@@ -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: " << valueStr;
+ << bitwidth << "-bit integer literal: " << rss.str();
return 0;
}
}
@@ -968,7 +968,7 @@ uint32_t Serializer::prepareConstantFp(Location loc, FloatAttr floatAttr,
value.print(rss);
emitError(loc, "cannot serialize ")
- << floatAttr.getType() << "-typed float literal: " << valueStr;
+ << floatAttr.getType() << "-typed float literal: " << rss.str();
return 0;
}
diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index 575fb4aacd947c..2f842df48826d5 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -148,8 +148,9 @@ class Parser {
std::string docStr;
{
llvm::raw_string_ostream docOS(docStr);
+ std::string tmpDocStr = doc.str();
raw_indented_ostream(docOS).printReindented(
- StringRef(docStr).rtrim(" \t"));
+ StringRef(tmpDocStr).rtrim(" \t"));
}
return docStr;
}
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 5a7b17672c518b..0b88d31f41a7cf 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -312,7 +312,8 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
FallbackAsmResourceMap fallbackResourceMap;
ParserConfig parseConfig(&roundtripContext, /*verifyAfterParse=*/true,
&fallbackResourceMap);
- roundtripModule = parseSourceString<Operation *>(buffer, parseConfig);
+ roundtripModule =
+ parseSourceString<Operation *>(ostream.str(), parseConfig);
if (!roundtripModule) {
op->emitOpError() << "failed to parse " << testType
<< " content back, cannot verify round-trip.\n";
diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index fa0af7665ba4c4..82e9863ab40bf3 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -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 buf;
+ return os.str();
}
/// Escape special characters such as '\n' and quotation marks.
@@ -199,7 +199,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
std::string buf;
llvm::raw_string_ostream ss(buf);
attr.print(ss);
- os << truncateString(buf);
+ os << truncateString(ss.str());
}
/// Append an edge to the list of edges.
@@ -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(buf) << ")";
+ os << truncateString(ss.str()) << ")";
}
// Print attributes.
More information about the Mlir-commits
mailing list