Skip to content

Commit

Permalink
Revert rL291205 because it breaks Chrome tests under CFI.
Browse files Browse the repository at this point in the history
Summary:
Revert LowerTypeTests: Split the pass in two: a resolution phase and a lowering phase.

This change separates how type identifiers are resolved from how intrinsic
calls are lowered. All information required to lower an intrinsic call
is stored in a new TypeIdLowering data structure. The idea is that this
data structure can either be initialized using the module itself during
regular LTO, or using the module summary in ThinLTO backends.

Original URL: https://reviews.llvm.org/D28341

Reviewers: pcc

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D28532

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291684 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Ivan Krasin committed Jan 11, 2017
1 parent bc6b23e commit 52a39de
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 164 deletions.
4 changes: 4 additions & 0 deletions include/llvm/Transforms/IPO/LowerTypeTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ struct BitSetInfo {

bool containsGlobalOffset(uint64_t Offset) const;

bool containsValue(const DataLayout &DL,
const DenseMap<GlobalObject *, uint64_t> &GlobalLayout,
Value *V, uint64_t COffset = 0) const;

void print(raw_ostream &OS) const;
};

Expand Down
265 changes: 110 additions & 155 deletions lib/Transforms/IPO/LowerTypeTests.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/Transforms/LowerTypeTests/function-disjoint.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone

define i1 @foo(i8* %p) {
; X64: icmp eq i64 {{.*}}, ptrtoint (void ()* @[[JT0]] to i64)
; WASM32: icmp eq i64 {{.*}}, ptrtoint (i8* getelementptr (i8, i8* null, i64 1) to i64)
; WASM32: icmp eq i64 {{.*}}, 1
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
; X64: icmp eq i64 {{.*}}, ptrtoint (void ()* @[[JT1]] to i64)
; WASM32: icmp eq i64 {{.*}}, mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64), i64 2)
; WASM32: icmp eq i64 {{.*}}, 2
%y = call i1 @llvm.type.test(i8* %p, metadata !"typeid2")
%z = add i1 %x, %y
ret i1 %z
Expand All @@ -46,4 +46,4 @@ define i1 @foo(i8* %p) {
; X64: call void asm sideeffect "jmp ${0:c}@plt\0Aint3\0Aint3\0Aint3\0A", "s"(void ()* @g.cfi)

; WASM32: ![[I0]] = !{i64 1}
; WASM32: ![[I1]] = !{i64 2}
; WASM32: ![[I1]] = !{i64 2}
3 changes: 2 additions & 1 deletion test/Transforms/LowerTypeTests/function-ext.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ declare !type !0 void @foo()

define i1 @bar(i8* %ptr) {
; X64: icmp eq i64 {{.*}}, ptrtoint (void ()* @[[JT:.*]] to i64)
; WASM32: ret i1 false
; WASM32: sub i64 {{.*}}, 0
; WASM32: icmp ult i64 {{.*}}, 1
%p = call i1 @llvm.type.test(i8* %ptr, metadata !"void")
ret i1 %p
}
Expand Down
2 changes: 1 addition & 1 deletion test/Transforms/LowerTypeTests/function.ll
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone

define i1 @foo(i8* %p) {
; NATIVE: sub i64 {{.*}}, ptrtoint (void ()* @[[JT]] to i64)
; WASM32: sub i64 {{.*}}, ptrtoint (i8* getelementptr (i8, i8* null, i64 1) to i64)
; WASM32: sub i64 {{.*}}, 1
; WASM32: icmp ult i64 {{.*}}, 2
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
ret i1 %x
Expand Down
3 changes: 2 additions & 1 deletion test/Transforms/LowerTypeTests/import-unsat.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; Test that we correctly import an unsat resolution for type identifier "typeid1".
; RUN: opt -S -lowertypetests -lowertypetests-summary-action=import -lowertypetests-read-summary=%S/Inputs/import-unsat.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s
; FIXME: We should not require -O2 to simplify this to return false.
; RUN: opt -S -lowertypetests -lowertypetests-summary-action=import -lowertypetests-read-summary=%S/Inputs/import-unsat.yaml -lowertypetests-write-summary=%t -O2 < %s | FileCheck %s
; RUN: FileCheck --check-prefix=SUMMARY %s < %t

; SUMMARY: GlobalValueMap:
Expand Down
2 changes: 1 addition & 1 deletion test/Transforms/LowerTypeTests/simple.ll
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ define i1 @bar(i32* %p) {
; CHECK: [[S0:%[^ ]*]] = bitcast i32* [[B0]] to i8*
%pi8 = bitcast i32* %p to i8*
; CHECK: [[S1:%[^ ]*]] = ptrtoint i8* [[S0]] to i32
; CHECK: [[S2:%[^ ]*]] = sub i32 [[S1]], ptrtoint (i8* getelementptr (i8, i8* bitcast ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]] to i8*), i32 4) to i32)
; CHECK: [[S2:%[^ ]*]] = sub i32 [[S1]], add (i32 ptrtoint ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]] to i32), i32 4)
; CHECK: [[S3:%[^ ]*]] = lshr i32 [[S2]], 8
; CHECK: [[S4:%[^ ]*]] = shl i32 [[S2]], 24
; CHECK: [[S5:%[^ ]*]] = or i32 [[S3]], [[S4]]
Expand Down
2 changes: 1 addition & 1 deletion test/Transforms/LowerTypeTests/single-offset.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define i1 @foo(i8* %p) {
; CHECK: @bar(i8* [[B0:%[^ ]*]])
define i1 @bar(i8* %p) {
; CHECK: [[S0:%[^ ]*]] = ptrtoint i8* [[B0]] to i32
; CHECK: [[S1:%[^ ]*]] = icmp eq i32 [[S0]], ptrtoint (i8* getelementptr (i8, i8* bitcast ({ i32, [0 x i8], i32 }* [[G]] to i8*), i32 4) to i32)
; CHECK: [[S1:%[^ ]*]] = icmp eq i32 [[S0]], add (i32 ptrtoint ({ i32, [0 x i8], i32 }* [[G]] to i32), i32 4)
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid3")
; CHECK: ret i1 [[S1]]
ret i1 %x
Expand Down
3 changes: 2 additions & 1 deletion test/Transforms/LowerTypeTests/unsat.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -S -lowertypetests < %s | FileCheck %s
; FIXME: We should not require -O2 to simplify this to return false.
; RUN: opt -S -lowertypetests -O2 < %s | FileCheck %s

target datalayout = "e-p:32:32"

Expand Down

0 comments on commit 52a39de

Please sign in to comment.