• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5; Repro cases from PR25168
6
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
11; to it in the LEA
12
13declare void @ProcessCLRException()
14declare void @f()
15
16define void @catchret(i1 %b) personality void ()* @ProcessCLRException {
17entry:
18  br i1 %b, label %body, label %early_out
19early_out:
20  ret void
21body:
22  invoke void @f()
23          to label %exit unwind label %catch.pad
24catch.pad:
25  %cs1 = catchswitch within none [label %catch.body] unwind to caller
26catch.body:
27  %catch = catchpad within %cs1 [i32 33554467]
28  catchret from %catch to label %exit
29exit:
30  ret void
31}
32; CHECK-LABEL: catchret:  # @catchret
33; CHECK: [[Exit:^[^ :]+]]: # Block address taken
34; CHECK-NEXT:              # %exit
35; CHECK: # %catch.body
36; CHECK: .seh_endprolog
37; CHECK: leaq [[Exit]](%rip), %rax
38; CHECK: retq # CATCHRET
39
40
41; test @setjmp - similar to @catchret, but the MBB in question
42; is the one generated when the setjmp's block is split
43
44@buf = internal global [5 x i8*] zeroinitializer
45declare i8* @llvm.frameaddress(i32) nounwind readnone
46declare i8* @llvm.stacksave() nounwind
47declare i32 @llvm.eh.sjlj.setjmp(i8*) nounwind
48declare void @llvm.eh.sjlj.longjmp(i8*) nounwind
49
50define void @setjmp(i1 %b) nounwind {
51entry:
52  br i1 %b, label %early_out, label %sj
53early_out:
54  ret void
55sj:
56  %fp = call i8* @llvm.frameaddress(i32 0)
57  store i8* %fp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 0), align 16
58  %sp = call i8* @llvm.stacksave()
59  store i8* %sp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 2), align 16
60  call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
61  ret void
62}
63; CHECK-LABEL: setjmp: # @setjmp
64; CHECK: # %sj
65; CHECK: leaq [[Label:\..+]](%rip), %[[Reg:.+]]{{$}}
66; CHECK-NEXT: movq %[[Reg]], buf
67; CHECK: {{^}}[[Label]]:  # Block address taken
68; CHECK-NEXT:              # %sj
69