llvm.org GIT mirror llvm / 917f97c
make the verifier accept @llvm.donothing as the only intrinsic that can be invoked While at it, merge 2 tests and FileCheckize them git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159388 91177308-0d34-0410-b5e6-96231b3b80d8 Nuno Lopes 8 years ago
4 changed file(s) with 69 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
16351635 if (Function *F = dyn_cast(I.getOperand(i))) {
16361636 // Check to make sure that the "address of" an intrinsic function is never
16371637 // taken.
1638 CallSite CS(&I);
1639 Assert1(!F->isIntrinsic() || (CS && i == (CS.isCall() ? e-1 : 2)),
1638 Assert1(!F->isIntrinsic() || i == (isa(I) ? e-1 : 0),
16401639 "Cannot take the address of an intrinsic!", &I);
1640 Assert1(!F->isIntrinsic() || isa(I) ||
1641 F->getIntrinsicID() == Intrinsic::donothing,
1642 "Cannot invoke an intrinsinc other than donothing", &I);
16411643 Assert1(F->getParent() == Mod, "Referencing function in another module!",
16421644 &I);
16431645 } else if (BasicBlock *OpBB = dyn_cast(I.getOperand(i))) {
+0
-10
test/Verifier/invoke-1.ll less more
None ; RUN: not llvm-as < %s |& grep {not verify as correct}
1 ; PR1042
2
3 define i32 @foo() {
4 %A = invoke i32 @foo( )
5 to label %L unwind label %L ; [#uses=1]
6 L: ; preds = %0, %0
7 ret i32 %A
8 }
9
+0
-14
test/Verifier/invoke-2.ll less more
None ; RUN: not llvm-as %s |& grep {not verify as correct}
1 ; PR1042
2
3 define i32 @foo() {
4 br i1 false, label %L1, label %L2
5 L1: ; preds = %0
6 %A = invoke i32 @foo( )
7 to label %L unwind label %L ; [#uses=1]
8 L2: ; preds = %0
9 br label %L
10 L: ; preds = %L2, %L1, %L1
11 ret i32 %A
12 }
13
0 ; RUN: not llvm-as < %s -o /dev/null |& FileCheck %s
1
2 ; PR1042
3 define i32 @foo() {
4 ; CHECK: The unwind destination does not have a landingpad instruction
5 %A = invoke i32 @foo( )
6 to label %L unwind label %L ; [#uses=1]
7 L: ; preds = %0, %0
8 ret i32 %A
9 }
10
11 ; PR1042
12 define i32 @bar() {
13 br i1 false, label %L1, label %L2
14 L1: ; preds = %0
15 %A = invoke i32 @bar( )
16 to label %L unwind label %L ; [#uses=1]
17 L2: ; preds = %0
18 br label %L
19 L: ; preds = %L2, %L1, %L1
20 ; CHECK: The unwind destination does not have a landingpad instruction
21 ; CHECK: Instruction does not dominate all uses
22 ret i32 %A
23 }
24
25
26 declare i32 @__gxx_personality_v0(...)
27 declare void @llvm.donothing()
28 declare void @llvm.trap()
29 declare i8 @llvm.expect.i8(i8,i8)
30 declare i32 @fn(i8 (i8, i8)*)
31
32 define void @f1() {
33 entry:
34 ; OK
35 invoke void @llvm.donothing()
36 to label %cont unwind label %cont
37
38 cont:
39 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
40 filter [0 x i8*] zeroinitializer
41 ret void
42 }
43
44 define i8 @f2() {
45 entry:
46 ; CHECK: Cannot invoke an intrinsinc other than donothing
47 invoke void @llvm.trap()
48 to label %cont unwind label %lpad
49
50 cont:
51 ret i8 3
52
53 lpad:
54 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
55 filter [0 x i8*] zeroinitializer
56 ret i8 2
57 }
58
59 define i32 @f3() {
60 entry:
61 ; CHECK: Cannot take the address of an intrinsic
62 %call = call i32 @fn(i8 (i8, i8)* @llvm.expect.i8)
63 ret i32 %call
64 }