[lld] r326581 - [WebAssembly] Export non-hidden defined data symbols via wasm globals
Nicholas Wilson via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 06:51:36 PST 2018
Author: ncw
Date: Fri Mar 2 06:51:36 2018
New Revision: 326581
URL: http://llvm.org/viewvc/llvm-project?rev=326581&view=rev
Log:
[WebAssembly] Export non-hidden defined data symbols via wasm globals
This fixes a TODO introduced in rLLD325861.
Differential Revision: https://reviews.llvm.org/D43930
Modified:
lld/trunk/test/wasm/call-indirect.ll
lld/trunk/test/wasm/comdats.ll
lld/trunk/test/wasm/local-symbols.ll
lld/trunk/test/wasm/locals-duplicate.test
lld/trunk/test/wasm/weak-symbols.ll
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/test/wasm/call-indirect.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/call-indirect.ll?rev=326581&r1=326580&r2=326581&view=diff
==============================================================================
--- lld/trunk/test/wasm/call-indirect.ll (original)
+++ lld/trunk/test/wasm/call-indirect.ll Fri Mar 2 06:51:36 2018
@@ -85,9 +85,15 @@ define void @call_ptr(i64 (i64)* %arg) {
; CHECK-NEXT: - Index: 2
; CHECK-NEXT: Type: I32
; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1036
+; CHECK-NEXT: - Index: 3
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1032
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
@@ -111,6 +117,9 @@ define void @call_ptr(i64 (i64)* %arg) {
; CHECK-NEXT: - Name: foo
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
+; CHECK-NEXT: - Name: indirect_func
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Name: call_ptr
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 4
Modified: lld/trunk/test/wasm/comdats.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/comdats.ll?rev=326581&r1=326580&r2=326581&view=diff
==============================================================================
--- lld/trunk/test/wasm/comdats.ll (original)
+++ lld/trunk/test/wasm/comdats.ll Fri Mar 2 06:51:36 2018
@@ -34,6 +34,12 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1027
+; CHECK-NEXT: - Index: 3
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
@@ -51,6 +57,9 @@ entry:
; CHECK-NEXT: - Name: inlineFn
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
+; CHECK-NEXT: - Name: constantData
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Name: callInline1
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
Modified: lld/trunk/test/wasm/local-symbols.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/local-symbols.ll?rev=326581&r1=326580&r2=326581&view=diff
==============================================================================
--- lld/trunk/test/wasm/local-symbols.ll (original)
+++ lld/trunk/test/wasm/local-symbols.ll Fri Mar 2 06:51:36 2018
@@ -63,6 +63,12 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1032
+; CHECK-NEXT: - Index: 3
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
@@ -77,6 +83,9 @@ entry:
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
+; CHECK-NEXT: - Name: foo
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Functions:
; CHECK-NEXT: - Index: 0
Modified: lld/trunk/test/wasm/locals-duplicate.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/locals-duplicate.test?rev=326581&r1=326580&r2=326581&view=diff
==============================================================================
--- lld/trunk/test/wasm/locals-duplicate.test (original)
+++ lld/trunk/test/wasm/locals-duplicate.test Fri Mar 2 06:51:36 2018
@@ -48,6 +48,18 @@
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1048
+; CHECK-NEXT: - Index: 3
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1028
+; CHECK-NEXT: - Index: 4
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1036
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
@@ -68,6 +80,9 @@
; CHECK-NEXT: - Name: get_global2A
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 4
+; CHECK-NEXT: - Name: colliding_global2
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Name: get_global3A
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 5
@@ -86,6 +101,9 @@
; CHECK-NEXT: - Name: get_global1B
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 12
+; CHECK-NEXT: - Name: colliding_global1
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 4
; CHECK-NEXT: - Name: get_global2B
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 13
Modified: lld/trunk/test/wasm/weak-symbols.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-symbols.ll?rev=326581&r1=326580&r2=326581&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-symbols.ll (original)
+++ lld/trunk/test/wasm/weak-symbols.ll Fri Mar 2 06:51:36 2018
@@ -60,6 +60,12 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1032
+; CHECK-NEXT: - Index: 3
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
@@ -80,6 +86,9 @@ entry:
; CHECK-NEXT: - Name: exportWeak1
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
+; CHECK-NEXT: - Name: weakGlobal
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Name: exportWeak2
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 4
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=326581&r1=326580&r2=326581&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Mar 2 06:51:36 2018
@@ -677,14 +677,8 @@ void Writer::calculateExports() {
DEBUG(dbgs() << "exporting sym: " << Sym->getName() << "\n");
- if (auto *D = dyn_cast<DefinedData>(Sym)) {
- // TODO Remove this check here; for non-relocatable output we actually
- // used only to create fake-global exports for the synthetic symbols. Fix
- // this in a future commit
- if (Sym != WasmSym::DataEnd && Sym != WasmSym::HeapBase)
- continue;
+ if (auto *D = dyn_cast<DefinedData>(Sym))
DefinedFakeGlobals.emplace_back(D);
- }
ExportedSymbols.emplace_back(Sym);
}
}
More information about the llvm-commits
mailing list