[SjLj Prepare] When demoting an invoke instructions to the stack, if the normal
[oota-llvm.git] / test / CodeGen / ARM / sjlj-prepare-critical-edge.ll
1 ; RUN: llc < %s -O1 -mtriple thumbv7-apple-ios6
2 ; Just make sure no one tries to make the assumption that the normal edge of an
3 ; invoke is never a critical edge.  Previously, this code would assert.
4
5 %struct.__CFString = type opaque
6
7 declare void @bar(%struct.__CFString*, %struct.__CFString*)
8
9 define noalias i8* @foo(i8* nocapture %inRefURL) noreturn ssp {
10 entry:
11   %call = tail call %struct.__CFString* @bar3()
12   %call2 = invoke i8* @bar2()
13           to label %for.cond unwind label %lpad
14
15 for.cond:                                         ; preds = %entry, %for.cond
16   invoke void @bar(%struct.__CFString* undef, %struct.__CFString* null)
17           to label %for.cond unwind label %lpad5
18
19 lpad:                                             ; preds = %entry
20   %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
21           cleanup
22   %1 = extractvalue { i8*, i32 } %0, 0
23   %2 = extractvalue { i8*, i32 } %0, 1
24   br label %ehcleanup
25
26 lpad5:                                            ; preds = %for.cond
27   %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
28           cleanup
29   %4 = extractvalue { i8*, i32 } %3, 0
30   %5 = extractvalue { i8*, i32 } %3, 1
31   invoke void @release(i8* %call2)
32           to label %ehcleanup unwind label %terminate.lpad.i.i16
33
34 terminate.lpad.i.i16:                             ; preds = %lpad5
35   %6 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
36           catch i8* null
37   tail call void @terminatev() noreturn nounwind
38   unreachable
39
40 ehcleanup:                                        ; preds = %lpad5, %lpad
41   %exn.slot.0 = phi i8* [ %1, %lpad ], [ %4, %lpad5 ]
42   %ehselector.slot.0 = phi i32 [ %2, %lpad ], [ %5, %lpad5 ]
43   %7 = bitcast %struct.__CFString* %call to i8*
44   invoke void @release(i8* %7)
45           to label %_ZN5SmartIPK10__CFStringED1Ev.exit unwind label %terminate.lpad.i.i
46
47 terminate.lpad.i.i:                               ; preds = %ehcleanup
48   %8 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
49           catch i8* null
50   tail call void @terminatev() noreturn nounwind
51   unreachable
52
53 _ZN5SmartIPK10__CFStringED1Ev.exit:               ; preds = %ehcleanup
54   %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0
55   %lpad.val12 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1
56   resume { i8*, i32 } %lpad.val12
57 }
58
59 declare %struct.__CFString* @bar3()
60
61 declare i8* @bar2()
62
63 declare i32 @__gxx_personality_sj0(...)
64
65 declare void @release(i8*)
66
67 declare void @terminatev()