[lld] r262225 - lto: don't fetch members for weak undef.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 29 06:29:49 PST 2016
Author: rafael
Date: Mon Feb 29 08:29:48 2016
New Revision: 262225
URL: http://llvm.org/viewvc/llvm-project?rev=262225&view=rev
Log:
lto: don't fetch members for weak undef.
Added:
lld/trunk/test/ELF/lto/undef-weak.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=262225&r1=262224&r2=262225&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Feb 29 08:29:48 2016
@@ -454,11 +454,11 @@ void BitcodeFile::parse() {
StringRef NameRef = Saver.save(StringRef(Name));
SymbolBody *Body;
uint32_t Flags = Sym.getFlags();
+ bool IsWeak = Flags & BasicSymbolRef::SF_Weak;
if (Flags & BasicSymbolRef::SF_Undefined)
- Body = new (Alloc) Undefined(NameRef, false, STV_DEFAULT, false);
+ Body = new (Alloc) Undefined(NameRef, IsWeak, STV_DEFAULT, false);
else
- Body =
- new (Alloc) DefinedBitcode(NameRef, Flags & BasicSymbolRef::SF_Weak);
+ Body = new (Alloc) DefinedBitcode(NameRef, IsWeak);
SymbolBodies.push_back(Body);
}
}
Added: lld/trunk/test/ELF/lto/undef-weak.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/undef-weak.ll?rev=262225&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/undef-weak.ll (added)
+++ lld/trunk/test/ELF/lto/undef-weak.ll Mon Feb 29 08:29:48 2016
@@ -0,0 +1,29 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %S/Inputs/archive.ll -o %t1.o
+; RUN: rm -f %t.a
+; RUN: llvm-ar rcs %t.a %t1.o
+
+
+; RUN: llvm-as %s -o %t2.o
+; RUN: ld.lld -m elf_x86_64 %t2.o -o %t2.so %t.a -shared
+; RUN: llvm-readobj -t %t2.so | FileCheck %s
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+declare extern_weak void @f()
+define void @foo() {
+ call void @f()
+ ret void
+}
+
+; We should not fetch the archive member.
+
+; CHECK: Name: f ({{.*}})
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Weak
+; CHECK-NEXT: Type: None
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: Undefined
+
More information about the llvm-commits
mailing list