[WebAssembly] Fix CFI index to account for padding nullptr function
The WebAssembly linker now creates a dummy function at index 0 to
prevent miscomparisons with the NULL pointer, see
https://github.com/WebAssembly/binaryen/pull/658. Thanks to pcc for
pointing out this problem!
Patch by Dominic Chen
Differential Revision: https://reviews.llvm.org/D23137
llvm-svn: 278073
diff --git a/llvm/test/CodeGen/WebAssembly/cfi.ll b/llvm/test/CodeGen/WebAssembly/cfi.ll
index 3cbc65e..e5664ba 100644
--- a/llvm/test/CodeGen/WebAssembly/cfi.ll
+++ b/llvm/test/CodeGen/WebAssembly/cfi.ll
@@ -14,13 +14,13 @@
}
; CHECK-LABEL: f:
-; CHECK: .indidx 0
+; CHECK: .indidx 1
define void @f() !type !0 {
ret void
}
; CHECK-LABEL: g:
-; CHECK: .indidx 1
+; CHECK: .indidx 2
define void @g() !type !1 {
ret void
}
diff --git a/llvm/test/Transforms/LowerTypeTests/function-disjoint.ll b/llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
index ebf8dcb..a5455a9 100644
--- a/llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
+++ b/llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
@@ -32,14 +32,14 @@
define i1 @foo(i8* %p) {
; X64: icmp eq i64 {{.*}}, ptrtoint ([1 x <{ i8, i32, i8, i8, i8 }>]* @[[JT0]] to i64)
- ; WASM32: icmp eq i64 {{.*}}, 0
+ ; WASM32: icmp eq i64 {{.*}}, 1
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
; X64: icmp eq i64 {{.*}}, ptrtoint ([1 x <{ i8, i32, i8, i8, i8 }>]* @[[JT1]] to i64)
- ; WASM32: icmp eq i64 {{.*}}, 1
+ ; WASM32: icmp eq i64 {{.*}}, 2
%y = call i1 @llvm.type.test(i8* %p, metadata !"typeid2")
%z = add i1 %x, %y
ret i1 %z
}
-; WASM32: ![[I0]] = !{i64 0}
-; WASM32: ![[I1]] = !{i64 1}
+; WASM32: ![[I0]] = !{i64 1}
+; WASM32: ![[I1]] = !{i64 2}
diff --git a/llvm/test/Transforms/LowerTypeTests/function-ext.ll b/llvm/test/Transforms/LowerTypeTests/function-ext.ll
index ba4c41f..2e9ab9d 100644
--- a/llvm/test/Transforms/LowerTypeTests/function-ext.ll
+++ b/llvm/test/Transforms/LowerTypeTests/function-ext.ll
@@ -22,3 +22,4 @@
!0 = !{i64 0, !"void"}
; WASM-NOT: !{i64 0}
+; WASM-NOT: !{i64 1}
diff --git a/llvm/test/Transforms/LowerTypeTests/function.ll b/llvm/test/Transforms/LowerTypeTests/function.ll
index 120bb9d..a9ef84a 100644
--- a/llvm/test/Transforms/LowerTypeTests/function.ll
+++ b/llvm/test/Transforms/LowerTypeTests/function.ll
@@ -30,11 +30,11 @@
define i1 @foo(i8* %p) {
; X64: sub i64 {{.*}}, ptrtoint ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64)
- ; WASM32: sub i64 {{.*}}, 0
+ ; WASM32: sub i64 {{.*}}, 1
; WASM32: icmp ult i64 {{.*}}, 2
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
ret i1 %x
}
-; WASM32: ![[I0]] = !{i64 0}
-; WASM32: ![[I1]] = !{i64 1}
+; WASM32: ![[I0]] = !{i64 1}
+; WASM32: ![[I1]] = !{i64 2}