1 ; RUN: llc < %s | FileCheck %s 2 ; RUN: llc -O3 < %s | FileCheck %s 3 ; RUN: llc -O3 -debug-only=stackmaps < %s 2>&1 | FileCheck -check-prefix=STACKMAPS %s 4 ; REQUIRES: asserts 5 6 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 7 target triple = "x86_64-apple-macosx10.11.0" 8 9 10 ; STACKMAPS: Stack Maps: callsite 2882400015 11 ; STACKMAPS-NEXT: Stack Maps: has 4 locations 12 ; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 13 ; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 14 ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 15 ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 16 ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers 17 ; STACKMAPS-NEXT: Stack Maps: callsite 4242 18 ; STACKMAPS-NEXT: Stack Maps: has 4 locations 19 ; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 20 ; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 21 ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 22 ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 23 ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers 24 ; STACKMAPS-NEXT: Stack Maps: callsite 4243 25 ; STACKMAPS-NEXT: Stack Maps: has 4 locations 26 ; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 27 ; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 28 ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 29 ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 16 [encoding: .byte 4, .byte 8, .short 0, .int 16] 30 ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers 31 ; STACKMAPS-NEXT: Stack Maps: callsite 2882400015 32 ; STACKMAPS-NEXT: Stack Maps: has 4 locations 33 ; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 34 ; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 35 ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 36 ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 2 [encoding: .byte 4, .byte 8, .short 0, .int 2] 37 ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers 38 ; STACKMAPS-NEXT: Stack Maps: callsite 2882400015 39 ; STACKMAPS-NEXT: Stack Maps: has 4 locations 40 ; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 41 ; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 42 ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 43 ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 3 [encoding: .byte 4, .byte 8, .short 0, .int 3] 44 ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers 45 ; STACKMAPS-NEXT: Stack Maps: callsite 4243 46 ; STACKMAPS-NEXT: Stack Maps: has 4 locations 47 ; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 48 ; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] 49 ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] 50 ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 55 [encoding: .byte 4, .byte 8, .short 0, .int 55] 51 ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers 52 53 54 declare i32 @callee_0() 55 declare i32 @callee_1(i32) 56 declare i32 @callee_vararg(...) 57 58 define i32 @caller_0() { 59 ; CHECK-LABEL: _caller_0 60 entry: 61 %v = call i32 @callee_0() [ "deopt"(i32 0) ] 62 %v2 = add i32 %v, 1 63 ret i32 %v2 64 ; CHECK: callq _callee_0 65 ; CHECK: incl %eax 66 ; CHECK: retq 67 } 68 69 define i32 @caller_1() { 70 ; CHECK-LABEL: _caller_1 71 entry: 72 %v = call i32 @callee_1(i32 42) "statepoint-id"="4242" [ "deopt"(i32 1) ] 73 ret i32 %v 74 ; CHECK: callq _callee_1 75 ; CHECK: popq %rcx 76 ; CHECK: retq 77 } 78 79 define i32 @caller_vararg() { 80 ; CHECK-LABEL: _caller_vararg 81 entry: 82 ; CHECK: movb $1, %al 83 ; CHECK: callq _callee_vararg 84 %v = call i32(...) @callee_vararg(i32 42, double 500.0) "statepoint-id"="4243" [ "deopt"(i32 16) ] 85 ret i32 %v 86 } 87 88 define i32 @invoker_0() personality i8 0 { 89 ; CHECK-LABEL: _invoker_0 90 entry: 91 %v = invoke i32 @callee_0() [ "deopt"(i32 2) ] 92 to label %normal unwind label %uw 93 94 normal: 95 ret i32 %v 96 97 uw: 98 %ehvals = landingpad { i8*, i32 } 99 cleanup 100 ret i32 1 101 ; CHECK: callq _callee_0 102 ; CHECK: popq %rcx 103 ; CHECK: retq 104 ; CHECK: movl $1, %eax 105 ; CHECK: popq %rcx 106 ; CHECK: retq 107 } 108 109 define i32 @invoker_1() personality i8 0 { 110 ; CHECK-LABEL: _invoker_1 111 entry: 112 %v = invoke i32 @callee_1(i32 45) "statepoint-num-patch-bytes"="9" [ "deopt"(i32 3) ] 113 to label %normal unwind label %uw 114 115 normal: 116 ret i32 %v 117 118 uw: 119 %ehvals = landingpad { i8*, i32 } 120 cleanup 121 ret i32 1 122 ; CHECK: movl $45, %edi 123 ; CHECK: nopw 512(%rax,%rax) 124 ; CHECK: popq %rcx 125 ; CHECK: retq 126 ; CHECK: movl $1, %eax 127 ; CHECK: popq %rcx 128 ; CHECK: retq 129 } 130 131 define i32 @invoker_2() personality i32 (...)* @__CxxFrameHandler3 { 132 entry: 133 %val = invoke i32 @callee_1(i32 1) 134 to label %try.cont unwind label %catch.dispatch 135 136 catch.dispatch: 137 %cs1 = catchswitch within none [label %catch] unwind to caller 138 139 catch: 140 %cp1 = catchpad within %cs1 [i8* null, i32 64, i8* null] 141 %val2 = call i32 @callee_1(i32 100) "statepoint-id"="4243" [ "funclet"(token %cp1), "deopt"(i32 55) ] 142 catchret from %cp1 to label %try.cont 143 144 try.cont: 145 ret i32 0 146 } 147 148 declare i32 @__CxxFrameHandler3(...) 149 150 define void @f_0(i64 %n) { 151 ; CHECK-LABEL: _f_0 152 %s = alloca i64 153 %vl = alloca i64, i64 %n 154 ; Check that the stackmap does not reference %s through 155 ; SP since the offset is not static because of %vl. 156 ; STACKMAPS: Loc 3: Direct 6 157 call void @g_0(i64* %vl) [ "deopt"(i64* %s) ] 158 ret void 159 } 160 161 declare void @g_0(i64* %vl) 162