From 0a5edb4de408ae0405f85c3e4c6da5233f185f63 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Mon, 23 Sep 2024 17:05:28 -0500 Subject: [PATCH] [bolt] 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. ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) --- bolt/include/bolt/Core/BinaryData.h | 1 - bolt/include/bolt/Core/BinaryFunction.h | 1 - bolt/lib/Passes/RetpolineInsertion.cpp | 2 -- bolt/lib/Rewrite/RewriteInstance.cpp | 2 -- bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp | 1 - 5 files changed, 7 deletions(-) diff --git a/bolt/include/bolt/Core/BinaryData.h b/bolt/include/bolt/Core/BinaryData.h index 8a67b3e73b80..6a773c4cb706 100644 --- a/bolt/include/bolt/Core/BinaryData.h +++ b/bolt/include/bolt/Core/BinaryData.h @@ -226,7 +226,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, Sep = ",\n "; TotalCount += AccessInfo.Count; } - SS.flush(); OS << TotalCount << " total counts : " << TempString; return OS; diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h index 6ebbaf94754e..fc0375b75533 100644 --- a/bolt/include/bolt/Core/BinaryFunction.h +++ b/bolt/include/bolt/Core/BinaryFunction.h @@ -117,7 +117,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, TotalCount += CSP.Count; TotalMispreds += CSP.Mispreds; } - SS.flush(); OS << TotalCount << " (" << TotalMispreds << " misses) :" << TempString; return OS; diff --git a/bolt/lib/Passes/RetpolineInsertion.cpp b/bolt/lib/Passes/RetpolineInsertion.cpp index 2808575cc6bb..171177d9e933 100644 --- a/bolt/lib/Passes/RetpolineInsertion.cpp +++ b/bolt/lib/Passes/RetpolineInsertion.cpp @@ -181,7 +181,6 @@ std::string createRetpolineFunctionTag(BinaryContext &BC, if (BrInfo.isReg()) { BC.InstPrinter->printRegName(TagOS, BrInfo.BranchReg); TagOS << "_"; - TagOS.flush(); return Tag; } @@ -212,7 +211,6 @@ std::string createRetpolineFunctionTag(BinaryContext &BC, BC.InstPrinter->printRegName(TagOS, MemRef.SegRegNum); } - TagOS.flush(); return Tag; } diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index 46cd771f61ee..32ec7abe8b66 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -4245,7 +4245,6 @@ void RewriteInstance::addBoltInfoSection() { << "command line:"; for (int I = 0; I < Argc; ++I) DescOS << " " << Argv[I]; - DescOS.flush(); // Encode as GNU GOLD VERSION so it is easily printable by 'readelf -n' const std::string BoltInfo = @@ -4268,7 +4267,6 @@ void RewriteInstance::encodeBATSection() { raw_string_ostream DescOS(DescStr); BAT->write(*BC, DescOS); - DescOS.flush(); const std::string BoltInfo = BinarySection::encodeELFNote("BOLT", DescStr, BinarySection::NT_BOLT_BAT); diff --git a/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp index 53a0c811b41d..f3199ebb00b3 100644 --- a/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp +++ b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp @@ -314,7 +314,6 @@ std::string InstrumentationRuntimeLibrary::buildTables(BinaryContext &BC) { } // Our string table lives immediately after descriptions vector OS << Summary->StringTable; - OS.flush(); return TablesStr; }