diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/tools/gold/Inputs/linkonce-weak.ll | 3 | ||||
| -rw-r--r-- | llvm/test/tools/gold/linkonce-weak.ll | 19 | ||||
| -rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 8 |
3 files changed, 29 insertions, 1 deletions
diff --git a/llvm/test/tools/gold/Inputs/linkonce-weak.ll b/llvm/test/tools/gold/Inputs/linkonce-weak.ll new file mode 100644 index 0000000..f42af8f --- /dev/null +++ b/llvm/test/tools/gold/Inputs/linkonce-weak.ll @@ -0,0 +1,3 @@ +define weak_odr void @f() { + ret void +} diff --git a/llvm/test/tools/gold/linkonce-weak.ll b/llvm/test/tools/gold/linkonce-weak.ll new file mode 100644 index 0000000..765275b --- /dev/null +++ b/llvm/test/tools/gold/linkonce-weak.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/linkonce-weak.ll -o %t2.o + +; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t2.o %t.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +define linkonce_odr void @f() { + ret void +} + +; Test that we get a weak_odr regardless of the order of the files +; CHECK: define weak_odr void @f() { diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index ffee1ff..d5d58d0 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -637,8 +637,14 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile, keepGlobalValue(*GV, KeptAliases); break; - case LDPR_PREEMPTED_REG: case LDPR_PREEMPTED_IR: + // Gold might have selected a linkonce_odr and preempted a weak_odr. + // In that case we have to make sure we don't end up internalizing it. + if (!GV->isDiscardableIfUnused()) + Maybe.erase(Sym.name); + + // fall-through + case LDPR_PREEMPTED_REG: Drop.insert(GV); break; |
