blob: a48f9b60feb474ba3817aafb9ceb8e0688b8b8a9 [file] [log] [blame]
Chandler Carruth5da53432012-07-02 18:37:59 +00001; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
Nuno Lopes2f492842012-06-28 22:57:00 +00002
3; PR1042
4define i32 @foo() {
5; CHECK: The unwind destination does not have a landingpad instruction
6 %A = invoke i32 @foo( )
7 to label %L unwind label %L ; <i32> [#uses=1]
8L: ; preds = %0, %0
9 ret i32 %A
10}
11
12; PR1042
13define i32 @bar() {
14 br i1 false, label %L1, label %L2
15L1: ; preds = %0
16 %A = invoke i32 @bar( )
17 to label %L unwind label %L ; <i32> [#uses=1]
18L2: ; preds = %0
19 br label %L
20L: ; preds = %L2, %L1, %L1
21; CHECK: The unwind destination does not have a landingpad instruction
22; CHECK: Instruction does not dominate all uses
23 ret i32 %A
24}
25
26
27declare i32 @__gxx_personality_v0(...)
28declare void @llvm.donothing()
29declare void @llvm.trap()
30declare i8 @llvm.expect.i8(i8,i8)
31declare i32 @fn(i8 (i8, i8)*)
32
33define void @f1() {
34entry:
35; OK
36 invoke void @llvm.donothing()
Eli Friedman4c923b32012-08-10 20:55:20 +000037 to label %conta unwind label %contb
Nuno Lopes2f492842012-06-28 22:57:00 +000038
Eli Friedman4c923b32012-08-10 20:55:20 +000039conta:
40 ret void
41
42contb:
Nuno Lopes2f492842012-06-28 22:57:00 +000043 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
44 filter [0 x i8*] zeroinitializer
45 ret void
46}
47
48define i8 @f2() {
49entry:
50; CHECK: Cannot invoke an intrinsinc other than donothing
51 invoke void @llvm.trap()
52 to label %cont unwind label %lpad
53
54cont:
55 ret i8 3
56
57lpad:
58 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
59 filter [0 x i8*] zeroinitializer
60 ret i8 2
61}
62
63define i32 @f3() {
64entry:
65; CHECK: Cannot take the address of an intrinsic
66 %call = call i32 @fn(i8 (i8, i8)* @llvm.expect.i8)
67 ret i32 %call
68}
Eli Friedman4c923b32012-08-10 20:55:20 +000069
70define void @f4() {
71entry:
72 invoke void @llvm.donothing()
73 to label %cont unwind label %cont
74
75cont:
76; CHECK: Block containing LandingPadInst must be jumped to only by the unwind edge of an invoke.
77 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
78 filter [0 x i8*] zeroinitializer
79 ret void
80}