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 -pass-remarks-output=%t | FileCheck %s
4 ; RUN: cat %t | FileCheck %s --check-prefix=REMARKS
6 ; Repro cases from PR25168
8 ; test @catchret - catchret target is not address-taken until PEI
9 ; splits it into lea/mov followed by ret. Make sure the MBB is
10 ; handled, both by tempting BranchFolding to merge it with %early_out
11 ; and delete it, and by checking that we emit a proper reference
14 declare void @ProcessCLRException()
17 define void @catchret(i1 %b) personality void ()* @ProcessCLRException {
19 br i1 %b, label %body, label %early_out
24 to label %exit unwind label %catch.pad
26 %cs1 = catchswitch within none [label %catch.body] unwind to caller
28 %catch = catchpad within %cs1 [i32 33554467]
29 catchret from %catch to label %exit
33 ; CHECK-LABEL: catchret: # @catchret
34 ; CHECK: [[Exit:^[^ :]+]]: # Block address taken
36 ; CHECK: # %catch.body
37 ; CHECK: .seh_endprolog
38 ; CHECK: leaq [[Exit]](%rip), %rax
39 ; CHECK: retq # CATCHRET
41 ; REMARKS: Pass: shrink-wrap
42 ; REMARKS-NEXT: Name: UnsupportedEHFunclets
43 ; REMARKS-NEXT: Function: catchret
45 ; REMARKS-NEXT: - String: EH Funclets are not supported yet.
47 ; test @setjmp - similar to @catchret, but the MBB in question
48 ; is the one generated when the setjmp's block is split
50 @buf = internal global [5 x i8*] zeroinitializer
51 declare i8* @llvm.frameaddress(i32) nounwind readnone
52 declare i8* @llvm.stacksave() nounwind
53 declare i32 @llvm.eh.sjlj.setjmp(i8*) nounwind
54 declare void @llvm.eh.sjlj.longjmp(i8*) nounwind
56 define void @setjmp(i1 %b) nounwind {
58 br i1 %b, label %early_out, label %sj
62 %fp = call i8* @llvm.frameaddress(i32 0)
63 store i8* %fp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 0), align 16
64 %sp = call i8* @llvm.stacksave()
65 store i8* %sp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 2), align 16
66 call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
69 ; CHECK-LABEL: setjmp: # @setjmp
71 ; CHECK: leaq [[Label:\..+]](%rip), %[[Reg:.+]]{{$}}
72 ; CHECK-NEXT: movq %[[Reg]], buf
73 ; CHECK: {{^}}[[Label]]: # Block address taken