[llvm] r306330 - [WebAssembly] Add more support for weak symbols
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 14:01:39 PDT 2017
Author: sbc
Date: Mon Jun 26 14:01:39 2017
New Revision: 306330
URL: http://llvm.org/viewvc/llvm-project?rev=306330&view=rev
Log:
[WebAssembly] Add more support for weak symbols
Add weak symbol tests to MC
Add symbol flags to output of `llvm-readobj -t`.
Differential Revision: https://reviews.llvm.org/D34635
Added:
llvm/trunk/test/MC/WebAssembly/weak-alias.ll
llvm/trunk/test/MC/WebAssembly/weak.ll
Modified:
llvm/trunk/test/tools/llvm-readobj/symbols.test
llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
Added: llvm/trunk/test/MC/WebAssembly/weak-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/weak-alias.ll?rev=306330&view=auto
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/weak-alias.ll (added)
+++ llvm/trunk/test/MC/WebAssembly/weak-alias.ll Mon Jun 26 14:01:39 2017
@@ -0,0 +1,33 @@
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+; foo_alias() function is weak alias of function foo()
+; Generates two exports of the same function, one of them weak
+
+ at foo_alias = weak hidden alias i32 (...), bitcast (i32 ()* @foo to i32 (...)*)
+
+define hidden i32 @foo() #0 {
+entry:
+ ret i32 0
+}
+
+; CHECK: - Type: EXPORT
+; CHECK-NEXT: Exports:
+; CHECK-NEXT: - Name: foo
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 0
+; CHECK-NEXT: - Name: foo_alias
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 0
+
+
+; CHECK: - Type: CUSTOM
+; CHECK-NEXT: Name: name
+; CHECK-NEXT: FunctionNames:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Name: foo
+; CHECK-NEXT: - Type: CUSTOM
+; CHECK-NEXT: Name: linking
+; CHECK-NEXT: SymbolInfo:
+; CHECK-NEXT: - Name: foo_alias
+; CHECK-NEXT: Flags: 1
+; CHECK-NEXT: ...
Added: llvm/trunk/test/MC/WebAssembly/weak.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/weak.ll?rev=306330&view=auto
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/weak.ll (added)
+++ llvm/trunk/test/MC/WebAssembly/weak.ll Mon Jun 26 14:01:39 2017
@@ -0,0 +1,34 @@
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+; Weak external data reference
+ at weak_external_data = extern_weak global i32, align 4
+
+; Weak function definition
+define weak hidden i32 @weak_function() local_unnamed_addr #0 {
+entry:
+ %0 = load i32, i32* @weak_external_data, align 4
+ ret i32 %0
+}
+
+; CHECK: - Type: IMPORT
+; CHECK-NEXT: Imports:
+; CHECK-NEXT: - Module: env
+; CHECK-NEXT: Field: weak_external_data
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: GlobalType: I32
+; CHECK-NEXT: GlobalMutable: false
+
+
+; CHECK: - Type: CUSTOM
+; CHECK-NEXT: Name: name
+; CHECK-NEXT: FunctionNames:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Name: weak_function
+; CHECK-NEXT: - Type: CUSTOM
+; CHECK-NEXT: Name: linking
+; CHECK-NEXT: SymbolInfo:
+; CHECK-NEXT: - Name: weak_external_data
+; CHECK-NEXT: Flags: 1
+; CHECK-NEXT: - Name: weak_function
+; CHECK-NEXT: Flags: 1
+; CHECK-NEXT: ...
Modified: llvm/trunk/test/tools/llvm-readobj/symbols.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/symbols.test?rev=306330&r1=306329&r2=306330&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/symbols.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/symbols.test Mon Jun 26 14:01:39 2017
@@ -75,17 +75,21 @@ WASM: Symbols [
WASM-NEXT: Symbol {
WASM-NEXT: Name: bar
WASM-NEXT: Type: GLOBAL_IMPORT (0x2)
+WASM-NEXT: Flags: 0x0
WASM-NEXT: }
WASM-NEXT: Symbol {
WASM-NEXT: Name: baz
WASM-NEXT: Type: GLOBAL_IMPORT (0x2)
+WASM-NEXT: Flags: 0x0
WASM-NEXT: }
WASM-NEXT: Symbol {
WASM-NEXT: Name: foo
WASM-NEXT: Type: FUNCTION_EXPORT (0x1)
+WASM-NEXT: Flags: 0x0
WASM-NEXT: }
WASM-NEXT: Symbol {
WASM-NEXT: Name: foo
WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4)
+WASM-NEXT: Flags: 0x0
WASM-NEXT: }
WASM-NEXT: ]
Modified: llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/WasmDumper.cpp?rev=306330&r1=306329&r2=306330&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/WasmDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/WasmDumper.cpp Mon Jun 26 14:01:39 2017
@@ -183,6 +183,7 @@ void WasmDumper::printSymbol(const Symbo
WasmSymbol Symbol = Obj->getWasmSymbol(Sym.getRawDataRefImpl());
W.printString("Name", Symbol.Name);
W.printEnum("Type", static_cast<unsigned>(Symbol.Type), makeArrayRef(WasmSymbolTypes));
+ W.printHex("Flags", Symbol.Flags);
}
}
More information about the llvm-commits
mailing list