[lld] r320872 - [WebAssembly] Don't include lazy symbols in import table

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 14:17:16 PST 2017


Author: sbc
Date: Fri Dec 15 14:17:15 2017
New Revision: 320872

URL: http://llvm.org/viewvc/llvm-project?rev=320872&view=rev
Log:
[WebAssembly] Don't include lazy symbols in import table

This bug was introduced in: https://reviews.llvm.org/D41304.
Add a test for this case.

Differential Revision: https://reviews.llvm.org/D41309

Modified:
    lld/trunk/test/wasm/archive.ll
    lld/trunk/wasm/Writer.cpp

Modified: lld/trunk/test/wasm/archive.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/archive.ll?rev=320872&r1=320871&r2=320872&view=diff
==============================================================================
--- lld/trunk/test/wasm/archive.ll (original)
+++ lld/trunk/test/wasm/archive.ll Fri Dec 15 14:17:15 2017
@@ -1,16 +1,11 @@
-; Verify that multually dependant object files in an archive is handled
-; correctly.
-;
 ; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o
-; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/archive1.ll -o %t2.o
-; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/archive2.ll -o %t3.o
-; RUN: llvm-ar rcs %t.a %t2.o %t3.o
+; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/archive1.ll -o %t.a1.o
+; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/archive2.ll -o %t.a2.o
+; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/hello.ll -o %t.a3.o
+; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o
 ; RUN: lld -flavor wasm %t.a %t.o -o %t.wasm
 ; RUN: llvm-nm -a %t.wasm | FileCheck %s
 
-; Specifying the same archive twice is allowed.
-; RUN: lld -flavor wasm %t.a %t.a %t.o -o %t.wasm
-
 declare i32 @foo() local_unnamed_addr #1
 
 define i32 @_start() local_unnamed_addr #0 {
@@ -19,6 +14,18 @@ entry:
   ret i32 %call
 }
 
-; CHECK: T _start
-; CHECK: T bar
-; CHECK: T foo
+; Verify that multually dependant object files in an archive is handled
+; correctly.
+
+; CHECK:      00000002 T _start
+; CHECK-NEXT: 00000002 T _start
+; CHECK-NEXT: 00000000 T bar
+; CHECK-NEXT: 00000000 T bar
+; CHECK-NEXT: 00000001 T foo
+; CHECK-NEXT: 00000001 T foo
+
+; Verify that symbols from unused objects don't appear in the symbol table
+; CHECK-NOT: hello
+
+; Specifying the same archive twice is allowed.
+; RUN: lld -flavor wasm %t.a %t.a %t.o -o %t.wasm

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=320872&r1=320871&r2=320872&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Dec 15 14:17:15 2017
@@ -551,7 +551,7 @@ void Writer::calculateOffsets() {
 
 void Writer::calculateImports() {
   for (Symbol *Sym : Symtab->getSymbols()) {
-    if (Sym->isDefined() || Sym->isWeak())
+    if (!Sym->isUndefined() || Sym->isWeak())
       continue;
 
     if (Sym->isFunction()) {




More information about the llvm-commits mailing list