[lld] r337314 - [WebAssemlby] Set IsUsedInRegularObj correctly for undefined data symbols
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 17 12:15:02 PDT 2018
Author: sbc
Date: Tue Jul 17 12:15:02 2018
New Revision: 337314
URL: http://llvm.org/viewvc/llvm-project?rev=337314&view=rev
Log:
[WebAssemlby] Set IsUsedInRegularObj correctly for undefined data symbols
Differential Revision: https://reviews.llvm.org/D49113
Added:
lld/trunk/test/wasm/lto/Inputs/used.ll
lld/trunk/test/wasm/lto/used.ll
Modified:
lld/trunk/wasm/SymbolTable.cpp
Added: lld/trunk/test/wasm/lto/Inputs/used.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/lto/Inputs/used.ll?rev=337314&view=auto
==============================================================================
--- lld/trunk/test/wasm/lto/Inputs/used.ll (added)
+++ lld/trunk/test/wasm/lto/Inputs/used.ll Tue Jul 17 12:15:02 2018
@@ -0,0 +1,8 @@
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+ at foo = hidden global i32 1
+
+define hidden void @bar() {
+ ret void
+}
Added: lld/trunk/test/wasm/lto/used.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/lto/used.ll?rev=337314&view=auto
==============================================================================
--- lld/trunk/test/wasm/lto/used.ll (added)
+++ lld/trunk/test/wasm/lto/used.ll Tue Jul 17 12:15:02 2018
@@ -0,0 +1,45 @@
+; RUN: llc %s -o %t.o -filetype=obj
+; RUN: llvm-as %S/Inputs/used.ll -o %t1.o
+; RUN: wasm-ld %t.o %t1.o -o %t.wasm
+; RUN: obj2yaml %t.wasm | FileCheck %s
+
+; Verify that symbols references from regular objects are preserved by LTO
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+declare void @bar()
+
+ at foo = external global i32
+
+define void @_start() {
+ %val = load i32, i32* @foo, align 4
+ %tobool = icmp ne i32 %val, 0
+ br i1 %tobool, label %callbar, label %return
+
+callbar:
+ call void @bar()
+ br label %return
+
+return:
+ ret void
+}
+
+; CHECK: - Type: DATA
+; CHECK-NEXT: Segments:
+; CHECK-NEXT: - SectionOffset: 7
+; CHECK-NEXT: MemoryIndex: 0
+; CHECK-NEXT: Offset:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1024
+; CHECK-NEXT: Content: '01000000'
+
+; CHECK: - Type: CUSTOM
+; CHECK-NEXT: Name: name
+; CHECK-NEXT: FunctionNames:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Name: __wasm_call_ctors
+; CHECK-NEXT: - Index: 1
+; CHECK-NEXT: Name: _start
+; CHECK-NEXT: - Index: 2
+; CHECK-NEXT: Name: bar
Modified: lld/trunk/wasm/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.cpp?rev=337314&r1=337313&r2=337314&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.cpp (original)
+++ lld/trunk/wasm/SymbolTable.cpp Tue Jul 17 12:15:02 2018
@@ -307,6 +307,9 @@ Symbol *SymbolTable::addUndefinedData(St
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
+ if (!File || File->kind() == InputFile::ObjectKind)
+ S->IsUsedInRegularObj = true;
+
if (WasInserted)
replaceSymbol<UndefinedData>(S, Name, Flags, File);
else if (auto *Lazy = dyn_cast<LazySymbol>(S))
More information about the llvm-commits
mailing list