[lld] r262761 - lto: Start taking symbol visibility into consideration.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 4 16:09:38 PST 2016
Author: rafael
Date: Fri Mar 4 18:09:37 2016
New Revision: 262761
URL: http://llvm.org/viewvc/llvm-project?rev=262761&view=rev
Log:
lto: Start taking symbol visibility into consideration.
Added:
lld/trunk/test/ELF/lto/Inputs/visibility.s
lld/trunk/test/ELF/lto/visibility.ll
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=262761&r1=262760&r2=262761&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Mar 4 18:09:37 2016
@@ -427,10 +427,23 @@ void BitcodeFile::parse(DenseSet<StringR
}
for (const BasicSymbolRef &Sym : Obj->symbols()) {
- if (const GlobalValue *GV = Obj->getSymbolGV(Sym.getRawDataRefImpl()))
+ uint8_t Visibility = STV_DEFAULT;
+ if (const GlobalValue *GV = Obj->getSymbolGV(Sym.getRawDataRefImpl())) {
if (const Comdat *C = GV->getComdat())
if (!KeptComdats.count(C))
continue;
+ switch (GV->getVisibility()) {
+ case GlobalValue::DefaultVisibility:
+ Visibility = STV_DEFAULT;
+ break;
+ case GlobalValue::HiddenVisibility:
+ Visibility = STV_HIDDEN;
+ break;
+ case GlobalValue::ProtectedVisibility:
+ Visibility = STV_PROTECTED;
+ break;
+ }
+ }
SmallString<64> Name;
raw_svector_ostream OS(Name);
@@ -440,7 +453,7 @@ void BitcodeFile::parse(DenseSet<StringR
uint32_t Flags = Sym.getFlags();
bool IsWeak = Flags & BasicSymbolRef::SF_Weak;
if (Flags & BasicSymbolRef::SF_Undefined)
- Body = new (Alloc) Undefined(NameRef, IsWeak, STV_DEFAULT, false);
+ Body = new (Alloc) Undefined(NameRef, IsWeak, Visibility, false);
else
Body = new (Alloc) DefinedBitcode(NameRef, IsWeak);
SymbolBodies.push_back(Body);
Added: lld/trunk/test/ELF/lto/Inputs/visibility.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/Inputs/visibility.s?rev=262761&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/Inputs/visibility.s (added)
+++ lld/trunk/test/ELF/lto/Inputs/visibility.s Fri Mar 4 18:09:37 2016
@@ -0,0 +1,3 @@
+ .global g
+g:
+ ret
Added: lld/trunk/test/ELF/lto/visibility.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/visibility.ll?rev=262761&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/visibility.ll (added)
+++ lld/trunk/test/ELF/lto/visibility.ll Fri Mar 4 18:09:37 2016
@@ -0,0 +1,22 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t1.o
+; RUN: llvm-mc -triple=x86_64-pc-linux %p/Inputs/visibility.s -o %t2.o -filetype=obj
+; RUN: ld.lld %t1.o %t2.o -o %t.so -shared
+; RUN: llvm-readobj -t %t.so | FileCheck %s
+
+; CHECK: Name: g
+; CHECK-NEXT: Value: 0x1000
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Local
+; CHECK-NEXT: Type: None
+; CHECK-NEXT: Other: 2
+; CHECK-NEXT: Section: .text
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare hidden void @g()
+define void @f() {
+ call void @g()
+ ret void
+}
More information about the llvm-commits
mailing list