Skip to content

Commit 095b41c

Browse files
committed
[mlir] Reland 5a6e52d with update (NFC)
Excluded updates to mlir/lib/AsmParser/Parser.cpp , which caused LIT failure "FAIL: MLIR::completion.test" on multiple buildbots.
1 parent 0c55ad1 commit 095b41c

File tree

13 files changed

+18
-20
lines changed

13 files changed

+18
-20
lines changed

Diff for: mlir/lib/Bindings/Python/IRAttributes.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ class PyDenseElementsAttribute
708708
llvm::raw_string_ostream os(message);
709709
os << "Expected a static ShapedType for the shaped_type parameter: "
710710
<< py::repr(py::cast(*explicitType));
711-
throw py::value_error(os.str());
711+
throw py::value_error(message);
712712
}
713713
shapedType = *explicitType;
714714
} else {
@@ -732,7 +732,7 @@ class PyDenseElementsAttribute
732732
os << "All attributes must be of the same type and match "
733733
<< "the type parameter: expected=" << py::repr(py::cast(shapedType))
734734
<< ", but got=" << py::repr(py::cast(attrType));
735-
throw py::value_error(os.str());
735+
throw py::value_error(message);
736736
}
737737
}
738738

Diff for: mlir/lib/TableGen/CodeGenHelpers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,5 @@ std::string mlir::tblgen::escapeString(StringRef value) {
315315
std::string ret;
316316
llvm::raw_string_ostream os(ret);
317317
os.write_escaped(value);
318-
return os.str();
318+
return ret;
319319
}

Diff for: mlir/lib/TableGen/Predicate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static std::string combineBinary(ArrayRef<std::string> children,
301301
for (unsigned i = 1; i < size; ++i) {
302302
os << ' ' << combiner << " (" << children[i] << ')';
303303
}
304-
return os.str();
304+
return str;
305305
}
306306

307307
// Prepend negation to the only condition in the predicate expression list.

Diff for: mlir/lib/Target/LLVM/ModuleToObject.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ ModuleToObject::translateToISA(llvm::Module &llvmModule,
182182

183183
codegenPasses.run(llvmModule);
184184
}
185-
return stream.str();
185+
return targetISA;
186186
}
187187

188188
void ModuleToObject::setDataLayoutAndTriple(llvm::Module &module) {

Diff for: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void registerFromLLVMIRTranslation() {
5050
std::string errStr;
5151
llvm::raw_string_ostream errStream(errStr);
5252
err.print(/*ProgName=*/"", errStream);
53-
emitError(UnknownLoc::get(context)) << errStream.str();
53+
emitError(UnknownLoc::get(context)) << errStr;
5454
return {};
5555
}
5656
if (llvm::verifyModule(*llvmModule, &llvm::errs()))

Diff for: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static std::string diagStr(const llvm::Type *type) {
6262
std::string str;
6363
llvm::raw_string_ostream os(str);
6464
type->print(os);
65-
return os.str();
65+
return str;
6666
}
6767

6868
/// Get the declaration of an overloaded llvm intrinsic. First we get the

Diff for: mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mlir::LLVM::createSourceLocStrFromLocation(Location loc,
2525
std::string locStr;
2626
llvm::raw_string_ostream locOS(locStr);
2727
locOS << loc;
28-
return builder.getOrCreateSrcLocStr(locOS.str(), strLen);
28+
return builder.getOrCreateSrcLocStr(locStr, strLen);
2929
}
3030

3131
llvm::Constant *

Diff for: mlir/lib/Target/LLVMIR/ModuleImport.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static std::string diag(const llvm::Value &value) {
5555
std::string str;
5656
llvm::raw_string_ostream os(str);
5757
os << value;
58-
return os.str();
58+
return str;
5959
}
6060

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

7272
/// Returns the name of the global_ctors global variables.

Diff for: mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Serializer::processSpecConstantOperationOp(spirv::SpecConstantOperationOp op) {
137137
std::string enclosedOpName;
138138
llvm::raw_string_ostream rss(enclosedOpName);
139139
rss << "Op" << enclosedOp.getName().stripDialect();
140-
auto enclosedOpcode = spirv::symbolizeOpcode(rss.str());
140+
auto enclosedOpcode = spirv::symbolizeOpcode(enclosedOpName);
141141

142142
if (!enclosedOpcode) {
143143
op.emitError("Couldn't find op code for op ")

Diff for: mlir/lib/Target/SPIRV/Serialization/Serializer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ uint32_t Serializer::prepareConstantInt(Location loc, IntegerAttr intAttr,
915915
value.print(rss, /*isSigned=*/false);
916916

917917
emitError(loc, "cannot serialize ")
918-
<< bitwidth << "-bit integer literal: " << rss.str();
918+
<< bitwidth << "-bit integer literal: " << valueStr;
919919
return 0;
920920
}
921921
}
@@ -968,7 +968,7 @@ uint32_t Serializer::prepareConstantFp(Location loc, FloatAttr floatAttr,
968968
value.print(rss);
969969

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

Diff for: mlir/lib/Tools/PDLL/Parser/Parser.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ class Parser {
148148
std::string docStr;
149149
{
150150
llvm::raw_string_ostream docOS(docStr);
151-
std::string tmpDocStr = doc.str();
152151
raw_indented_ostream(docOS).printReindented(
153-
StringRef(tmpDocStr).rtrim(" \t"));
152+
StringRef(docStr).rtrim(" \t"));
154153
}
155154
return docStr;
156155
}

Diff for: mlir/lib/Tools/mlir-opt/MlirOptMain.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
312312
FallbackAsmResourceMap fallbackResourceMap;
313313
ParserConfig parseConfig(&roundtripContext, /*verifyAfterParse=*/true,
314314
&fallbackResourceMap);
315-
roundtripModule =
316-
parseSourceString<Operation *>(ostream.str(), parseConfig);
315+
roundtripModule = parseSourceString<Operation *>(buffer, parseConfig);
317316
if (!roundtripModule) {
318317
op->emitOpError() << "failed to parse " << testType
319318
<< " content back, cannot verify round-trip.\n";

Diff for: mlir/lib/Transforms/ViewOpGraph.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static std::string strFromOs(function_ref<void(raw_ostream &)> func) {
4646
std::string buf;
4747
llvm::raw_string_ostream os(buf);
4848
func(os);
49-
return os.str();
49+
return buf;
5050
}
5151

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

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

268268
// Print attributes.

0 commit comments

Comments
 (0)