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