if (TempDir.empty())
return;
// User asked to save temps, let dump the bitcode file after import.
- auto SaveTempPath = TempDir + llvm::utostr(count) + Suffix;
+ std::string SaveTempPath = (TempDir + llvm::utostr(count) + Suffix).str();
std::error_code EC;
- raw_fd_ostream OS(SaveTempPath.str(), EC, sys::fs::F_None);
+ raw_fd_ostream OS(SaveTempPath, EC, sys::fs::F_None);
if (EC)
report_fatal_error(Twine("Failed to open ") + SaveTempPath +
" to save optimized bitcode\n");
; verification error.
; RUN: opt -module-summary %s -o %t1.bc
; RUN: opt -module-summary %p/Inputs/linkonce_resolution_comdat.ll -o %t2.bc
-; RUN: llvm-lto -thinlto-action=run %t1.bc %t2.bc -exported-symbol=f -exported-symbol=g
+; RUN: llvm-lto -thinlto-action=run %t1.bc %t2.bc -exported-symbol=f -exported-symbol=g -thinlto-save-temps=%t3.
+
+; RUN: llvm-dis %t3.0.3.imported.bc -o - | FileCheck %s --check-prefix=IMPORT1
+; RUN: llvm-dis %t3.1.3.imported.bc -o - | FileCheck %s --check-prefix=IMPORT2
+; Copy from first module is prevailing and converted to weak_odr, copy
+; from second module is preempted and converted to available_externally and
+; removed from comdat.
+; IMPORT1: define weak_odr i32 @f(i8*) unnamed_addr comdat($c1) {
+; IMPORT2: define available_externally i32 @f(i8*) unnamed_addr {
; RUN: llvm-nm -o - < %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM1
; NM1: W f
static cl::opt<std::string>
ThinLTOCacheDir("thinlto-cache-dir", cl::desc("Enable ThinLTO caching."));
+static cl::opt<std::string> ThinLTOSaveTempsPrefix(
+ "thinlto-save-temps",
+ cl::desc("Save ThinLTO temp files using filenames created by adding "
+ "suffixes to the given file path prefix."));
+
static cl::opt<bool>
SaveModuleFile("save-merged-module", cl::init(false),
cl::desc("Write merged LTO module to file before CodeGen"));
ThinGenerator.addModule(Filename, InputBuffers.back()->getBuffer());
}
+ if (!ThinLTOSaveTempsPrefix.empty())
+ ThinGenerator.setSaveTempsDir(ThinLTOSaveTempsPrefix);
ThinGenerator.run();
auto &Binaries = ThinGenerator.getProducedBinaries();