1; RUN: llc -stack-symbol-ordering=0 -mtriple=i686-windows-msvc < %s | FileCheck %s 2 3; 32-bit catch-all has to use a filter function because that's how it saves the 4; exception code. 5 6@str = linkonce_odr unnamed_addr constant [27 x i8] c"GetExceptionCode(): 0x%lx\0A\00", align 1 7 8declare i32 @_except_handler3(...) 9declare void @crash() 10declare i32 @printf(ptr nocapture readonly, ...) nounwind 11declare i32 @llvm.eh.typeid.for(ptr) 12declare ptr @llvm.frameaddress(i32) 13declare ptr @llvm.localrecover(ptr, ptr, i32) 14declare void @llvm.localescape(...) 15declare ptr @llvm.eh.recoverfp(ptr, ptr) 16 17define i32 @main() personality ptr @_except_handler3 { 18entry: 19 ; The EH code allocation is overaligned, triggering realignment. 20 %__exceptioncode = alloca i32, align 8 21 call void (...) @llvm.localescape(ptr %__exceptioncode) 22 invoke void @crash() #5 23 to label %__try.cont unwind label %lpad 24 25lpad: ; preds = %entry 26 %cs1 = catchswitch within none [label %__except] unwind to caller 27 28__except: ; preds = %lpad 29 %p = catchpad within %cs1 [ptr @"filt$main"] 30 %code = load i32, ptr %__exceptioncode, align 4 31 %call = call i32 (ptr, ...) @printf(ptr @str, i32 %code) #4 [ "funclet"(token %p) ] 32 catchret from %p to label %__try.cont 33 34__try.cont: ; preds = %entry, %__except 35 ret i32 0 36} 37 38define internal i32 @"filt$main"() { 39entry: 40 %ebp = tail call ptr @llvm.frameaddress(i32 1) 41 %parentfp = tail call ptr @llvm.eh.recoverfp(ptr @main, ptr %ebp) 42 %code.i8 = tail call ptr @llvm.localrecover(ptr @main, ptr %parentfp, i32 0) 43 %info.addr = getelementptr inbounds i8, ptr %ebp, i32 -20 44 %0 = load ptr, ptr %info.addr, align 4 45 %1 = load ptr, ptr %0, align 4 46 %2 = load i32, ptr %1, align 4 47 store i32 %2, ptr %code.i8, align 4 48 ret i32 1 49} 50 51; Check that we can get the exception code from eax to the printf. 52 53; CHECK-LABEL: _main: 54; CHECK: .set Lmain$frame_escape_0, [[code_offs:[-0-9]+]] 55; CHECK: movl %esp, [[reg_offs:[-0-9]+]](%esi) 56; CHECK: movl $L__ehtable$main, 57; EH state 0 58; CHECK: movl $0, 32(%esi) 59; CHECK: calll _crash 60; CHECK: retl 61; CHECK: LBB0_[[lpbb:[0-9]+]]: # %__except 62; Restore ESP 63; CHECK: movl -24(%ebp), %esp 64; Restore ESI 65; CHECK: leal -36(%ebp), %esi 66; Restore EBP 67; CHECK: movl 4(%esi), %ebp 68; CHECK: movl [[code_offs]](%esi), %[[code:[a-z]+]] 69; CHECK: pushl %[[code]] 70; CHECK: pushl $_str 71; CHECK: calll _printf 72 73; CHECK: .section .xdata,"dr" 74; CHECK: .set Lmain$parent_frame_offset, [[reg_offs]] 75; CHECK: L__ehtable$main 76; CHECK-NEXT: .long -1 77; CHECK-NEXT: .long _filt$main 78; CHECK-NEXT: .long LBB0_[[lpbb]] 79 80; CHECK-LABEL: _filt$main: 81; CHECK: pushl %ebp 82; CHECK: movl %esp, %ebp 83; CHECK: movl (%ebp), %[[oldebp:[a-z]+]] 84; CHECK: movl -20(%[[oldebp]]), %[[ehinfo:[a-z]+]] 85; CHECK: movl (%[[ehinfo]]), %[[ehrec:[a-z]+]] 86; CHECK: movl (%[[ehrec]]), %[[ehcode:[a-z]+]] 87; CHECK: movl %[[ehcode]], {{.*}}(%{{.*}}) 88