1 ; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -enable-shrink-wrap=false | FileCheck %s
2 ; Make sure shrink-wrapping does not break the lowering of exception handling.
3 ; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -enable-shrink-wrap=true | FileCheck %s
5 ; Repro cases from PR25168
7 ; test @catchret - catchret target is not address-taken until PEI
8 ; splits it into lea/mov followed by ret. Make sure the MBB is
9 ; handled, both by tempting BranchFolding to merge it with %early_out
10 ; and delete it, and by checking that we emit a proper reference
13 declare void @ProcessCLRException()
16 define void @catchret(i1 %b) personality void ()* @ProcessCLRException {
18 br i1 %b, label %body, label %early_out
23 to label %exit unwind label %catch.pad
25 %catch = catchpad [i32 33554467]
26 to label %catch.body unwind label %catch.end
28 catchret %catch to label %exit
30 catchendpad unwind to caller
34 ; CHECK-LABEL: catchret: # @catchret
35 ; CHECK: [[Exit:^[^ :]+]]: # Block address taken
38 ; CHECK: .seh_endprolog
39 ; CHECK: leaq [[Exit]](%rip), %rax
40 ; CHECK: retq # CATCHRET
43 ; test @setjmp - similar to @catchret, but the MBB in question
44 ; is the one generated when the setjmp's block is split
46 @buf = internal global [5 x i8*] zeroinitializer
47 declare i8* @llvm.frameaddress(i32) nounwind readnone
48 declare i8* @llvm.stacksave() nounwind
49 declare i32 @llvm.eh.sjlj.setjmp(i8*) nounwind
50 declare void @llvm.eh.sjlj.longjmp(i8*) nounwind
52 define void @setjmp(i1 %b) nounwind {
54 br i1 %b, label %early_out, label %sj
58 %fp = call i8* @llvm.frameaddress(i32 0)
59 store i8* %fp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 0), align 16
60 %sp = call i8* @llvm.stacksave()
61 store i8* %sp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 2), align 16
62 call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
65 ; CHECK-LABEL: setjmp: # @setjmp
67 ; CHECK: leaq [[Label:\..+]](%rip), %[[Reg:.+]]{{$}}
68 ; CHECK-NEXT: movq %[[Reg]], buf
69 ; CHECK: {{^}}[[Label]]: # Block address taken