1; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s 2; 3; Note: Print verbose stackmaps using -debug-only=stackmaps. 4 5; CHECK-LABEL: .section .llvm_stackmaps 6; CHECK-NEXT: __LLVM_StackMaps: 7; Header 8; CHECK-NEXT: .byte 3 9; CHECK-NEXT: .byte 0 10; CHECK-NEXT: .hword 0 11; Num Functions 12; CHECK-NEXT: .word 14 13; Num LargeConstants 14; CHECK-NEXT: .word 3 15; Num Callsites 16; CHECK-NEXT: .word 18 17 18; Functions and stack size 19; CHECK-NEXT: .xword constantargs 20; CHECK-NEXT: .xword 16 21; CHECK-NEXT: .xword 1 22; CHECK-NEXT: .xword osrinline 23; CHECK-NEXT: .xword 32 24; CHECK-NEXT: .xword 1 25; CHECK-NEXT: .xword osrcold 26; CHECK-NEXT: .xword 16 27; CHECK-NEXT: .xword 1 28; CHECK-NEXT: .xword propertyRead 29; CHECK-NEXT: .xword 16 30; CHECK-NEXT: .xword 1 31; CHECK-NEXT: .xword propertyWrite 32; CHECK-NEXT: .xword 16 33; CHECK-NEXT: .xword 1 34; CHECK-NEXT: .xword jsVoidCall 35; CHECK-NEXT: .xword 16 36; CHECK-NEXT: .xword 1 37; CHECK-NEXT: .xword jsIntCall 38; CHECK-NEXT: .xword 16 39; CHECK-NEXT: .xword 1 40; CHECK-NEXT: .xword spilledValue 41; CHECK-NEXT: .xword 144 42; CHECK-NEXT: .xword 1 43; CHECK-NEXT: .xword spilledStackMapValue 44; CHECK-NEXT: .xword 128 45; CHECK-NEXT: .xword 1 46; CHECK-NEXT: .xword liveConstant 47; CHECK-NEXT: .xword 16 48; CHECK-NEXT: .xword 1 49; CHECK-NEXT: .xword directFrameIdx 50; CHECK-NEXT: .xword 64 51; CHECK-NEXT: .xword 2 52; CHECK-NEXT: .xword longid 53; CHECK-NEXT: .xword 16 54; CHECK-NEXT: .xword 4 55; CHECK-NEXT: .xword clobberLR 56; CHECK-NEXT: .xword 112 57; CHECK-NEXT: .xword 1 58; CHECK-NEXT: .xword needsStackRealignment 59; CHECK-NEXT: .xword -1 60; CHECK-NEXT: .xword 1 61 62; Large Constants 63; CHECK-NEXT: .xword 2147483648 64; CHECK-NEXT: .xword 4294967295 65; CHECK-NEXT: .xword 4294967296 66 67; Callsites 68; Constant arguments 69; 70; CHECK-NEXT: .xword 1 71; CHECK-NEXT: .word .L{{.*}}-constantargs 72; CHECK-NEXT: .hword 0 73; CHECK-NEXT: .hword 12 74; SmallConstant 75; CHECK-NEXT: .byte 4 76; CHECK-NEXT: .byte 0 77; CHECK-NEXT: .hword 8 78; CHECK-NEXT: .hword 0 79; CHECK-NEXT: .hword 0 80; CHECK-NEXT: .word -1 81; SmallConstant 82; CHECK-NEXT: .byte 4 83; CHECK-NEXT: .byte 0 84; CHECK-NEXT: .hword 8 85; CHECK-NEXT: .hword 0 86; CHECK-NEXT: .hword 0 87; CHECK-NEXT: .word -1 88; SmallConstant 89; CHECK-NEXT: .byte 4 90; CHECK-NEXT: .byte 0 91; CHECK-NEXT: .hword 8 92; CHECK-NEXT: .hword 0 93; CHECK-NEXT: .hword 0 94; CHECK-NEXT: .word 65536 95; SmallConstant 96; CHECK-NEXT: .byte 4 97; CHECK-NEXT: .byte 0 98; CHECK-NEXT: .hword 8 99; CHECK-NEXT: .hword 0 100; CHECK-NEXT: .hword 0 101; CHECK-NEXT: .word 2000000000 102; SmallConstant 103; CHECK-NEXT: .byte 4 104; CHECK-NEXT: .byte 0 105; CHECK-NEXT: .hword 8 106; CHECK-NEXT: .hword 0 107; CHECK-NEXT: .hword 0 108; CHECK-NEXT: .word 2147483647 109; SmallConstant 110; CHECK-NEXT: .byte 4 111; CHECK-NEXT: .byte 0 112; CHECK-NEXT: .hword 8 113; CHECK-NEXT: .hword 0 114; CHECK-NEXT: .hword 0 115; CHECK-NEXT: .word -1 116; SmallConstant 117; CHECK-NEXT: .byte 4 118; CHECK-NEXT: .byte 0 119; CHECK-NEXT: .hword 8 120; CHECK-NEXT: .hword 0 121; CHECK-NEXT: .hword 0 122; CHECK-NEXT: .word -1 123; SmallConstant 124; CHECK-NEXT: .byte 4 125; CHECK-NEXT: .byte 0 126; CHECK-NEXT: .hword 8 127; CHECK-NEXT: .hword 0 128; CHECK-NEXT: .hword 0 129; CHECK-NEXT: .word 0 130; LargeConstant at index 0 131; CHECK-NEXT: .byte 5 132; CHECK-NEXT: .byte 0 133; CHECK-NEXT: .hword 8 134; CHECK-NEXT: .hword 0 135; CHECK-NEXT: .hword 0 136; CHECK-NEXT: .word 0 137; LargeConstant at index 1 138; CHECK-NEXT: .byte 5 139; CHECK-NEXT: .byte 0 140; CHECK-NEXT: .hword 8 141; CHECK-NEXT: .hword 0 142; CHECK-NEXT: .hword 0 143; CHECK-NEXT: .word 1 144; LargeConstant at index 2 145; CHECK-NEXT: .byte 5 146; CHECK-NEXT: .byte 0 147; CHECK-NEXT: .hword 8 148; CHECK-NEXT: .hword 0 149; CHECK-NEXT: .hword 0 150; CHECK-NEXT: .word 2 151; SmallConstant 152; CHECK-NEXT: .byte 4 153; CHECK-NEXT: .byte 0 154; CHECK-NEXT: .hword 8 155; CHECK-NEXT: .hword 0 156; CHECK-NEXT: .hword 0 157; CHECK-NEXT: .word -1 158 159define void @constantargs() { 160entry: 161 %0 = inttoptr i64 12345 to i8* 162 tail call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 1, i32 16, i8* %0, i32 0, i16 65535, i16 -1, i32 65536, i32 2000000000, i32 2147483647, i32 -1, i32 4294967295, i32 4294967296, i64 2147483648, i64 4294967295, i64 4294967296, i64 -1) 163 ret void 164} 165 166; Inline OSR Exit 167; 168; CHECK-LABEL: .word .L{{.*}}-osrinline 169; CHECK-NEXT: .hword 0 170; CHECK-NEXT: .hword 2 171; CHECK-NEXT: .byte 1 172; CHECK-NEXT: .byte 0 173; CHECK-NEXT: .hword 8 174; CHECK-NEXT: .hword {{[0-9]+}} 175; CHECK-NEXT: .hword 0 176; CHECK-NEXT: .word 0 177; CHECK-NEXT: .byte 1 178; CHECK-NEXT: .byte 0 179; CHECK-NEXT: .hword 8 180; CHECK-NEXT: .hword {{[0-9]+}} 181; CHECK-NEXT: .hword 0 182; CHECK-NEXT: .word 0 183define void @osrinline(i64 %a, i64 %b) { 184entry: 185 ; Runtime void->void call. 186 call void inttoptr (i64 -559038737 to void ()*)() 187 ; Followed by inline OSR patchpoint with 12-byte shadow and 2 live vars. 188 call void (i64, i32, ...) @llvm.experimental.stackmap(i64 3, i32 12, i64 %a, i64 %b) 189 ret void 190} 191 192; Cold OSR Exit 193; 194; 2 live variables in register. 195; 196; CHECK-LABEL: .word .L{{.*}}-osrcold 197; CHECK-NEXT: .hword 0 198; CHECK-NEXT: .hword 2 199; CHECK-NEXT: .byte 1 200; CHECK-NEXT: .byte 0 201; CHECK-NEXT: .hword 8 202; CHECK-NEXT: .hword {{[0-9]+}} 203; CHECK-NEXT: .hword 0 204; CHECK-NEXT: .word 0 205; CHECK-NEXT: .byte 1 206; CHECK-NEXT: .byte 0 207; CHECK-NEXT: .hword 8 208; CHECK-NEXT: .hword {{[0-9]+}} 209; CHECK-NEXT: .hword 0 210; CHECK-NEXT: .word 0 211define void @osrcold(i64 %a, i64 %b) { 212entry: 213 %test = icmp slt i64 %a, %b 214 br i1 %test, label %ret, label %cold 215cold: 216 ; OSR patchpoint with 12-byte nop-slide and 2 live vars. 217 %thunk = inttoptr i64 3735928559 to i8* 218 call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 4, i32 16, i8* %thunk, i32 0, i64 %a, i64 %b) 219 unreachable 220ret: 221 ret void 222} 223 224; Property Read 225; CHECK-LABEL: .word .L{{.*}}-propertyRead 226; CHECK-NEXT: .hword 0 227; CHECK-NEXT: .hword 2 228; CHECK-NEXT: .byte 1 229; CHECK-NEXT: .byte 0 230; CHECK-NEXT: .hword 8 231; CHECK-NEXT: .hword {{[0-9]+}} 232; CHECK-NEXT: .hword 0 233; CHECK-NEXT: .word 0 234; CHECK-NEXT: .byte 1 235; CHECK-NEXT: .byte 0 236; CHECK-NEXT: .hword 8 237; CHECK-NEXT: .hword {{[0-9]+}} 238; CHECK-NEXT: .hword 0 239; CHECK-NEXT: .word 0 240define i64 @propertyRead(i64* %obj) { 241entry: 242 %resolveRead = inttoptr i64 3735928559 to i8* 243 %result = call anyregcc i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 5, i32 16, i8* %resolveRead, i32 1, i64* %obj) 244 %add = add i64 %result, 3 245 ret i64 %add 246} 247 248; Property Write 249; CHECK-LABEL: .word .L{{.*}}-propertyWrite 250; CHECK-NEXT: .hword 0 251; CHECK-NEXT: .hword 2 252; CHECK-NEXT: .byte 1 253; CHECK-NEXT: .byte 0 254; CHECK-NEXT: .hword 8 255; CHECK-NEXT: .hword {{[0-9]+}} 256; CHECK-NEXT: .hword 0 257; CHECK-NEXT: .word 0 258; CHECK-NEXT: .byte 1 259; CHECK-NEXT: .byte 0 260; CHECK-NEXT: .hword 8 261; CHECK-NEXT: .hword {{[0-9]+}} 262; CHECK-NEXT: .hword 0 263; CHECK-NEXT: .word 0 264define void @propertyWrite(i64 %dummy1, i64* %obj, i64 %dummy2, i64 %a) { 265entry: 266 %resolveWrite = inttoptr i64 3735928559 to i8* 267 call anyregcc void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 6, i32 16, i8* %resolveWrite, i32 2, i64* %obj, i64 %a) 268 ret void 269} 270 271; Void JS Call 272; 273; 2 live variables in registers. 274; 275; CHECK-LABEL: .word .L{{.*}}-jsVoidCall 276; CHECK-NEXT: .hword 0 277; CHECK-NEXT: .hword 2 278; CHECK-NEXT: .byte 1 279; CHECK-NEXT: .byte 0 280; CHECK-NEXT: .hword 8 281; CHECK-NEXT: .hword {{[0-9]+}} 282; CHECK-NEXT: .hword 0 283; CHECK-NEXT: .word 0 284; CHECK-NEXT: .byte 1 285; CHECK-NEXT: .byte 0 286; CHECK-NEXT: .hword 8 287; CHECK-NEXT: .hword {{[0-9]+}} 288; CHECK-NEXT: .hword 0 289; CHECK-NEXT: .word 0 290define void @jsVoidCall(i64 %dummy1, i64* %obj, i64 %arg, i64 %l1, i64 %l2) { 291entry: 292 %resolveCall = inttoptr i64 3735928559 to i8* 293 call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 7, i32 16, i8* %resolveCall, i32 2, i64* %obj, i64 %arg, i64 %l1, i64 %l2) 294 ret void 295} 296 297; i64 JS Call 298; 299; 2 live variables in registers. 300; 301; CHECK-LABEL: .word .L{{.*}}-jsIntCall 302; CHECK-NEXT: .hword 0 303; CHECK-NEXT: .hword 2 304; CHECK-NEXT: .byte 1 305; CHECK-NEXT: .byte 0 306; CHECK-NEXT: .hword 8 307; CHECK-NEXT: .hword {{[0-9]+}} 308; CHECK-NEXT: .hword 0 309; CHECK-NEXT: .word 0 310; CHECK-NEXT: .byte 1 311; CHECK-NEXT: .byte 0 312; CHECK-NEXT: .hword 8 313; CHECK-NEXT: .hword {{[0-9]+}} 314; CHECK-NEXT: .hword 0 315; CHECK-NEXT: .word 0 316define i64 @jsIntCall(i64 %dummy1, i64* %obj, i64 %arg, i64 %l1, i64 %l2) { 317entry: 318 %resolveCall = inttoptr i64 3735928559 to i8* 319 %result = call i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 8, i32 16, i8* %resolveCall, i32 2, i64* %obj, i64 %arg, i64 %l1, i64 %l2) 320 %add = add i64 %result, 3 321 ret i64 %add 322} 323 324; Spilled stack map values. 325; 326; Verify 28 stack map entries. 327; 328; CHECK-LABEL: .word .L{{.*}}-spilledValue 329; CHECK-NEXT: .hword 0 330; CHECK-NEXT: .hword 28 331; 332; Check that at least one is a spilled entry from RBP. 333; Location: Indirect RBP + ... 334; CHECK: .byte 3 335; CHECK-NEXT: .byte 0 336; CHECK-NEXT: .hword 8 337; CHECK-NEXT: .hword 29 338; CHECK-NEXT: .hword 0 339; CHECK-NEXT: .word 340define 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) { 341entry: 342 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) 343 ret void 344} 345 346; Spilled stack map values. 347; 348; Verify 30 stack map entries. 349; 350; CHECK-LABEL: .word .L{{.*}}-spilledStackMapValue 351; CHECK-NEXT: .hword 0 352; CHECK-NEXT: .hword 30 353; 354; Check that at least one is a spilled entry from RBP. 355; Location: Indirect RBP + ... 356; CHECK: .byte 3 357; CHECK-NEXT: .byte 0 358; CHECK-NEXT: .hword 8 359; CHECK-NEXT: .hword 29 360; CHECK-NEXT: .hword 0 361; CHECK-NEXT: .word 362define 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) { 363entry: 364 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) 365 ret void 366} 367 368; Map a constant value. 369; 370; CHECK-LABEL: .word .L{{.*}}-liveConstant 371; CHECK-NEXT: .hword 0 372; 1 location 373; CHECK-NEXT: .hword 1 374; Loc 0: SmallConstant 375; CHECK-NEXT: .byte 4 376; CHECK-NEXT: .byte 0 377; CHECK-NEXT: .hword 8 378; CHECK-NEXT: .hword 0 379; CHECK-NEXT: .hword 0 380; CHECK-NEXT: .word 33 381 382define void @liveConstant() { 383 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 15, i32 4, i32 33) 384 ret void 385} 386 387; Directly map an alloca's address. 388; 389; Callsite 16 390; CHECK-LABEL: .word .L{{.*}}-directFrameIdx 391; CHECK-NEXT: .hword 0 392; 1 location 393; CHECK-NEXT: .hword 1 394; Loc 0: Direct RBP - ofs 395; CHECK-NEXT: .byte 2 396; CHECK-NEXT: .byte 0 397; CHECK-NEXT: .hword 8 398; CHECK-NEXT: .hword 29 399; CHECK-NEXT: .hword 0 400; CHECK-NEXT: .word 401 402; Callsite 17 403; CHECK-LABEL: .word .L{{.*}}-directFrameIdx 404; CHECK-NEXT: .hword 0 405; 2 locations 406; CHECK-NEXT: .hword 2 407; Loc 0: Direct RBP - ofs 408; CHECK-NEXT: .byte 2 409; CHECK-NEXT: .byte 0 410; CHECK-NEXT: .hword 8 411; CHECK-NEXT: .hword 29 412; CHECK-NEXT: .hword 0 413; CHECK-NEXT: .word 414; Loc 1: Direct RBP - ofs 415; CHECK-NEXT: .byte 2 416; CHECK-NEXT: .byte 0 417; CHECK-NEXT: .hword 8 418; CHECK-NEXT: .hword 29 419; CHECK-NEXT: .hword 0 420; CHECK-NEXT: .word 421define void @directFrameIdx() { 422entry: 423 %metadata1 = alloca i64, i32 3, align 8 424 store i64 11, i64* %metadata1 425 store i64 12, i64* %metadata1 426 store i64 13, i64* %metadata1 427 call void (i64, i32, ...) @llvm.experimental.stackmap(i64 16, i32 0, i64* %metadata1) 428 %metadata2 = alloca i8, i32 4, align 8 429 %metadata3 = alloca i16, i32 4, align 8 430 call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 17, i32 4, i8* null, i32 0, i8* %metadata2, i16* %metadata3) 431 ret void 432} 433 434; Test a 64-bit ID. 435; 436; CHECK: .xword 4294967295 437; CHECK-LABEL: .word .L{{.*}}-longid 438; CHECK: .xword 4294967296 439; CHECK-LABEL: .word .L{{.*}}-longid 440; CHECK: .xword 9223372036854775807 441; CHECK-LABEL: .word .L{{.*}}-longid 442; CHECK: .xword -1 443; CHECK-LABEL: .word .L{{.*}}-longid 444define void @longid() { 445entry: 446 tail call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 4294967295, i32 0, i8* null, i32 0) 447 tail call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 4294967296, i32 0, i8* null, i32 0) 448 tail call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 9223372036854775807, i32 0, i8* null, i32 0) 449 tail call void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 -1, i32 0, i8* null, i32 0) 450 ret void 451} 452 453; Map a value when R11 is the only free register. 454; The scratch register should not be used for a live stackmap value. 455; 456; CHECK-LABEL: .word .L{{.*}}-clobberLR 457; CHECK-NEXT: .hword 0 458; 1 location 459; CHECK-NEXT: .hword 1 460; Loc 0: Indirect fp - offset 461; CHECK-NEXT: .byte 3 462; CHECK-NEXT: .byte 0 463; CHECK-NEXT: .hword 4 464; CHECK-NEXT: .hword 29 465; CHECK-NEXT: .hword 0 466; CHECK-NEXT: .word -{{[0-9]+}} 467define void @clobberLR(i32 %a) { 468 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 469 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 16, i32 8, i32 %a) 470 ret void 471} 472 473; A stack frame which needs to be realigned at runtime (to meet alignment 474; criteria for values on the stack) does not have a fixed frame size. 475; CHECK-LABEL: .word .L{{.*}}-needsStackRealignment 476; CHECK-NEXT: .hword 0 477; 0 locations 478; CHECK-NEXT: .hword 0 479define void @needsStackRealignment() { 480 %val = alloca i64, i32 3, align 128 481 tail call void (...) @escape_values(i64* %val) 482; Note: Adding any non-constant to the stackmap would fail because we 483; expected to be able to address off the frame pointer. In a realigned 484; frame, we must use the stack pointer instead. This is a separate bug. 485 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 0) 486 ret void 487} 488declare void @escape_values(...) 489 490declare void @llvm.experimental.stackmap(i64, i32, ...) 491declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...) 492declare i64 @llvm.experimental.patchpoint.i64(i64, i32, i8*, i32, ...) 493