Skip to content

Commit a75565a

Browse files
committed
[llvm][ExecutionEngine] Strip unneeded calls to raw_string_ostream::str() (NFC)
Avoid excess layer of indirection.
1 parent 9fc789d commit a75565a

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void MCJIT::generateCodeForModule(Module *M) {
219219
std::string Buf;
220220
raw_string_ostream OS(Buf);
221221
logAllUnhandledErrors(LoadedObject.takeError(), OS);
222-
report_fatal_error(Twine(OS.str()));
222+
report_fatal_error(Twine(Buf));
223223
}
224224
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> L =
225225
Dyld.loadObject(*LoadedObject.get());

llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ static Error registerJITLoaderPerfStartImpl() {
346346
// Need to open ourselves, because we need to hand the FD to OpenMarker() and
347347
// raw_fd_ostream doesn't expose the FD.
348348
using sys::fs::openFileForWrite;
349-
if (auto EC = openFileForReadWrite(FilenameBuf.str(), Tentative.DumpFd,
349+
if (auto EC = openFileForReadWrite(Filename, Tentative.DumpFd,
350350
sys::fs::CD_CreateNew, sys::fs::OF_None)) {
351351
std::string ErrStr;
352352
raw_string_ostream ErrStream(ErrStr);
353-
ErrStream << "could not open JIT dump file " << FilenameBuf.str() << ": "
353+
ErrStream << "could not open JIT dump file " << Filename << ": "
354354
<< EC.message() << "\n";
355355
return make_error<StringError>(std::move(ErrStr), inconvertibleErrorCode());
356356
}

llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,9 @@ PerfJITEventListener::PerfJITEventListener()
199199
// Need to open ourselves, because we need to hand the FD to OpenMarker() and
200200
// raw_fd_ostream doesn't expose the FD.
201201
using sys::fs::openFileForWrite;
202-
if (auto EC =
203-
openFileForReadWrite(FilenameBuf.str(), DumpFd,
204-
sys::fs::CD_CreateNew, sys::fs::OF_None)) {
205-
errs() << "could not open JIT dump file " << FilenameBuf.str() << ": "
202+
if (auto EC = openFileForReadWrite(Filename, DumpFd, sys::fs::CD_CreateNew,
203+
sys::fs::OF_None)) {
204+
errs() << "could not open JIT dump file " << Filename << ": "
206205
<< EC.message() << "\n";
207206
return;
208207
}

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ class RuntimeDyldCheckerExprEval {
304304
if (auto E = TI.takeError()) {
305305
errs() << "Error obtaining instruction printer: "
306306
<< toString(std::move(E)) << "\n";
307-
return std::make_pair(EvalResult(ErrMsgStream.str()), "");
307+
return;
308308
}
309309
Inst.dump_pretty(ErrMsgStream, TI->InstPrinter.get());
310-
return std::make_pair(EvalResult(ErrMsgStream.str()), "");
310+
return;
311311
};
312312

313313
if (OpIdx >= Inst.getNumOperands()) {
@@ -319,7 +319,8 @@ class RuntimeDyldCheckerExprEval {
319319
<< format("%i", Inst.getNumOperands())
320320
<< " operands.\nInstruction is:\n ";
321321

322-
return printInst(Symbol, Inst, ErrMsgStream);
322+
printInst(Symbol, Inst, ErrMsgStream);
323+
return {EvalResult(std::move(ErrMsg)), ""};
323324
}
324325

325326
const MCOperand &Op = Inst.getOperand(OpIdx);
@@ -329,7 +330,8 @@ class RuntimeDyldCheckerExprEval {
329330
ErrMsgStream << "Operand '" << format("%i", OpIdx) << "' of instruction '"
330331
<< Symbol << "' is not an immediate.\nInstruction is:\n ";
331332

332-
return printInst(Symbol, Inst, ErrMsgStream);
333+
printInst(Symbol, Inst, ErrMsgStream);
334+
return {EvalResult(std::move(ErrMsg)), ""};
333335
}
334336

335337
return std::make_pair(EvalResult(Op.getImm()), RemainingExpr);

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ RuntimeDyldELF::processRelocationRef(
12571257
std::string Buf;
12581258
raw_string_ostream OS(Buf);
12591259
logAllUnhandledErrors(SymTypeOrErr.takeError(), OS);
1260-
report_fatal_error(Twine(OS.str()));
1260+
report_fatal_error(Twine(Buf));
12611261
}
12621262
SymType = *SymTypeOrErr;
12631263
}
@@ -1277,7 +1277,7 @@ RuntimeDyldELF::processRelocationRef(
12771277
std::string Buf;
12781278
raw_string_ostream OS(Buf);
12791279
logAllUnhandledErrors(SectionOrErr.takeError(), OS);
1280-
report_fatal_error(Twine(OS.str()));
1280+
report_fatal_error(Twine(Buf));
12811281
}
12821282
section_iterator si = *SectionOrErr;
12831283
if (si == Obj.section_end())

llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static bool isThumbFunc(object::symbol_iterator Symbol,
3030
std::string Buf;
3131
raw_string_ostream OS(Buf);
3232
logAllUnhandledErrors(SymTypeOrErr.takeError(), OS);
33-
report_fatal_error(Twine(OS.str()));
33+
report_fatal_error(Twine(Buf));
3434
}
3535

3636
if (*SymTypeOrErr != object::SymbolRef::ST_Function)

0 commit comments

Comments
 (0)