[llvm] a75565a - [llvm][ExecutionEngine] Strip unneeded calls to raw_string_ostream::str() (NFC)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 15 00:56:59 PDT 2024


Author: JOE1994
Date: 2024-09-15T03:47:13-04:00
New Revision: a75565a684feaed48cf92284c5901aaa08fd91ad

URL: https://github.com/llvm/llvm-project/commit/a75565a684feaed48cf92284c5901aaa08fd91ad
DIFF: https://github.com/llvm/llvm-project/commit/a75565a684feaed48cf92284c5901aaa08fd91ad.diff

LOG: [llvm][ExecutionEngine] Strip unneeded calls to raw_string_ostream::str() (NFC)

Avoid excess layer of indirection.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
    llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
    llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
    llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
    llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
    llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 0d7a51bfe73753..4cce4a77b343f0 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -219,7 +219,7 @@ void MCJIT::generateCodeForModule(Module *M) {
     std::string Buf;
     raw_string_ostream OS(Buf);
     logAllUnhandledErrors(LoadedObject.takeError(), OS);
-    report_fatal_error(Twine(OS.str()));
+    report_fatal_error(Twine(Buf));
   }
   std::unique_ptr<RuntimeDyld::LoadedObjectInfo> L =
     Dyld.loadObject(*LoadedObject.get());

diff  --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
index f7852b0ca62e53..f40d93fefb8754 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
@@ -346,11 +346,11 @@ static Error registerJITLoaderPerfStartImpl() {
   // Need to open ourselves, because we need to hand the FD to OpenMarker() and
   // raw_fd_ostream doesn't expose the FD.
   using sys::fs::openFileForWrite;
-  if (auto EC = openFileForReadWrite(FilenameBuf.str(), Tentative.DumpFd,
+  if (auto EC = openFileForReadWrite(Filename, Tentative.DumpFd,
                                      sys::fs::CD_CreateNew, sys::fs::OF_None)) {
     std::string ErrStr;
     raw_string_ostream ErrStream(ErrStr);
-    ErrStream << "could not open JIT dump file " << FilenameBuf.str() << ": "
+    ErrStream << "could not open JIT dump file " << Filename << ": "
               << EC.message() << "\n";
     return make_error<StringError>(std::move(ErrStr), inconvertibleErrorCode());
   }

diff  --git a/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp b/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
index cf9ed7dbff1536..4d14a606b98b00 100644
--- a/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
+++ b/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
@@ -199,10 +199,9 @@ PerfJITEventListener::PerfJITEventListener()
   // Need to open ourselves, because we need to hand the FD to OpenMarker() and
   // raw_fd_ostream doesn't expose the FD.
   using sys::fs::openFileForWrite;
-  if (auto EC =
-          openFileForReadWrite(FilenameBuf.str(), DumpFd,
-			       sys::fs::CD_CreateNew, sys::fs::OF_None)) {
-    errs() << "could not open JIT dump file " << FilenameBuf.str() << ": "
+  if (auto EC = openFileForReadWrite(Filename, DumpFd, sys::fs::CD_CreateNew,
+                                     sys::fs::OF_None)) {
+    errs() << "could not open JIT dump file " << Filename << ": "
            << EC.message() << "\n";
     return;
   }

diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index b98d455cea37cd..d3d3735e4ea53a 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@ -304,10 +304,10 @@ class RuntimeDyldCheckerExprEval {
       if (auto E = TI.takeError()) {
         errs() << "Error obtaining instruction printer: "
                << toString(std::move(E)) << "\n";
-        return std::make_pair(EvalResult(ErrMsgStream.str()), "");
+        return;
       }
       Inst.dump_pretty(ErrMsgStream, TI->InstPrinter.get());
-      return std::make_pair(EvalResult(ErrMsgStream.str()), "");
+      return;
     };
 
     if (OpIdx >= Inst.getNumOperands()) {
@@ -319,7 +319,8 @@ class RuntimeDyldCheckerExprEval {
                    << format("%i", Inst.getNumOperands())
                    << " operands.\nInstruction is:\n  ";
 
-      return printInst(Symbol, Inst, ErrMsgStream);
+      printInst(Symbol, Inst, ErrMsgStream);
+      return {EvalResult(std::move(ErrMsg)), ""};
     }
 
     const MCOperand &Op = Inst.getOperand(OpIdx);
@@ -329,7 +330,8 @@ class RuntimeDyldCheckerExprEval {
       ErrMsgStream << "Operand '" << format("%i", OpIdx) << "' of instruction '"
                    << Symbol << "' is not an immediate.\nInstruction is:\n  ";
 
-      return printInst(Symbol, Inst, ErrMsgStream);
+      printInst(Symbol, Inst, ErrMsgStream);
+      return {EvalResult(std::move(ErrMsg)), ""};
     }
 
     return std::make_pair(EvalResult(Op.getImm()), RemainingExpr);

diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 736d9a3e056f1e..b4e088d5339466 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -1257,7 +1257,7 @@ RuntimeDyldELF::processRelocationRef(
       std::string Buf;
       raw_string_ostream OS(Buf);
       logAllUnhandledErrors(SymTypeOrErr.takeError(), OS);
-      report_fatal_error(Twine(OS.str()));
+      report_fatal_error(Twine(Buf));
     }
     SymType = *SymTypeOrErr;
   }
@@ -1277,7 +1277,7 @@ RuntimeDyldELF::processRelocationRef(
         std::string Buf;
         raw_string_ostream OS(Buf);
         logAllUnhandledErrors(SectionOrErr.takeError(), OS);
-        report_fatal_error(Twine(OS.str()));
+        report_fatal_error(Twine(Buf));
       }
       section_iterator si = *SectionOrErr;
       if (si == Obj.section_end())

diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
index c079d8896c1d7f..19e42253ab1d79 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
@@ -30,7 +30,7 @@ static bool isThumbFunc(object::symbol_iterator Symbol,
     std::string Buf;
     raw_string_ostream OS(Buf);
     logAllUnhandledErrors(SymTypeOrErr.takeError(), OS);
-    report_fatal_error(Twine(OS.str()));
+    report_fatal_error(Twine(Buf));
   }
 
   if (*SymTypeOrErr != object::SymbolRef::ST_Function)


        


More information about the llvm-commits mailing list