diff --git a/llvm/test/tools/gold/X86/Inputs/emit-llvm.bar.ll b/llvm/test/tools/gold/X86/Inputs/emit-llvm.bar.ll new file mode 100644 --- /dev/null +++ b/llvm/test/tools/gold/X86/Inputs/emit-llvm.bar.ll @@ -0,0 +1,9 @@ +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define dso_local i32 @_Z3barv() #0 { + ret i32 0 +} + +^0 = module: (path: "bar.o", hash: (3853957065, 2310817429, 3119833948, 1366622700, 2470927843)) +^1 = gv: (name: "_Z3barv", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0)))) ; guid = 17377440600225628772 diff --git a/llvm/test/tools/gold/X86/Inputs/emit-llvm.foo.ll b/llvm/test/tools/gold/X86/Inputs/emit-llvm.foo.ll new file mode 100644 --- /dev/null +++ b/llvm/test/tools/gold/X86/Inputs/emit-llvm.foo.ll @@ -0,0 +1,9 @@ +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define dso_local i32 @_Z3foov() #0 { + ret i32 0 +} + +^0 = module: (path: "foo.o", hash: (3786635673, 3275786284, 1544384821, 2103351884, 2354656665)) +^1 = gv: (name: "_Z3foov", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0)))) ; guid = 9191153033785521275 diff --git a/llvm/test/tools/gold/X86/thinlto-emit-llvm.ll b/llvm/test/tools/gold/X86/thinlto-emit-llvm.ll new file mode 100644 --- /dev/null +++ b/llvm/test/tools/gold/X86/thinlto-emit-llvm.ll @@ -0,0 +1,17 @@ +; RUN: llvm-as %p/Inputs/emit-llvm.foo.ll -o %t.foo.bc +; RUN: llvm-as %p/Inputs/emit-llvm.bar.ll -o %t.bar.bc +; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext --shared -plugin-opt thinlto -plugin-opt emit-llvm -m elf_x86_64 %t.foo.bc %t.bar.bc -o %t.bc +; RUN: llvm-dis %t.bc1 -o - | FileCheck --check-prefix=CHECK-BC1 %s +; RUN: llvm-dis %t.bc2 -o - | FileCheck --check-prefix=CHECK-BC2 %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; CHECK-BC1: define dso_local i32 @_Z3foov() +define dso_local i32 @_Z3foov() { + ret i32 0 +} +; CHECK-BC2: define dso_local i32 @_Z3barv() +define dso_local i32 @_Z3barv() { + ret i32 0 +} diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -915,7 +915,10 @@ case options::OT_BC_ONLY: Conf.PostInternalizeModuleHook = [](size_t Task, const Module &M) { std::error_code EC; - raw_fd_ostream OS(output_name, EC, sys::fs::OpenFlags::OF_None); + SmallString<128> TaskFilename; + getOutputFileName(output_name, /* TempOutFile */ false, TaskFilename, + Task); + raw_fd_ostream OS(TaskFilename, EC, sys::fs::OpenFlags::OF_None); if (EC) message(LDPL_FATAL, "Failed to write the output file."); WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ false);