xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/catchret-regmask.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-pc-windows-msvc"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...)
7*9880d681SAndroid Build Coastguard Workerdeclare void @throw() noreturn uwtable
8*9880d681SAndroid Build Coastguard Workerdeclare i8* @getval()
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine i8* @reload_out_of_pad(i8* %arg) #0 personality i32 (...)* @__CxxFrameHandler3 {
11*9880d681SAndroid Build Coastguard WorkerassertPassed:
12*9880d681SAndroid Build Coastguard Worker  invoke void @throw()
13*9880d681SAndroid Build Coastguard Worker          to label %unreachable unwind label %catch.dispatch
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workercatch:
16*9880d681SAndroid Build Coastguard Worker  %cp = catchpad within %cs [i8* null, i32 0, i8* null]
17*9880d681SAndroid Build Coastguard Worker  catchret from %cp to label %return
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker  ; This block *must* appear after the catchret to test the bug.
20*9880d681SAndroid Build Coastguard Worker  ; FIXME: Make this an MIR test so we can control MBB layout.
21*9880d681SAndroid Build Coastguard Workerunreachable:
22*9880d681SAndroid Build Coastguard Worker  unreachable
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workercatch.dispatch:
25*9880d681SAndroid Build Coastguard Worker  %cs = catchswitch within none [label %catch] unwind to caller
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerreturn:
28*9880d681SAndroid Build Coastguard Worker  ret i8* %arg
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: reload_out_of_pad: # @reload_out_of_pad
32*9880d681SAndroid Build Coastguard Worker; CHECK: movq %rcx, -[[arg_slot:[0-9]+]](%rbp) # 8-byte Spill
33*9880d681SAndroid Build Coastguard Worker; CHECK: callq throw
34*9880d681SAndroid Build Coastguard Worker; CHECK: ud2
35*9880d681SAndroid Build Coastguard Worker; CHECK: movq -[[arg_slot]](%rbp), %rax # 8-byte Reload
36*9880d681SAndroid Build Coastguard Worker; CHECK: retq
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker; CHECK: "?catch$3@?0?reload_out_of_pad@4HA":
39*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: Reload
40*9880d681SAndroid Build Coastguard Worker; CHECK: retq
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerdefine i8* @spill_in_pad() #0 personality i32 (...)* @__CxxFrameHandler3 {
43*9880d681SAndroid Build Coastguard WorkerassertPassed:
44*9880d681SAndroid Build Coastguard Worker  invoke void @throw()
45*9880d681SAndroid Build Coastguard Worker          to label %unreachable unwind label %catch.dispatch
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workercatch:
48*9880d681SAndroid Build Coastguard Worker  %cp = catchpad within %cs [i8* null, i32 0, i8* null]
49*9880d681SAndroid Build Coastguard Worker  %val = call i8* @getval() [ "funclet"(token %cp) ]
50*9880d681SAndroid Build Coastguard Worker  catchret from %cp to label %return
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerunreachable:
53*9880d681SAndroid Build Coastguard Worker  unreachable
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Workercatch.dispatch:
56*9880d681SAndroid Build Coastguard Worker  %cs = catchswitch within none [label %catch] unwind to caller
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerreturn:
59*9880d681SAndroid Build Coastguard Worker  ret i8* %val
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: spill_in_pad: # @spill_in_pad
63*9880d681SAndroid Build Coastguard Worker; CHECK: callq throw
64*9880d681SAndroid Build Coastguard Worker; CHECK: ud2
65*9880d681SAndroid Build Coastguard Worker; CHECK: movq -[[val_slot:[0-9]+]](%rbp), %rax # 8-byte Reload
66*9880d681SAndroid Build Coastguard Worker; CHECK: retq
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker; CHECK: "?catch$3@?0?spill_in_pad@4HA":
69*9880d681SAndroid Build Coastguard Worker; CHECK: callq getval
70*9880d681SAndroid Build Coastguard Worker; CHECK: movq %rax, -[[val_slot]](%rbp) # 8-byte Spill
71*9880d681SAndroid Build Coastguard Worker; CHECK: retq
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Workerattributes #0 = { uwtable }
74