1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s --check-prefix=X86
; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s --check-prefix=X64
; Based on this source:
; extern "C" void may_throw(int);
; void f() {
; try {
; may_throw(1);
; try {
; may_throw(2);
; } catch (int) {
; may_throw(3);
; }
; } catch (int) {
; may_throw(4);
; }
; }
%rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] }
%eh.CatchHandlerType = type { i32, ptr }
declare void @may_throw(i32)
declare i32 @__CxxFrameHandler3(...)
declare i32 @llvm.eh.typeid.for(ptr)
$"\01??_R0H@8" = comdat any
@"\01??_7type_info@@6B@" = external constant ptr
@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"\01??_7type_info@@6B@", ptr null, [3 x i8] c".H\00" }, comdat
@llvm.eh.handlertype.H.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, ptr @"\01??_R0H@8" }, section "llvm.metadata"
define void @f() #0 personality ptr @__CxxFrameHandler3 {
entry:
invoke void @may_throw(i32 1)
to label %invoke.cont unwind label %lpad.1
invoke.cont: ; preds = %entry
invoke void @may_throw(i32 2)
to label %try.cont.9 unwind label %lpad
try.cont.9: ; preds = %invoke.cont.3, %invoke.cont, %catch.7
ret void
lpad: ; preds = %catch, %entry
%cs1 = catchswitch within none [label %catch] unwind label %lpad.1
catch: ; preds = %lpad.1
%p1 = catchpad within %cs1 [ptr @"\01??_R0H@8", i32 0, ptr null]
invoke void @may_throw(i32 3) [ "funclet"(token %p1) ]
to label %invoke.cont.3 unwind label %lpad.1
invoke.cont.3: ; preds = %catch
catchret from %p1 to label %try.cont.9
lpad.1: ; preds = %invoke.cont
%cs2 = catchswitch within none [label %catch.7] unwind to caller
catch.7:
%p2 = catchpad within %cs2 [ptr @"\01??_R0H@8", i32 0, ptr null]
call void @may_throw(i32 4) [ "funclet"(token %p2) ]
catchret from %p2 to label %try.cont.9
}
; X86-LABEL: _f:
; X86: movl $-1, [[state:[-0-9]+]](%ebp)
; X86: movl $___ehhandler$f, {{.*}}
;
; X86: movl $0, [[state]](%ebp)
; X86: pushl $1
; X86: calll _may_throw
;
; X86: movl $1, [[state]](%ebp)
; X86: pushl $2
; X86: calll _may_throw
;
; X86: movl $2, [[state]](%ebp)
; X86: pushl $3
; X86: calll _may_throw
;
; X86: movl $3, [[state]](%ebp)
; X86: pushl $4
; X86: calll _may_throw
; X64-LABEL: f:
; X64-LABEL: $ip2state$f:
; X64-NEXT: .long .Lfunc_begin0@IMGREL
; X64-NEXT: .long -1
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long 0
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long 1
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long -1
; X64-NEXT: .long "?catch${{.*}}@?0?f@4HA"@IMGREL
; X64-NEXT: .long 2
; X64-NEXT: .long "?catch${{.*}}@?0?f@4HA"@IMGREL
; X64-NEXT: .long 3
; Based on this source:
; extern "C" void may_throw(int);
; struct S { ~S(); };
; void g() {
; S x;
; try {
; may_throw(-1);
; } catch (...) {
; may_throw(0);
; {
; S y;
; may_throw(1);
; }
; may_throw(2);
; }
; }
%struct.S = type { i8 }
declare void @"\01??1S@@QEAA@XZ"(ptr)
define void @g() personality ptr @__CxxFrameHandler3 {
entry:
%x = alloca %struct.S, align 1
%y = alloca %struct.S, align 1
invoke void @may_throw(i32 -1)
to label %unreachable unwind label %catch.dispatch
catch.dispatch: ; preds = %entry
%0 = catchswitch within none [label %catch] unwind label %ehcleanup5
catch: ; preds = %catch.dispatch
%1 = catchpad within %0 [ptr null, i32 64, ptr null]
invoke void @may_throw(i32 0) [ "funclet"(token %1) ]
to label %invoke.cont unwind label %ehcleanup5
invoke.cont: ; preds = %catch
invoke void @may_throw(i32 1) [ "funclet"(token %1) ]
to label %invoke.cont2 unwind label %ehcleanup
invoke.cont2: ; preds = %invoke.cont
invoke void @"\01??1S@@QEAA@XZ"(ptr nonnull %y) [ "funclet"(token %1) ]
to label %invoke.cont3 unwind label %ehcleanup5
invoke.cont3: ; preds = %invoke.cont2
invoke void @may_throw(i32 2) [ "funclet"(token %1) ]
to label %invoke.cont4 unwind label %ehcleanup5
invoke.cont4: ; preds = %invoke.cont3
catchret from %1 to label %try.cont
try.cont: ; preds = %invoke.cont4
call void @"\01??1S@@QEAA@XZ"(ptr nonnull %x)
ret void
ehcleanup: ; preds = %invoke.cont
%2 = cleanuppad within %1 []
call void @"\01??1S@@QEAA@XZ"(ptr nonnull %y) [ "funclet"(token %2) ]
cleanupret from %2 unwind label %ehcleanup5
ehcleanup5: ; preds = %invoke.cont2, %invoke.cont3, %ehcleanup, %catch, %catch.dispatch
%3 = cleanuppad within none []
call void @"\01??1S@@QEAA@XZ"(ptr nonnull %x) [ "funclet"(token %3) ]
cleanupret from %3 unwind to caller
unreachable: ; preds = %entry
unreachable
}
; X86-LABEL: _g:
; X86: movl $-1, [[state:[-0-9]+]](%ebp)
; X86: movl $___ehhandler$g, {{.*}}
;
; X86: movl $1, [[state]](%ebp)
; X86: pushl $-1
; X86: calll _may_throw
;
; X86: movl $2, [[state]](%ebp)
; X86: pushl $0
; X86: calll _may_throw
;
; X86: movl $3, [[state]](%ebp)
; X86: pushl $1
; X86: calll _may_throw
;
; X86: movl $2, [[state]](%ebp)
; X86: pushl $2
; X86: calll _may_throw
; X64-LABEL: g:
; X64-LABEL: $ip2state$g:
; X64-NEXT: .long .Lfunc_begin1@IMGREL
; X64-NEXT: .long -1
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long 1
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long -1
; X64-NEXT: .long "?catch${{.*}}@?0?g@4HA"@IMGREL
; X64-NEXT: .long 2
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long 3
; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1
; X64-NEXT: .long 2
; X86: .safeseh ___ehhandler$f
; X86: .safeseh ___ehhandler$g
|