[llvm] r322814 - Don't drop dso_local in LTO.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 21:38:44 PST 2018
Author: rafael
Date: Wed Jan 17 21:38:43 2018
New Revision: 322814
URL: http://llvm.org/viewvc/llvm-project?rev=322814&view=rev
Log:
Don't drop dso_local in LTO.
LTO sets dso_local as an optimization, so don't clear it.
This avoid clearing it from undefined hidden symbols, which would then
fail the verifier.
Added:
llvm/trunk/test/LTO/Resolution/X86/setting-dso-local.ll
Modified:
llvm/trunk/lib/LTO/LTO.cpp
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=322814&r1=322813&r2=322814&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Wed Jan 17 21:38:43 2018
@@ -639,7 +639,8 @@ LTO::addRegularLTO(BitcodeModule BM, Arr
}
// Set the 'local' flag based on the linker resolution for this symbol.
- GV->setDSOLocal(Res.FinalDefinitionInLinkageUnit);
+ if (Res.FinalDefinitionInLinkageUnit)
+ GV->setDSOLocal(Res.FinalDefinitionInLinkageUnit);
}
// Common resolution: collect the maximum size/alignment over all commons.
// We also record if we see an instance of a common as prevailing, so that
Added: llvm/trunk/test/LTO/Resolution/X86/setting-dso-local.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/setting-dso-local.ll?rev=322814&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/setting-dso-local.ll (added)
+++ llvm/trunk/test/LTO/Resolution/X86/setting-dso-local.ll Wed Jan 17 21:38:43 2018
@@ -0,0 +1,15 @@
+; RUN: llvm-as -o %t.o %s
+; RUN: llvm-lto2 run -o %t2.o %t.o -r=%t.o,_start,plx -r=%t.o,foobar,x
+; RUN: llvm-readelf --symbols %t2.o.0 | FileCheck %s
+
+; We used to fail the verifier by clearing dso_local from foobar
+
+; CHECK: 0000000000000000 0 NOTYPE GLOBAL HIDDEN UND foobar
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at foobar = external hidden global i32
+define i32* @_start() {
+ ret i32* @foobar
+}
More information about the llvm-commits
mailing list