Skip to content

Commit 123e8c7

Browse files
committed
[mlir] Don't call llvm::raw_string_ostream::flush() (NFC)
Don't call raw_string_ostream::flush(), which is essentially a no-op. As specified in the docs, raw_string_ostream is always unbuffered. ( 65b1361 for further reference )
1 parent 5a68ac8 commit 123e8c7

File tree

7 files changed

+0
-24
lines changed

7 files changed

+0
-24
lines changed

mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ static std::string buildMmaSparseAsmConstraintString(unsigned matASize,
495495
// The final operand is for the sparsity metadata.
496496
// The sparsity selector appears as direct literal.
497497
ss << "r";
498-
ss.flush();
499498
return str;
500499
}
501500

@@ -535,7 +534,6 @@ static std::string buildMmaSparseAsmString(
535534
ss << "$" << asmArgIdx++ << ",";
536535
assert(metaDataSelector <= 1);
537536
ss << "0x" << metaDataSelector << ";";
538-
ss.flush();
539537
return asmStr;
540538
}
541539

mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,12 @@ void PtxBuilder::insertValue(Value v, PTXRegisterMod itype) {
9999
} else {
100100
ss << getModifier() << getRegisterType(t) << ",";
101101
}
102-
ss.flush();
103102
}
104103
return;
105104
}
106105
// Handle Scalars
107106
addValue(v);
108107
ss << getModifier() << getRegisterType(v) << ",";
109-
ss.flush();
110108
}
111109

112110
LLVM::InlineAsmOp PtxBuilder::build() {

mlir/lib/Dialect/Transform/IR/TransformDialect.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ void transform::TransformDialect::reportDuplicateTypeRegistration(
111111
llvm::raw_string_ostream msg(buffer);
112112
msg << "extensible dialect type '" << mnemonic
113113
<< "' is already registered with a different implementation";
114-
msg.flush();
115114
llvm::report_fatal_error(StringRef(buffer));
116115
}
117116

@@ -121,7 +120,6 @@ void transform::TransformDialect::reportDuplicateOpRegistration(
121120
llvm::raw_string_ostream msg(buffer);
122121
msg << "extensible dialect operation '" << opName
123122
<< "' is already registered with a mismatching TypeID";
124-
msg.flush();
125123
llvm::report_fatal_error(StringRef(buffer));
126124
}
127125

mlir/lib/Dialect/XeGPU/IR/XeGPUOps.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static std::string makeString(T array, bool breakline = false) {
3737
os << "\n\t\t";
3838
}
3939
os << array.back() << "]";
40-
os.flush();
4140
return buf;
4241
}
4342

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ translateDataLayout(DataLayoutSpecInterface attribute,
195195
bool isLittleEndian =
196196
value.getValue() == DLTIDialect::kDataLayoutEndiannessLittle;
197197
layoutStream << "-" << (isLittleEndian ? "e" : "E");
198-
layoutStream.flush();
199198
continue;
200199
}
201200
if (key.getValue() == DLTIDialect::kDataLayoutProgramMemorySpaceKey) {
@@ -205,7 +204,6 @@ translateDataLayout(DataLayoutSpecInterface attribute,
205204
if (space == 0)
206205
continue;
207206
layoutStream << "-P" << space;
208-
layoutStream.flush();
209207
continue;
210208
}
211209
if (key.getValue() == DLTIDialect::kDataLayoutGlobalMemorySpaceKey) {
@@ -215,7 +213,6 @@ translateDataLayout(DataLayoutSpecInterface attribute,
215213
if (space == 0)
216214
continue;
217215
layoutStream << "-G" << space;
218-
layoutStream.flush();
219216
continue;
220217
}
221218
if (key.getValue() == DLTIDialect::kDataLayoutAllocaMemorySpaceKey) {
@@ -225,7 +222,6 @@ translateDataLayout(DataLayoutSpecInterface attribute,
225222
if (space == 0)
226223
continue;
227224
layoutStream << "-A" << space;
228-
layoutStream.flush();
229225
continue;
230226
}
231227
if (key.getValue() == DLTIDialect::kDataLayoutStackAlignmentKey) {
@@ -235,7 +231,6 @@ translateDataLayout(DataLayoutSpecInterface attribute,
235231
if (alignment == 0)
236232
continue;
237233
layoutStream << "-S" << alignment;
238-
layoutStream.flush();
239234
continue;
240235
}
241236
emitError(*loc) << "unsupported data layout key " << key;
@@ -293,7 +288,6 @@ translateDataLayout(DataLayoutSpecInterface attribute,
293288
if (failed(result))
294289
return failure();
295290
}
296-
layoutStream.flush();
297291
StringRef layoutSpec(llvmDataLayout);
298292
if (layoutSpec.starts_with("-"))
299293
layoutSpec = layoutSpec.drop_front();

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,6 @@ void OpEmitter::genPropertiesSupport() {
14111411
// Backward compat for now, TODO: Remove at some point.
14121412
os << " if (!attr) attr = dict.get(\"result_segment_sizes\");";
14131413
}
1414-
os.flush();
14151414

14161415
setPropMethod << "{\n"
14171416
<< formatv(propFromAttrFmt,
@@ -1445,7 +1444,6 @@ void OpEmitter::genPropertiesSupport() {
14451444
// Backward compat for now
14461445
os << " if (!attr) attr = dict.get(\"result_segment_sizes\");";
14471446
}
1448-
os.flush();
14491447

14501448
setPropMethod << formatv(R"decl(
14511449
{{
@@ -4188,10 +4186,8 @@ OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(
41884186
" bool operator!=(const Properties &rhs) const {\n"
41894187
" return !(*this == rhs);\n"
41904188
" }\n";
4191-
comparatorOs.flush();
41924189
os << comparator;
41934190
os << " };\n";
4194-
os.flush();
41954191

41964192
genericAdaptorBase.declare<ExtraClassDeclaration>(std::move(declarations));
41974193
}

mlir/unittests/Support/IndentedOstreamTest.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ TEST(FormatTest, SingleLine) {
1717
llvm::raw_string_ostream os(str);
1818
raw_indented_ostream ros(os);
1919
ros << 10;
20-
ros.flush();
2120
EXPECT_THAT(str, StrEq("10"));
2221
}
2322

@@ -30,7 +29,6 @@ TEST(FormatTest, SimpleMultiLine) {
3029
ros << "\n";
3130
ros << "c";
3231
ros << "\n";
33-
ros.flush();
3432
EXPECT_THAT(str, StrEq("ab\nc\n"));
3533
}
3634

@@ -43,7 +41,6 @@ TEST(FormatTest, SimpleMultiLineIndent) {
4341
ros << "\n";
4442
ros << "c";
4543
ros << "\n";
46-
ros.flush();
4744
EXPECT_THAT(str, StrEq(" a b\n c\n"));
4845
}
4946

@@ -62,7 +59,6 @@ TEST(FormatTest, SingleRegion) {
6259
}
6360
}
6461
ros << "after";
65-
ros.flush();
6662
const auto *expected =
6763
R"(before
6864
inside 10
@@ -79,7 +75,6 @@ after)";
7975
ros.scope().os << "inside " << 10 << "\n two\n";
8076
ros.scope().os.scope("{\n", "\n}\n").os << "inner inner";
8177
ros << "after";
82-
ros.flush();
8378
EXPECT_THAT(os.str(), StrEq(expected));
8479
}
8580

@@ -99,7 +94,6 @@ TEST(FormatTest, Reindent) {
9994
10095
)";
10196
ros.printReindented(desc);
102-
ros.flush();
10397
const auto *expected =
10498
R"(First line
10599
second line
@@ -120,7 +114,6 @@ TEST(FormatTest, ReindentLineEndings) {
120114
const auto *desc =
121115
"\r\n\r\n\r\n First line\r\n second line";
122116
ros.printReindented(desc);
123-
ros.flush();
124117
const auto *expected = "First line\r\n second line";
125118
EXPECT_THAT(str, StrEq(expected));
126119
}

0 commit comments

Comments
 (0)