Index: ELF/Error.h =================================================================== --- ELF/Error.h +++ ELF/Error.h @@ -12,6 +12,8 @@ #include "lld/Core/LLVM.h" +#include "llvm/Support/Error.h" + namespace lld { namespace elf { @@ -31,6 +33,13 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg); LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg, const Twine &Prefix); +inline void check(Error E, std::string Msg = "") { + handleAllErrors(std::move(E), [&](llvm::ErrorInfoBase &EIB) { + error(EIB.message().c_str()); + return Error::success(); + }); +} + template T check(ErrorOr E) { if (auto EC = E.getError()) fatal(EC.message()); Index: ELF/InputFiles.h =================================================================== --- ELF/InputFiles.h +++ ELF/InputFiles.h @@ -239,6 +239,7 @@ ArrayRef getSymbols() { return Symbols; } static bool shouldSkip(uint32_t Flags); std::unique_ptr Obj; + MemoryBufferRef getBuffer() { return MB; } private: std::vector Symbols; Index: ELF/SymbolTable.h =================================================================== --- ELF/SymbolTable.h +++ ELF/SymbolTable.h @@ -137,6 +137,8 @@ llvm::DenseSet SoNames; std::unique_ptr Lto; + + std::vector> CompiledBitcodeFiles; }; template struct Symtab { static SymbolTable *X; }; Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -16,11 +16,16 @@ #include "SymbolTable.h" #include "Config.h" +#include "Driver.h" #include "Error.h" #include "LinkerScript.h" #include "SymbolListFile.h" #include "Symbols.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/CodeGen/CommandFlags.h" +#include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/LTO/LTO.h" +#include "llvm/LTO/LTOBackend.h" #include "llvm/Support/StringSaver.h" using namespace llvm; @@ -102,6 +107,92 @@ F->parse(ComdatGroups); } +static void diagnosticHandler(const DiagnosticInfo &DI) { + if (const auto *BDI = dyn_cast(&DI)) { + std::error_code EC = BDI->getError(); + if (EC == BitcodeError::InvalidBitcodeSignature) + return; + } + + std::string ErrStorage; + { + raw_string_ostream OS(ErrStorage); + DiagnosticPrinterRawOStream DP(OS); + DI.print(DP); + } + warning(ErrStorage.c_str()); +} + +static std::unique_ptr createLTO() { + lto::Config Conf; + lto::ThinBackend Backend; + unsigned ParallelCodeGenParallelismLevel = Config->LtoJobs; + + // LLD supports the new relocations. + Conf.Options = InitTargetOptionsFromCodeGenFlags(); + Conf.Options.RelaxELFRelocations = true; + + Conf.RelocModel = Config->Pic ? Reloc::PIC_ : Reloc::Static; + Conf.DisableVerify = Config->DisableVerify; + Conf.DiagHandler = diagnosticHandler; + Conf.OptLevel = Config->LtoO; + + // Set up a custom pipeline if we've been asked to. + if (!Config->LtoNewPmPasses.empty()) + Conf.OptPipeline = Config->LtoNewPmPasses; + + if (Config->SaveTemps) + check(Conf.addSaveTemps(std::string(Config->OutputFile) + ".", + /*UseInputModulePath*/ true)); + + return (HasError) + ? nullptr + : llvm::make_unique(std::move(Conf), Backend, + ParallelCodeGenParallelismLevel); +} + +namespace { +// Define the LTOOutput handling +class LTOOutput : public lto::NativeObjectOutput { + StringRef Path; + +public: + LTOOutput(StringRef Path) : Path(Path) {} + // Open the filename \p Path and allocate a stream. + std::unique_ptr getStream() override { + int FD; + std::error_code EC = sys::fs::openFileForWrite(Path, FD, sys::fs::F_None); + if (EC) + llvm_unreachable("can't open the file"); + return llvm::make_unique(FD, true); + } +}; +} + +/// Return the desired output filename given a base input name, a flag +/// indicating whether a temp file should be generated, and an optional task id. +/// The new filename generated is returned in \p NewFilename. +static void getOutputFileName(SmallString<128> InFilename, + SmallString<128> &NewFilename, int TaskID = -1) { + NewFilename = InFilename; + if (TaskID >= 0) + NewFilename += utostr(TaskID); +} + +static void undefine(Symbol *S) { + replaceBody(S, S->body()->getName(), STV_DEFAULT, S->body()->Type, + nullptr); +} + +// This is for use when debugging LTO. +static void saveBuffer(StringRef Buffer, const Twine &Path) { + std::error_code EC; + raw_fd_ostream OS(Path.str(), EC, sys::fs::OpenFlags::F_None); + if (EC) + error(EC, "cannot create " + Path); + OS << Buffer; +} + // This function is where all the optimizations of link-time // optimization happens. When LTO is in use, some input files are // not in native object file format but in the LLVM bitcode format. @@ -113,19 +204,84 @@ if (BitcodeFiles.empty()) return; - // Compile bitcode files. - Lto.reset(new BitcodeCompiler); - for (const std::unique_ptr &F : BitcodeFiles) - Lto->add(*F); - std::vector> IFs = Lto->compile(); + std::unique_ptr LtoObj = createLTO(); + if (HasError) + return; + + for (const std::unique_ptr &F : BitcodeFiles) { + Expected> ObjOrErr = + lto::InputFile::create(F->getBuffer()); + if (!ObjOrErr) + error(toString(ObjOrErr.takeError()).c_str()); + if (HasError) + return; + lto::InputFile &Obj = **ObjOrErr; + Module &M = Obj.getModule(); + if (M.getDataLayoutStr().empty()) + fatal("invalid bitcode file: " + F->getName() + " has no datalayout"); + + unsigned SymNum = 0; + std::vector Syms = F->getSymbols(); + std::vector Resols(Syms.size()); + for (LLVM_ATTRIBUTE_UNUSED auto &ObjSym : Obj.symbols()) { + Symbol *Sym = Syms[SymNum]; + lto::SymbolResolution &R = Resols[SymNum]; + ++SymNum; + SymbolBody *B = Sym->body(); + if (B->File != F.get()) + continue; + if (Sym->body()->isUndefined()) + continue; + R.Prevailing = Sym->body()->isDefined(); + R.VisibleToRegularObj = Sym->IsUsedInRegularObj || Sym->includeInDynsym(); + if (Sym->body()->isDefined()) + undefine(Sym); + } + check(LtoObj->add(std::move(*ObjOrErr), Resols)); + if (HasError) + return; + } + + SmallString<128> Filename; + Filename = Config->OutputFile; + unsigned MaxTasks = LtoObj->getMaxTasks(); + std::vector> Filenames(MaxTasks); + + auto AddOutput = + [&](size_t Task) -> std::unique_ptr { + auto &OutputName = Filenames[Task]; + getOutputFileName(Filename, OutputName, MaxTasks > 1 ? Task : -1); + return llvm::make_unique(OutputName); + }; - // Replace bitcode symbols. - for (auto &IF : IFs) { - ObjectFile *Obj = cast>(IF.release()); + check(LtoObj->run(AddOutput)); + if (HasError) + return; - DenseSet DummyGroups; - Obj->parse(DummyGroups); - ObjectFiles.emplace_back(Obj); + for (unsigned I = 0; I != MaxTasks; ++I) { + if (!Filenames[I].empty()) { + auto MBOrErr = MemoryBuffer::getFile(Filenames[I]); + if (auto EC = MBOrErr.getError()) { + error(EC, "cannot open " + Filenames[I]); + return; + } + MemoryBufferRef MB = (*MBOrErr)->getMemBufferRef(); + + // Do we want to move this to the LTO API? + if (Config->SaveTemps) { + if (MaxTasks == 1) + saveBuffer(MB.getBuffer(), Config->OutputFile + ".lto.o"); + else + saveBuffer(MB.getBuffer(), Config->OutputFile + Twine(I) + ".lto.o"); + } + + CompiledBitcodeFiles.push_back(std::move(*MBOrErr)); + ObjectFile *Obj = + cast>(createObjectFile(MB).release()); + DenseSet DummyGroups; + Obj->parse(DummyGroups); + ObjectFiles.emplace_back(Obj); + } } } Index: test/ELF/lto/archive-3.ll =================================================================== --- test/ELF/lto/archive-3.ll +++ test/ELF/lto/archive-3.ll @@ -3,12 +3,12 @@ ; RUN: llvm-as %s -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t1.o %t2.o -o %t3 -save-temps -; RUN: llvm-dis %t3.lto.bc -o - | FileCheck %s +; RUN: llvm-dis %t3.0.2.internalize.bc -o - | FileCheck %s ; RUN: rm -f %t.a ; RUN: llvm-ar rcs %t.a %t1.o ; RUN: ld.lld -m elf_x86_64 %t.a %t1.o %t2.o -o %t3 -save-temps -; RUN: llvm-dis %t3.lto.bc -o - | FileCheck %s +; RUN: llvm-dis %t3.0.2.internalize.bc -o - | FileCheck %s ; CHECK: define internal void @foo() { Index: test/ELF/lto/available-externally.ll =================================================================== --- test/ELF/lto/available-externally.ll +++ test/ELF/lto/available-externally.ll @@ -1,7 +1,7 @@ ; RUN: llvm-as %s -o %t1.o ; RUN: llvm-as %p/Inputs/available-externally.ll -o %t2.o ; RUN: ld.lld %t1.o %t2.o -m elf_x86_64 -o %t.so -shared -save-temps -; RUN: llvm-dis < %t.so.lto.bc | FileCheck %s +; RUN: llvm-dis < %t.so.0.2.internalize.bc | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/common2.ll =================================================================== --- test/ELF/lto/common2.ll +++ test/ELF/lto/common2.ll @@ -1,6 +1,6 @@ ; RUN: llvm-as %s -o %t1.o ; RUN: ld.lld -m elf_x86_64 %t1.o -o %t -shared -save-temps -; RUN: llvm-dis < %t.lto.bc | FileCheck %s +; RUN: llvm-dis < %t.0.2.internalize.bc | FileCheck %s ; RUN: llvm-readobj -t %t | FileCheck %s --check-prefix=SHARED target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/common3.ll =================================================================== --- test/ELF/lto/common3.ll +++ test/ELF/lto/common3.ll @@ -1,7 +1,7 @@ ; RUN: llvm-as %s -o %t1.o ; RUN: llvm-as %S/Inputs/common3.ll -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t1.o %t2.o -o %t -shared -save-temps -; RUN: llvm-dis < %t.lto.bc | FileCheck %s +; RUN: llvm-dis < %t.0.2.internalize.bc | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/discard-value-names.ll =================================================================== --- test/ELF/lto/discard-value-names.ll +++ test/ELF/lto/discard-value-names.ll @@ -1,7 +1,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: ld.lld -m elf_x86_64 -shared -save-temps %t.o -o %t2.o -; RUN: llvm-dis < %t2.o.lto.bc | FileCheck %s +; RUN: llvm-dis < %t2.o.0.0.preopt.bc | FileCheck %s ; CHECK: @GlobalValueName ; CHECK: @foo(i32 %in) Index: test/ELF/lto/drop-debug-info.ll =================================================================== --- test/ELF/lto/drop-debug-info.ll +++ test/ELF/lto/drop-debug-info.ll @@ -5,5 +5,5 @@ ; ; RUN: ld.lld -m elf_x86_64 -shared %p/Inputs/drop-debug-info.bc \ ; RUN: -disable-verify 2>&1 | FileCheck %s -; CHECK: warning: ignoring debug info with an invalid version (1) in {{.*}}drop-debug-info.bc +; CHECK: ignoring debug info with an invalid version (1) in {{.*}}drop-debug-info.bc Index: test/ELF/lto/drop-linkage.ll =================================================================== --- test/ELF/lto/drop-linkage.ll +++ test/ELF/lto/drop-linkage.ll @@ -5,7 +5,7 @@ ; RUN: llc %s -o %t.o -filetype=obj ; RUN: llvm-as %p/Inputs/drop-linkage.ll -o %t2.o ; RUN: ld.lld %t.o %t2.o -o %t.so -save-temps -shared -; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s define void @foo() { ret void Index: test/ELF/lto/internalize-basic.ll =================================================================== --- test/ELF/lto/internalize-basic.ll +++ test/ELF/lto/internalize-basic.ll @@ -1,7 +1,7 @@ ; REQUIRES: x86 ; RUN: llvm-as %s -o %t.o ; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 -save-temps -; RUN: llvm-dis < %t2.lto.bc | FileCheck %s +; RUN: llvm-dis < %t2.0.2.internalize.bc | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/internalize-exportdyn.ll =================================================================== --- test/ELF/lto/internalize-exportdyn.ll +++ test/ELF/lto/internalize-exportdyn.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: llvm-as %p/Inputs/internalize-exportdyn.ll -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t.o %t2.o -o %t2 --export-dynamic -save-temps -; RUN: llvm-dis < %t2.lto.bc | FileCheck %s +; RUN: llvm-dis < %t2.0.2.internalize.bc | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/internalize-llvmused.ll =================================================================== --- test/ELF/lto/internalize-llvmused.ll +++ test/ELF/lto/internalize-llvmused.ll @@ -1,7 +1,7 @@ ; REQUIRES: x86 ; RUN: llvm-as %s -o %t.o ; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 -save-temps -; RUN: llvm-dis < %t2.lto.bc | FileCheck %s +; RUN: llvm-dis < %t2.0.2.internalize.bc | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/internalize-undef.ll =================================================================== --- test/ELF/lto/internalize-undef.ll +++ test/ELF/lto/internalize-undef.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: llvm-as %p/Inputs/internalize-undef.ll -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t.o %t2.o -o %t -save-temps -; RUN: llvm-dis < %t.lto.bc | FileCheck %s +; RUN: llvm-dis < %t.0.2.internalize.bc | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/internalize-version-script.ll =================================================================== --- test/ELF/lto/internalize-version-script.ll +++ test/ELF/lto/internalize-version-script.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: echo "{ global: foo; local: *; };" > %t.script ; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 -shared --version-script %t.script -save-temps -; RUN: llvm-dis < %t2.lto.bc | FileCheck %s +; RUN: llvm-dis < %t2.0.2.internalize.bc | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/irmover-error.ll =================================================================== --- test/ELF/lto/irmover-error.ll +++ test/ELF/lto/irmover-error.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as -o %t2.bc %S/Inputs/irmover-error.ll ; RUN: not ld.lld -m elf_x86_64 %t1.bc %t2.bc -o %t 2>&1 | FileCheck %s -; CHECK: failed to link module {{.*}}2.bc: linking module flags 'foo': IDs have conflicting values +; CHECK: linking module flags 'foo': IDs have conflicting values target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/linkonce-odr.ll =================================================================== --- test/ELF/lto/linkonce-odr.ll +++ test/ELF/lto/linkonce-odr.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %p/Inputs/linkonce-odr.ll -o %t1.o ; RUN: llc -relocation-model=pic %s -o %t2.o -filetype=obj ; RUN: ld.lld %t1.o %t2.o -o %t.so -shared -save-temps -; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/linkonce.ll =================================================================== --- test/ELF/lto/linkonce.ll +++ test/ELF/lto/linkonce.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %p/Inputs/linkonce.ll -o %t1.o ; RUN: llc -relocation-model=pic %s -o %t2.o -filetype=obj ; RUN: ld.lld %t1.o %t2.o -o %t.so -shared -save-temps -; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/ltopasses-basic.ll =================================================================== --- test/ELF/lto/ltopasses-basic.ll +++ test/ELF/lto/ltopasses-basic.ll @@ -1,8 +1,7 @@ ; REQUIRES: x86 -; RUN: rm -f %t.so.lto.bc %t.so.lto.opt.bc %t.so.lto.o ; RUN: llvm-as %s -o %t.o ; RUN: ld.lld -m elf_x86_64 %t.o -o %t.so -save-temps -mllvm -debug-pass=Arguments -shared 2>&1 | FileCheck %s --check-prefix=MLLVM -; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/ltopasses-custom.ll =================================================================== --- test/ELF/lto/ltopasses-custom.ll +++ test/ELF/lto/ltopasses-custom.ll @@ -3,8 +3,8 @@ ; RUN: ld.lld -m elf_x86_64 %t.o -o %t.so -save-temps --lto-aa-pipeline=basic-aa \ ; RUN: --lto-newpm-passes=ipsccp -shared ; RUN: ld.lld -m elf_x86_64 %t.o -o %t2.so -save-temps --lto-newpm-passes=loweratomic -shared -; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s -; RUN: llvm-dis %t2.so.lto.opt.bc -o - | FileCheck %s --check-prefix=ATOMIC +; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s +; RUN: llvm-dis %t2.so.0.4.opt.bc -o - | FileCheck %s --check-prefix=ATOMIC target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/save-temps.ll =================================================================== --- test/ELF/lto/save-temps.ll +++ test/ELF/lto/save-temps.ll @@ -5,9 +5,9 @@ ; RUN: llvm-as %p/Inputs/save-temps.ll -o %t2.o ; RUN: ld.lld -shared -m elf_x86_64 %t.o %t2.o -save-temps ; RUN: llvm-nm a.out | FileCheck %s -; RUN: llvm-nm a.out.lto.bc | FileCheck %s +; RUN: llvm-nm a.out.0.0.preopt.bc | FileCheck %s ; RUN: llvm-nm a.out.lto.o | FileCheck %s -; RUN: llvm-dis a.out.lto.bc +; RUN: llvm-dis a.out.0.0.preopt.bc target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/type-merge.ll =================================================================== --- test/ELF/lto/type-merge.ll +++ test/ELF/lto/type-merge.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: llvm-as %p/Inputs/type-merge.ll -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t.o %t2.o -o %t -shared -save-temps -; RUN: llvm-dis < %t.lto.bc | FileCheck %s +; RUN: llvm-dis < %t.0.0.preopt.bc | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/type-merge2.ll =================================================================== --- test/ELF/lto/type-merge2.ll +++ test/ELF/lto/type-merge2.ll @@ -1,7 +1,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: llvm-as %p/Inputs/type-merge2.ll -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t.o %t2.o -o %t.so -shared -save-temps -; RUN: llvm-dis %t.so.lto.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.0.preopt.bc -o - | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/unnamed-addr-comdat.ll =================================================================== --- test/ELF/lto/unnamed-addr-comdat.ll +++ test/ELF/lto/unnamed-addr-comdat.ll @@ -1,6 +1,6 @@ ; RUN: llvm-as %s -o %t.o ; RUN: ld.lld -m elf_x86_64 %t.o %t.o -o %t.so -save-temps -shared -; RUN: llvm-dis %t.so.lto.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.2.internalize.bc -o - | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/unnamed-addr-drop.ll =================================================================== --- test/ELF/lto/unnamed-addr-drop.ll +++ test/ELF/lto/unnamed-addr-drop.ll @@ -1,7 +1,7 @@ ; RUN: llvm-as %s -o %t1.o ; RUN: llvm-as %S/Inputs/unnamed-addr-drop.ll -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t1.o %t2.o -o %t.so -save-temps -shared -; RUN: llvm-dis %t.so.lto.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.2.internalize.bc -o - | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/unnamed-addr-lib.ll =================================================================== --- test/ELF/lto/unnamed-addr-lib.ll +++ test/ELF/lto/unnamed-addr-lib.ll @@ -3,7 +3,7 @@ ; RUN: llvm-mc %p/Inputs/unnamed-addr-lib.s -o %t2.o -filetype=obj -triple=x86_64-pc-linux ; RUN: ld.lld %t2.o -shared -o %t2.so ; RUN: ld.lld -m elf_x86_64 %t.o %t2.so -o %t.so -save-temps -shared -; RUN: llvm-dis %t.so.lto.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.2.internalize.bc -o - | FileCheck %s ; This documents a small limitation of lld's internalization logic. We decide ; that bar should be in the symbol table because if it is it will preempt the @@ -11,8 +11,8 @@ ; We could add one extra bit for ODR so that we know that preemption is not ; necessary, but that is probably not worth it. -; CHECK: @foo = internal constant i8 42 -; CHECK: @bar = weak_odr constant i8 42 +; CHECK: @foo = internal unnamed_addr constant i8 42 +; CHECK: @bar = weak_odr unnamed_addr constant i8 42 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: test/ELF/lto/unnamed-addr.ll =================================================================== --- test/ELF/lto/unnamed-addr.ll +++ test/ELF/lto/unnamed-addr.ll @@ -1,6 +1,6 @@ ; RUN: llvm-as %s -o %t.o ; RUN: ld.lld -m elf_x86_64 %t.o -o %t.so -save-temps -shared -; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s +; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: test/ELF/lto/version-script.ll =================================================================== --- test/ELF/lto/version-script.ll +++ test/ELF/lto/version-script.ll @@ -2,7 +2,7 @@ ; RUN: llvm-as %s -o %t.o ; RUN: echo "VERSION_1.0{ global: foo; local: *; }; VERSION_2.0{ global: bar; local: *; };" > %t.script ; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 -shared --version-script %t.script -save-temps -; RUN: llvm-dis < %t2.lto.bc | FileCheck %s +; RUN: llvm-dis < %t2.0.0.preopt.bc | FileCheck %s ; RUN: llvm-readobj -V -dyn-symbols %t2 | FileCheck --check-prefix=DSO %s target triple = "x86_64-unknown-linux-gnu"