1; RUN: llc -mtriple=arm64-apple-darwin -mattr=+reserve-x18 < %s | FileCheck %s 2; RUN: llc -mtriple=arm64-apple-darwin -mattr=+reserve-x18 -fast-isel -fast-isel-abort=1 < %s | FileCheck %s 3; 4; Note: Print verbose stackmaps using -debug-only=stackmaps. 5 6; We are not getting the correct stack alignment when cross compiling for arm64. 7; So specify a datalayout here. 8target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 9 10; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps 11; CHECK-NEXT: __LLVM_StackMaps: 12; Header 13; CHECK-NEXT: .byte 1 14; CHECK-NEXT: .byte 0 15; CHECK-NEXT: .short 0 16; Num Functions 17; CHECK-NEXT: .long 11 18; Num LargeConstants 19; CHECK-NEXT: .long 2 20; Num Callsites 21; CHECK-NEXT: .long 11 22 23; Functions and stack size 24; CHECK-NEXT: .quad _constantargs 25; CHECK-NEXT: .quad 16 26; CHECK-NEXT: .quad _osrinline 27; CHECK-NEXT: .quad 32 28; CHECK-NEXT: .quad _osrcold 29; CHECK-NEXT: .quad 16 30; CHECK-NEXT: .quad _propertyRead 31; CHECK-NEXT: .quad 16 32; CHECK-NEXT: .quad _propertyWrite 33; CHECK-NEXT: .quad 16 34; CHECK-NEXT: .quad _jsVoidCall 35; CHECK-NEXT: .quad 16 36; CHECK-NEXT: .quad _jsIntCall 37; CHECK-NEXT: .quad 16 38; CHECK-NEXT: .quad _spilledValue 39; CHECK-NEXT: .quad 160 40; CHECK-NEXT: .quad _spilledStackMapValue 41; CHECK-NEXT: .quad 128 42; CHECK-NEXT: .quad _liveConstant 43; CHECK-NEXT: .quad 16 44; CHECK-NEXT: .quad _clobberLR 45; CHECK-NEXT: .quad 112 46 47; Num LargeConstants 48; CHECK-NEXT: .quad 4294967295 49; CHECK-NEXT: .quad 4294967296 50 51; Constant arguments 52; 53; CHECK-NEXT: .quad 1 54; CHECK-NEXT: .long L{{.*}}-_constantargs 55; CHECK-NEXT: .short 0 56; CHECK-NEXT: .short 4 57; SmallConstant 58; CHECK-NEXT: .byte 4 59; CHECK-NEXT: .byte 8 60; CHECK-NEXT: .short 0 61; CHECK-NEXT: .long 65535 62; SmallConstant 63; CHECK-NEXT: .byte 4 64; CHECK-NEXT: .byte 8 65; CHECK-NEXT: .short 0 66; CHECK-NEXT: .long 65536 67; SmallConstant 68; CHECK-NEXT: .byte 5 69; CHECK-NEXT: .byte 8 70; CHECK-NEXT: .short 0 71; CHECK-NEXT: .long 0 72; LargeConstant at index 0 73; CHECK-NEXT: .byte 5 74; CHECK-NEXT: .byte 8 75; CHECK-NEXT: .short 0 76; CHECK-NEXT: .long 1 77 78define void @constantargs() { 79entry: 80 %0 = inttoptr i64 244837814094590 to i8* 81 tail call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 1, i32 20, i8* %0, i32 0, i64 65535, i64 65536, i64 4294967295, i64 4294967296) 82 ret void 83} 84 85; Inline OSR Exit 86; 87; CHECK-LABEL: .long L{{.*}}-_osrinline 88; CHECK-NEXT: .short 0 89; CHECK-NEXT: .short 2 90; CHECK-NEXT: .byte 1 91; CHECK-NEXT: .byte 8 92; CHECK-NEXT: .short {{[0-9]+}} 93; CHECK-NEXT: .long 0 94; CHECK-NEXT: .byte 1 95; CHECK-NEXT: .byte 8 96; CHECK-NEXT: .short {{[0-9]+}} 97; CHECK-NEXT: .long 0 98define void @osrinline(i64 %a, i64 %b) { 99entry: 100 ; Runtime void->void call. 101 call void inttoptr (i64 244837814094590 to void ()*)() 102 ; Followed by inline OSR patchpoint with 12-byte shadow and 2 live vars. 103 call void (i64, i32, ...) @llvm.experimental.stackmap(i64 3, i32 12, i64 %a, i64 %b) 104 ret void 105} 106 107; Cold OSR Exit 108; 109; 2 live variables in register. 110; 111; CHECK-LABEL: .long L{{.*}}-_osrcold 112; CHECK-NEXT: .short 0 113; CHECK-NEXT: .short 2 114; CHECK-NEXT: .byte 1 115; CHECK-NEXT: .byte 8 116; CHECK-NEXT: .short {{[0-9]+}} 117; CHECK-NEXT: .long 0 118; CHECK-NEXT: .byte 1 119; CHECK-NEXT: .byte 8 120; CHECK-NEXT: .short {{[0-9]+}} 121; CHECK-NEXT: .long 0 122define void @osrcold(i64 %a, i64 %b) { 123entry: 124 %test = icmp slt i64 %a, %b 125 br i1 %test, label %ret, label %cold 126cold: 127 ; OSR patchpoint with 12-byte nop-slide and 2 live vars. 128 %thunk = inttoptr i64 244837814094590 to i8* 129 call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 4, i32 20, i8* %thunk, i32 0, i64 %a, i64 %b) 130 unreachable 131ret: 132 ret void 133} 134 135; Property Read 136; CHECK-LABEL: .long L{{.*}}-_propertyRead 137; CHECK-NEXT: .short 0 138; CHECK-NEXT: .short 0 139; 140; FIXME: There are currently no stackmap entries. After moving to 141; AnyRegCC, we will have entries for the object and return value. 142define i64 @propertyRead(i64* %obj) { 143entry: 144 %resolveRead = inttoptr i64 244837814094590 to i8* 145 %result = call i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 5, i32 20, i8* %resolveRead, i32 1, i64* %obj) 146 %add = add i64 %result, 3 147 ret i64 %add 148} 149 150; Property Write 151; CHECK-LABEL: .long L{{.*}}-_propertyWrite 152; CHECK-NEXT: .short 0 153; CHECK-NEXT: .short 2 154; CHECK-NEXT: .byte 1 155; CHECK-NEXT: .byte 8 156; CHECK-NEXT: .short {{[0-9]+}} 157; CHECK-NEXT: .long 0 158; CHECK-NEXT: .byte 1 159; CHECK-NEXT: .byte 8 160; CHECK-NEXT: .short {{[0-9]+}} 161; CHECK-NEXT: .long 0 162define void @propertyWrite(i64 %dummy1, i64* %obj, i64 %dummy2, i64 %a) { 163entry: 164 %resolveWrite = inttoptr i64 244837814094590 to i8* 165 call anyregcc void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 6, i32 20, i8* %resolveWrite, i32 2, i64* %obj, i64 %a) 166 ret void 167} 168 169; Void JS Call 170; 171; 2 live variables in registers. 172; 173; CHECK-LABEL: .long L{{.*}}-_jsVoidCall 174; CHECK-NEXT: .short 0 175; CHECK-NEXT: .short 2 176; CHECK-NEXT: .byte 1 177; CHECK-NEXT: .byte 8 178; CHECK-NEXT: .short {{[0-9]+}} 179; CHECK-NEXT: .long 0 180; CHECK-NEXT: .byte 1 181; CHECK-NEXT: .byte 8 182; CHECK-NEXT: .short {{[0-9]+}} 183; CHECK-NEXT: .long 0 184define void @jsVoidCall(i64 %dummy1, i64* %obj, i64 %arg, i64 %l1, i64 %l2) { 185entry: 186 %resolveCall = inttoptr i64 244837814094590 to i8* 187 call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 7, i32 20, i8* %resolveCall, i32 2, i64* %obj, i64 %arg, i64 %l1, i64 %l2) 188 ret void 189} 190 191; i64 JS Call 192; 193; 2 live variables in registers. 194; 195; CHECK-LABEL: .long L{{.*}}-_jsIntCall 196; CHECK-NEXT: .short 0 197; CHECK-NEXT: .short 2 198; CHECK-NEXT: .byte 1 199; CHECK-NEXT: .byte 8 200; CHECK-NEXT: .short {{[0-9]+}} 201; CHECK-NEXT: .long 0 202; CHECK-NEXT: .byte 1 203; CHECK-NEXT: .byte 8 204; CHECK-NEXT: .short {{[0-9]+}} 205; CHECK-NEXT: .long 0 206define i64 @jsIntCall(i64 %dummy1, i64* %obj, i64 %arg, i64 %l1, i64 %l2) { 207entry: 208 %resolveCall = inttoptr i64 244837814094590 to i8* 209 %result = call i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 8, i32 20, i8* %resolveCall, i32 2, i64* %obj, i64 %arg, i64 %l1, i64 %l2) 210 %add = add i64 %result, 3 211 ret i64 %add 212} 213 214; Spilled stack map values. 215; 216; Verify 28 stack map entries. 217; 218; CHECK-LABEL: .long L{{.*}}-_spilledValue 219; CHECK-NEXT: .short 0 220; CHECK-NEXT: .short 28 221; 222; Check that at least one is a spilled entry from RBP. 223; Location: Indirect FP + ... 224; CHECK: .byte 3 225; CHECK-NEXT: .byte 8 226; CHECK-NEXT: .short 29 227define void @spilledValue(i64 %arg0, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27) { 228entry: 229 call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 11, i32 20, i8* null, i32 5, i64 %arg0, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27) 230 ret void 231} 232 233; Spilled stack map values. 234; 235; Verify 23 stack map entries. 236; 237; CHECK-LABEL: .long L{{.*}}-_spilledStackMapValue 238; CHECK-NEXT: .short 0 239; CHECK-NEXT: .short 30 240; 241; Check that at least one is a spilled entry from RBP. 242; Location: Indirect FP + ... 243; CHECK: .byte 3 244; CHECK-NEXT: .byte 8 245; CHECK-NEXT: .short 29 246define webkit_jscc void @spilledStackMapValue(i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27, i64 %l28, i64 %l29) { 247entry: 248 call void (i64, i32, ...) @llvm.experimental.stackmap(i64 12, i32 16, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27, i64 %l28, i64 %l29) 249 ret void 250} 251 252 253; Map a constant value. 254; 255; CHECK-LABEL: .long L{{.*}}-_liveConstant 256; CHECK-NEXT: .short 0 257; 1 location 258; CHECK-NEXT: .short 1 259; Loc 0: SmallConstant 260; CHECK-NEXT: .byte 4 261; CHECK-NEXT: .byte 8 262; CHECK-NEXT: .short 0 263; CHECK-NEXT: .long 33 264 265define void @liveConstant() { 266 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 15, i32 8, i32 33) 267 ret void 268} 269 270; Map a value when LR is the only free register. 271; 272; CHECK-LABEL: .long L{{.*}}-_clobberLR 273; CHECK-NEXT: .short 0 274; 1 location 275; CHECK-NEXT: .short 1 276; Loc 0: Indirect FP (r29) - offset 277; CHECK-NEXT: .byte 3 278; CHECK-NEXT: .byte 4 279; CHECK-NEXT: .short 29 280; CHECK-NEXT: .long -{{[0-9]+}} 281define void @clobberLR(i32 %a) { 282 tail call void asm sideeffect "nop", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{x29},~{x31}"() nounwind 283 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 16, i32 8, i32 %a) 284 ret void 285} 286 287declare void @llvm.experimental.stackmap(i64, i32, ...) 288declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...) 289declare i64 @llvm.experimental.patchpoint.i64(i64, i32, i8*, i32, ...) 290