[lld] r325376 - [WebAssembly] Fix bug is function signature checking
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 11:45:41 PST 2018
Author: sbc
Date: Fri Feb 16 11:45:41 2018
New Revision: 325376
URL: http://llvm.org/viewvc/llvm-project?rev=325376&view=rev
Log:
[WebAssembly] Fix bug is function signature checking
This bug effected undefined symbols that were resolved by
existing defined symbols. We were skipping the signature
check in this case.
Differential Revision: https://reviews.llvm.org/D43399
Modified:
lld/trunk/test/wasm/init-fini.ll
lld/trunk/test/wasm/signature-mismatch.ll
lld/trunk/wasm/Symbols.h
Modified: lld/trunk/test/wasm/init-fini.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/init-fini.ll?rev=325376&r1=325375&r2=325376&view=diff
==============================================================================
--- lld/trunk/test/wasm/init-fini.ll (original)
+++ lld/trunk/test/wasm/init-fini.ll Fri Feb 16 11:45:41 2018
@@ -23,8 +23,8 @@ entry:
ret void
}
-define void @__cxa_atexit() {
- ret void
+define i32 @__cxa_atexit(i32 %func, i32 %arg, i32 %dso_handle) {
+ ret i32 0
}
define hidden void @_start() {
@@ -52,9 +52,9 @@ entry:
; CHECK-NEXT: - Offset:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
-; CHECK-NEXT: Functions: [ 6, 9, 13, 15, 17 ]
+; CHECK-NEXT: Functions: [ 6, 8, 12, 14, 16 ]
-; CHECK: Body: 100010011007100B100E100B10101000100A100B10120B
+; CHECK: Body: 100010011007100A100D100A100F10001009100A10110B
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 0
@@ -78,28 +78,26 @@ entry:
; CHECK-NEXT: - Index: 7
; CHECK-NEXT: Name: .Lregister_call_dtors.101
; CHECK-NEXT: - Index: 8
-; CHECK-NEXT: Name: .Lbitcast
-; CHECK-NEXT: - Index: 9
; CHECK-NEXT: Name: .Lcall_dtors.1001
-; CHECK-NEXT: - Index: 10
+; CHECK-NEXT: - Index: 9
; CHECK-NEXT: Name: .Lregister_call_dtors.1001
-; CHECK-NEXT: - Index: 11
+; CHECK-NEXT: - Index: 10
; CHECK-NEXT: Name: myctor
-; CHECK-NEXT: - Index: 12
+; CHECK-NEXT: - Index: 11
; CHECK-NEXT: Name: mydtor
-; CHECK-NEXT: - Index: 13
+; CHECK-NEXT: - Index: 12
; CHECK-NEXT: Name: .Lcall_dtors.101
-; CHECK-NEXT: - Index: 14
+; CHECK-NEXT: - Index: 13
; CHECK-NEXT: Name: .Lregister_call_dtors.101
-; CHECK-NEXT: - Index: 15
+; CHECK-NEXT: - Index: 14
; CHECK-NEXT: Name: .Lcall_dtors.202
-; CHECK-NEXT: - Index: 16
+; CHECK-NEXT: - Index: 15
; CHECK-NEXT: Name: .Lregister_call_dtors.202
-; CHECK-NEXT: - Index: 17
+; CHECK-NEXT: - Index: 16
; CHECK-NEXT: Name: .Lcall_dtors.2002
-; CHECK-NEXT: - Index: 18
+; CHECK-NEXT: - Index: 17
; CHECK-NEXT: Name: .Lregister_call_dtors.2002
-; CHECK-NEXT: - Index: 19
+; CHECK-NEXT: - Index: 18
; CHECK-NEXT: Name: __wasm_call_ctors
; CHECK-NEXT: ...
@@ -126,8 +124,6 @@ entry:
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
; RELOC-NEXT: - Name: .Lregister_call_dtors.101
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
-; RELOC-NEXT: - Name: .Lbitcast
-; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
; RELOC-NEXT: - Name: .Lcall_dtors.1001
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
; RELOC-NEXT: - Name: .Lregister_call_dtors.1001
@@ -156,21 +152,21 @@ entry:
; RELOC-NEXT: - Priority: 101
; RELOC-NEXT: FunctionIndex: 7
; RELOC-NEXT: - Priority: 101
-; RELOC-NEXT: FunctionIndex: 11
+; RELOC-NEXT: FunctionIndex: 10
; RELOC-NEXT: - Priority: 101
-; RELOC-NEXT: FunctionIndex: 14
+; RELOC-NEXT: FunctionIndex: 13
; RELOC-NEXT: - Priority: 202
-; RELOC-NEXT: FunctionIndex: 11
+; RELOC-NEXT: FunctionIndex: 10
; RELOC-NEXT: - Priority: 202
-; RELOC-NEXT: FunctionIndex: 16
+; RELOC-NEXT: FunctionIndex: 15
; RELOC-NEXT: - Priority: 1001
; RELOC-NEXT: FunctionIndex: 0
; RELOC-NEXT: - Priority: 1001
-; RELOC-NEXT: FunctionIndex: 10
+; RELOC-NEXT: FunctionIndex: 9
; RELOC-NEXT: - Priority: 2002
-; RELOC-NEXT: FunctionIndex: 11
+; RELOC-NEXT: FunctionIndex: 10
; RELOC-NEXT: - Priority: 2002
-; RELOC-NEXT: FunctionIndex: 18
+; RELOC-NEXT: FunctionIndex: 17
; RELOC-NEXT: - Type: CUSTOM
; RELOC-NEXT: Name: name
; RELOC-NEXT: FunctionNames:
@@ -191,25 +187,23 @@ entry:
; RELOC-NEXT: - Index: 7
; RELOC-NEXT: Name: .Lregister_call_dtors.101
; RELOC-NEXT: - Index: 8
-; RELOC-NEXT: Name: .Lbitcast
-; RELOC-NEXT: - Index: 9
; RELOC-NEXT: Name: .Lcall_dtors.1001
-; RELOC-NEXT: - Index: 10
+; RELOC-NEXT: - Index: 9
; RELOC-NEXT: Name: .Lregister_call_dtors.1001
-; RELOC-NEXT: - Index: 11
+; RELOC-NEXT: - Index: 10
; RELOC-NEXT: Name: myctor
-; RELOC-NEXT: - Index: 12
+; RELOC-NEXT: - Index: 11
; RELOC-NEXT: Name: mydtor
-; RELOC-NEXT: - Index: 13
+; RELOC-NEXT: - Index: 12
; RELOC-NEXT: Name: .Lcall_dtors.101
-; RELOC-NEXT: - Index: 14
+; RELOC-NEXT: - Index: 13
; RELOC-NEXT: Name: .Lregister_call_dtors.101
-; RELOC-NEXT: - Index: 15
+; RELOC-NEXT: - Index: 14
; RELOC-NEXT: Name: .Lcall_dtors.202
-; RELOC-NEXT: - Index: 16
+; RELOC-NEXT: - Index: 15
; RELOC-NEXT: Name: .Lregister_call_dtors.202
-; RELOC-NEXT: - Index: 17
+; RELOC-NEXT: - Index: 16
; RELOC-NEXT: Name: .Lcall_dtors.2002
-; RELOC-NEXT: - Index: 18
+; RELOC-NEXT: - Index: 17
; RELOC-NEXT: Name: .Lregister_call_dtors.2002
; RELOC-NEXT: ...
Modified: lld/trunk/test/wasm/signature-mismatch.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/signature-mismatch.ll?rev=325376&r1=325375&r2=325376&view=diff
==============================================================================
--- lld/trunk/test/wasm/signature-mismatch.ll (original)
+++ lld/trunk/test/wasm/signature-mismatch.ll Fri Feb 16 11:45:41 2018
@@ -1,6 +1,10 @@
; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o
; RUN: llc -filetype=obj %s -o %t.main.o
; RUN: not lld -flavor wasm --check-signatures -o %t.wasm %t.main.o %t.ret32.o 2>&1 | FileCheck %s
+; Run the test again by with the object files in the other order to verify
+; the check works when the undefined symbol is resolved by an existing defined
+; one.
+; RUN: not lld -flavor wasm --check-signatures -o %t.wasm %t.ret32.o %t.main.o 2>&1 | FileCheck %s -check-prefix=REVERSE
target triple = "wasm32-unknown-unknown-wasm"
@@ -16,3 +20,7 @@ declare i32 @ret32(i32, i64, i32) local_
; CHECK: error: function signature mismatch: ret32
; CHECK-NEXT: >>> defined as (I32, I64, I32) -> I32 in {{.*}}.main.o
; CHECK-NEXT: >>> defined as (F32) -> I32 in {{.*}}.ret32.o
+
+; REVERSE: error: function signature mismatch: ret32
+; REVERSE-NEXT: >>> defined as (F32) -> I32 in {{.*}}.ret32.o
+; REVERSE-NEXT: >>> defined as (I32, I64, I32) -> I32 in {{.*}}.main.o
Modified: lld/trunk/wasm/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.h?rev=325376&r1=325375&r2=325376&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.h (original)
+++ lld/trunk/wasm/Symbols.h Fri Feb 16 11:45:41 2018
@@ -94,7 +94,7 @@ public:
S->kind() == UndefinedFunctionKind;
}
- bool hasFunctionType() const { return FunctionType != nullptr; }
+ bool hasFunctionType() const { return Chunk || FunctionType; }
const WasmSignature &getFunctionType() const;
uint32_t getTableIndex() const;
More information about the llvm-commits
mailing list