[llvm] d31e314 - [llvm] Don't call raw_string_ostream::flush() (NFC)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 10:20:49 PDT 2024
Author: Youngsuk Kim
Date: 2024-09-20T12:19:59-05:00
New Revision: d31e314131b17b0a802a80593a33cb11213c60d1
URL: https://github.com/llvm/llvm-project/commit/d31e314131b17b0a802a80593a33cb11213c60d1
DIFF: https://github.com/llvm/llvm-project/commit/d31e314131b17b0a802a80593a33cb11213c60d1.diff
LOG: [llvm] Don't call 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.
( 65b13610a5226b84889b923bae884ba395ad084d for further reference )
Added:
Modified:
llvm/lib/Analysis/CallGraphSCCPass.cpp
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
llvm/lib/IRReader/IRReader.cpp
llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
llvm/lib/TableGen/Record.cpp
llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index ccba8b3831c8f4..7caf814cdb2d79 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -453,7 +453,6 @@ bool CGPassManager::RunAllPassesOnSCC(CallGraphSCC &CurSCC, CallGraph &CG,
OS << LS;
CGN->print(OS);
}
- OS.flush();
#endif
dumpPassInfo(P, EXECUTION_MSG, ON_CG_MSG, Functions);
}
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 6e23969cd99bac..7de68b12045f14 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -256,7 +256,6 @@ void MIRPrinter::print(const MachineFunction &MF) {
.print(MBB);
IsNewlineNeeded = true;
}
- StrOS.flush();
// Convert machine metadata collected during the print of the machine
// function.
convertMachineMetadataNodes(YamlMF, MF, MST);
diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
index 601686fdd3dd51..894abf5777f161 100644
--- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -620,7 +620,6 @@ Error DwarfTransformer::convert(uint32_t NumThreads, OutputAggregator &Out) {
// Print ThreadLogStorage lines into an actual stream under a lock
std::lock_guard<std::mutex> guard(LogMutex);
if (Out.GetOS()) {
- StrStream.flush();
Out << storage;
}
Out.Merge(ThreadOut);
diff --git a/llvm/lib/IRReader/IRReader.cpp b/llvm/lib/IRReader/IRReader.cpp
index 7885c36a79876a..a7e7deee8aa912 100644
--- a/llvm/lib/IRReader/IRReader.cpp
+++ b/llvm/lib/IRReader/IRReader.cpp
@@ -124,7 +124,6 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
raw_string_ostream os(buf);
Diag.print(nullptr, os, false);
- os.flush();
*OutMessage = strdup(buf.c_str());
}
diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
index e1d2700623ec3c..b15919f68725fa 100644
--- a/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
+++ b/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
@@ -308,7 +308,6 @@ void UnknownSymbolRecord::map(yaml::IO &io) {
std::string Str;
raw_string_ostream OS(Str);
Binary.writeAsBinary(OS);
- OS.flush();
Data.assign(Str.begin(), Str.end());
}
}
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index ff2da3badb3628..a72a0799a08025 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -838,7 +838,6 @@ Init *UnOpInit::Fold(Record *CurRec, bool IsFinal) const {
std::string S;
raw_string_ostream OS(S);
OS << *Def->getDef();
- OS.flush();
return StringInit::get(RK, S);
} else {
// Otherwise, print the value of the variable.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
index f5b5e9e4275986..6a79aa0cbf4df7 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
@@ -321,7 +321,6 @@ void AMDGPUAsmPrinter::emitInstruction(const MachineInstr *MI) {
HexStream << format("%s%08X", (i > 0 ? " " : ""), CodeDWord);
}
- DisasmStream.flush();
DisasmLineMaxLen = std::max(DisasmLineMaxLen, DisasmLine.size());
}
}
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index f973924ae58ea2..728e421b7f89e3 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -6094,7 +6094,6 @@ bool AMDGPUAsmParser::ParseToEndDirective(const char *AssemblerDirectiveBegin,
Twine(AssemblerDirectiveEnd) + Twine(" not found"));
}
- CollectStream.flush();
return false;
}
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index cda664a151ef54..8b5ec8793d84a2 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -904,7 +904,6 @@ std::string AMDGPUTargetID::toString() const {
StreamRep << Processor << Features;
- StreamRep.flush();
return StringRep;
}
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index d7197a7923eaf0..38c51666139a89 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -596,7 +596,6 @@ std::string NVPTXAsmPrinter::getVirtualRegisterName(unsigned Reg) const {
NameStr << getNVPTXRegClassStr(RC) << MappedVR;
- NameStr.flush();
return Name;
}
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index dcde86388dcd9d..9528aea3497999 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -3246,7 +3246,6 @@ static std::string convertToSinitPriority(int Priority) {
std::string PrioritySuffix;
llvm::raw_string_ostream os(PrioritySuffix);
os << llvm::format_hex_no_prefix(P, 8);
- os.flush();
return PrioritySuffix;
}
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 02f65ffcea6454..41f93fde17d329 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3025,7 +3025,6 @@ std::string RISCVInstrInfo::createMIROperandComment(
<< (Policy & RISCVII::MASK_AGNOSTIC ? "ma" : "mu");
}
- OS.flush();
return Comment;
}
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index b6560f1cc60747..24db39c4e98b96 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1541,7 +1541,6 @@ static std::string getShuffleComment(const MachineInstr *MI, unsigned SrcOp1Idx,
printDstRegisterName(CS, MI, SrcOp1Idx);
CS << " = ";
printShuffleMask(CS, Src1Name, Src2Name, Mask);
- CS.flush();
return Comment;
}
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 1d4f85ab1e8ea5..694b2e6af718b7 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -340,7 +340,6 @@ namespace {
std::string FunctionNameAndLine;
raw_string_ostream FNLOS(FunctionNameAndLine);
FNLOS << getFunctionName(SP) << SP->getLine();
- FNLOS.flush();
FuncChecksum = hash_value(FunctionNameAndLine);
}
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index b985d5b3b226a1..10442fa0bb9003 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -404,7 +404,6 @@ static std::string getBranchCondString(Instruction *TI) {
else
OS << "_Const";
}
- OS.flush();
return result;
}
@@ -2364,7 +2363,6 @@ void llvm::setProfMetadata(Module *M, Instruction *TI,
raw_string_ostream OS(BranchProbStr);
OS << BP;
OS << " (total count : " << TotalCount << ")";
- OS.flush();
Function *F = TI->getParent()->getParent();
OptimizationRemarkEmitter ORE(F);
ORE.emit([&]() {
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 6565aed4bc390c..7e2721d0c5a5e6 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1857,7 +1857,6 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
std::string S;
raw_string_ostream StringS(S);
ReproducerModule->print(StringS, nullptr);
- StringS.flush();
OptimizationRemark Rem(DEBUG_TYPE, "Reproducer", &F);
Rem << ore::NV("module") << S;
ORE.emit(Rem);
diff --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
index 8af85d27adcf6c..0d98e844cf91ea 100644
--- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -2306,7 +2306,6 @@ class LowerMatrixIntrinsics {
default:
llvm_unreachable("Unhandled case");
}
- SS.flush();
write(Tmp);
}
}
@@ -2361,7 +2360,6 @@ class LowerMatrixIntrinsics {
else
TmpStream << "scalar";
}
- TmpStream.flush();
Tmp = std::string(StringRef(Tmp).trim());
LineLength += Tmp.size();
Stream << Tmp;
@@ -2435,7 +2433,6 @@ class LowerMatrixIntrinsics {
}
const std::string &getResult() {
- Stream.flush();
return Str;
}
};
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 806dbd5bb7304e..3cf41628ba0c7d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4427,7 +4427,6 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
OS << " call to " << CalledFn->getName();
} else
OS << " " << Instruction::getOpcodeName(Opcode);
- OS.flush();
reportVectorizationInfo(OutString, "InvalidCost", ORE, OrigLoop, nullptr,
R->getDebugLoc());
Tail = Tail.drop_front(Subset.size());
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index ddeb97463281c9..3102ed9d844e56 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -413,7 +413,6 @@ static std::string shortBundleName(ArrayRef<Value *> VL, int Idx = -1) {
if (Idx >= 0)
OS << "Idx: " << Idx << ", ";
OS << "n=" << VL.size() << " [" << *VL.front() << ", ..]";
- OS.flush();
return Result;
}
#endif
More information about the llvm-commits
mailing list