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