[llvm] r278073 - [WebAssembly] Fix CFI index to account for padding nullptr function
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 16:56:02 PDT 2016
Author: dschuff
Date: Mon Aug 8 18:56:01 2016
New Revision: 278073
URL: http://llvm.org/viewvc/llvm-project?rev=278073&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/trunk/test/CodeGen/WebAssembly/cfi.ll
llvm/trunk/test/Transforms/LowerTypeTests/function-disjoint.ll
llvm/trunk/test/Transforms/LowerTypeTests/function-ext.ll
llvm/trunk/test/Transforms/LowerTypeTests/function.ll
Modified: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp?rev=278073&r1=278072&r2=278073&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp Mon Aug 8 18:56:01 2016
@@ -822,6 +822,7 @@ void LowerTypeTests::buildBitSetsFromFun
// Build consecutive monotonic integer ranges for each call target set
DenseMap<GlobalObject *, uint64_t> GlobalLayout;
+
for (Function *F : Functions) {
// Skip functions that are not address taken, to avoid bloating the table
if (!F->hasAddressTaken())
@@ -1049,7 +1050,7 @@ static void init(LowerTypeTests *LTT, Mo
LTT->Int64Ty = Type::getInt64Ty(M.getContext());
LTT->IntPtrTy = DL.getIntPtrType(M.getContext(), 0);
LTT->TypeTestCallSites.clear();
- LTT->IndirectIndex = 0;
+ LTT->IndirectIndex = 1;
}
bool LowerTypeTests::runOnModule(Module &M) {
Modified: llvm/trunk/test/CodeGen/WebAssembly/cfi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/cfi.ll?rev=278073&r1=278072&r2=278073&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/cfi.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/cfi.ll Mon Aug 8 18:56:01 2016
@@ -14,13 +14,13 @@ define void @h() !type !0 {
}
; 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
}
Modified: llvm/trunk/test/Transforms/LowerTypeTests/function-disjoint.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/function-disjoint.ll?rev=278073&r1=278072&r2=278073&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/function-disjoint.ll (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/function-disjoint.ll Mon Aug 8 18:56:01 2016
@@ -32,14 +32,14 @@ declare i1 @llvm.type.test(i8* %ptr, met
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}
Modified: llvm/trunk/test/Transforms/LowerTypeTests/function-ext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/function-ext.ll?rev=278073&r1=278072&r2=278073&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/function-ext.ll (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/function-ext.ll Mon Aug 8 18:56:01 2016
@@ -22,3 +22,4 @@ declare i1 @llvm.type.test(i8* %ptr, met
!0 = !{i64 0, !"void"}
; WASM-NOT: !{i64 0}
+; WASM-NOT: !{i64 1}
Modified: llvm/trunk/test/Transforms/LowerTypeTests/function.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/function.ll?rev=278073&r1=278072&r2=278073&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/function.ll (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/function.ll Mon Aug 8 18:56:01 2016
@@ -30,11 +30,11 @@ declare i1 @llvm.type.test(i8* %ptr, met
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}
More information about the llvm-commits
mailing list