Fix PR4865. This syncs up the JIT's DWARF emitter with what's in the
[oota-llvm.git] / test / ExecutionEngine / jit-eh-x86-64.ll
1 ; RUN: llvm-as %s -o %t.bc
2 ; RUN: lli -march=x86-64 %t.bc > /dev/null
3 ; PR4865
4
5 %struct.__fundamental_type_info_pseudo = type { %struct.__type_info_pseudo }
6 %struct.__type_info_pseudo = type { i8*, i8* }
7
8 @_ZTIi = external constant %struct.__fundamental_type_info_pseudo ; <%struct.__fundamental_type_info_pseudo*> [#uses=1]
9 @.str = private constant [3 x i8] c"ok\00", align 1 ; <[3 x i8]*> [#uses=1]
10
11 define i32 @main() ssp {
12 entry:
13   %retval = alloca i32                            ; <i32*> [#uses=2]
14   %save_filt.5 = alloca i32                       ; <i32*> [#uses=2]
15   %save_eptr.4 = alloca i8*                       ; <i8**> [#uses=2]
16   %0 = alloca i32                                 ; <i32*> [#uses=2]
17   %eh_exception = alloca i8*                      ; <i8**> [#uses=10]
18   %eh_selector = alloca i32                       ; <i32*> [#uses=5]
19   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
20   invoke void @_ZL3foov() ssp
21           to label %invcont unwind label %lpad
22
23 invcont:                                          ; preds = %entry
24   br label %bb6
25
26 bb:                                               ; preds = %ppad
27   %eh_value = load i8** %eh_exception             ; <i8*> [#uses=1]
28   %1 = call i8* @__cxa_begin_catch(i8* %eh_value) nounwind ; <i8*> [#uses=0]
29   %2 = invoke i32 @puts(i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0))
30           to label %invcont1 unwind label %lpad10 ; <i32> [#uses=0]
31
32 invcont1:                                         ; preds = %bb
33   call void @__cxa_end_catch()
34   br label %bb6
35
36 bb2:                                              ; preds = %ppad18
37   %eh_select = load i32* %eh_selector             ; <i32> [#uses=1]
38   store i32 %eh_select, i32* %save_filt.5, align 4
39   %eh_value3 = load i8** %eh_exception            ; <i8*> [#uses=1]
40   store i8* %eh_value3, i8** %save_eptr.4, align 4
41   invoke void @__cxa_end_catch()
42           to label %invcont4 unwind label %lpad14
43
44 invcont4:                                         ; preds = %bb2
45   %3 = load i8** %save_eptr.4, align 4            ; <i8*> [#uses=1]
46   store i8* %3, i8** %eh_exception, align 4
47   %4 = load i32* %save_filt.5, align 4            ; <i32> [#uses=1]
48   store i32 %4, i32* %eh_selector, align 4
49   br label %Unwind
50
51 bb5:                                              ; preds = %ppad19
52   call void @_ZSt9terminatev() noreturn nounwind
53   unreachable
54
55 bb6:                                              ; preds = %invcont1, %invcont
56   store i32 0, i32* %0, align 4
57   %5 = load i32* %0, align 4                      ; <i32> [#uses=1]
58   store i32 %5, i32* %retval, align 4
59   br label %return
60
61 return:                                           ; preds = %bb6
62   %retval7 = load i32* %retval                    ; <i32> [#uses=1]
63   ret i32 %retval7
64
65 lpad:                                             ; preds = %entry
66   %eh_ptr = call i8* @llvm.eh.exception()         ; <i8*> [#uses=1]
67   store i8* %eh_ptr, i8** %eh_exception
68   %eh_ptr8 = load i8** %eh_exception              ; <i8*> [#uses=1]
69   %eh_select9 = call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32(i8* %eh_ptr8, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ; <i32> [#uses=1]
70   store i32 %eh_select9, i32* %eh_selector
71   br label %ppad
72
73 lpad10:                                           ; preds = %bb
74   %eh_ptr11 = call i8* @llvm.eh.exception()       ; <i8*> [#uses=1]
75   store i8* %eh_ptr11, i8** %eh_exception
76   %eh_ptr12 = load i8** %eh_exception             ; <i8*> [#uses=1]
77   %eh_select13 = call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32(i8* %eh_ptr12, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ; <i32> [#uses=1]
78   store i32 %eh_select13, i32* %eh_selector
79   br label %ppad18
80
81 lpad14:                                           ; preds = %bb2
82   %eh_ptr15 = call i8* @llvm.eh.exception()       ; <i8*> [#uses=1]
83   store i8* %eh_ptr15, i8** %eh_exception
84   %eh_ptr16 = load i8** %eh_exception             ; <i8*> [#uses=1]
85   %eh_select17 = call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32(i8* %eh_ptr16, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i32 1) ; <i32> [#uses=1]
86   store i32 %eh_select17, i32* %eh_selector
87   br label %ppad19
88
89 ppad:                                             ; preds = %lpad
90   br label %bb
91
92 ppad18:                                           ; preds = %lpad10
93   br label %bb2
94
95 ppad19:                                           ; preds = %lpad14
96   br label %bb5
97
98 Unwind:                                           ; preds = %invcont4
99   %eh_ptr20 = load i8** %eh_exception             ; <i8*> [#uses=1]
100   call void @_Unwind_Resume_or_Rethrow(i8* %eh_ptr20)
101   unreachable
102 }
103
104 define internal void @_ZL3foov() ssp {
105 entry:
106   %0 = alloca i8*                                 ; <i8**> [#uses=3]
107   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
108   %1 = call i8* @__cxa_allocate_exception(i32 4) nounwind ; <i8*> [#uses=1]
109   store i8* %1, i8** %0, align 4
110   %2 = load i8** %0, align 4                      ; <i8*> [#uses=1]
111   %3 = bitcast i8* %2 to i32*                     ; <i32*> [#uses=1]
112   store i32 42, i32* %3, align 4
113   %4 = load i8** %0, align 4                      ; <i8*> [#uses=1]
114   call void @__cxa_throw(i8* %4, i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIi to i8*), void (i8*)* null) noreturn
115   unreachable
116
117 return:                                           ; No predecessors!
118   ret void
119 }
120
121 declare i8* @__cxa_allocate_exception(i32) nounwind
122
123 declare void @__cxa_throw(i8*, i8*, void (i8*)*) noreturn
124
125 declare i8* @__cxa_begin_catch(i8*) nounwind
126
127 declare i8* @llvm.eh.exception() nounwind
128
129 declare i32 @llvm.eh.selector.i32(i8*, i8*, ...) nounwind
130
131 declare i32 @llvm.eh.typeid.for.i32(i8*) nounwind
132
133 declare i32 @puts(i8*)
134
135 declare void @__cxa_end_catch()
136
137 declare void @_ZSt9terminatev() noreturn nounwind
138
139 declare i32 @__gxx_personality_v0(...)
140
141 declare void @_Unwind_Resume_or_Rethrow(i8*)