1; RUN: llc < %s -mcpu=generic -mtriple=i686-linux -verify-machineinstrs | FileCheck %s -check-prefix=X86-Linux 2; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -verify-machineinstrs | FileCheck %s -check-prefix=X64-Linux 3; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -code-model=large -verify-machineinstrs | FileCheck %s -check-prefix=X64-Linux-Large 4; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnux32 -verify-machineinstrs | FileCheck %s -check-prefix=X32ABI 5; RUN: llc < %s -mcpu=generic -mtriple=i686-darwin -verify-machineinstrs | FileCheck %s -check-prefix=X86-Darwin 6; RUN: llc < %s -mcpu=generic -mtriple=x86_64-darwin -verify-machineinstrs | FileCheck %s -check-prefix=X64-Darwin 7; RUN: llc < %s -mcpu=generic -mtriple=i686-mingw32 -verify-machineinstrs | FileCheck %s -check-prefix=X86-MinGW 8; RUN: llc < %s -mcpu=generic -mtriple=x86_64-freebsd -verify-machineinstrs | FileCheck %s -check-prefix=X64-FreeBSD 9; RUN: llc < %s -mcpu=generic -mtriple=i686-dragonfly -verify-machineinstrs | FileCheck %s -check-prefix=X86-DFlyBSD 10; RUN: llc < %s -mcpu=generic -mtriple=x86_64-dragonfly -verify-machineinstrs | FileCheck %s -check-prefix=X64-DFlyBSD 11; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32 -verify-machineinstrs | FileCheck %s -check-prefix=X64-MinGW 12 13; We used to crash with filetype=obj 14; RUN: llc < %s -mcpu=generic -mtriple=i686-linux -filetype=obj -o /dev/null 15; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -filetype=obj -o /dev/null 16; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnux32 -filetype=obj -o /dev/null 17; RUN: llc < %s -mcpu=generic -mtriple=i686-darwin -filetype=obj -o /dev/null 18; RUN: llc < %s -mcpu=generic -mtriple=x86_64-darwin -filetype=obj -o /dev/null 19; RUN: llc < %s -mcpu=generic -mtriple=i686-mingw32 -filetype=obj -o /dev/null 20; RUN: llc < %s -mcpu=generic -mtriple=x86_64-freebsd -filetype=obj -o /dev/null 21; RUN: llc < %s -mcpu=generic -mtriple=i686-dragonfly -filetype=obj -o /dev/null 22; RUN: llc < %s -mcpu=generic -mtriple=x86_64-dragonfly -filetype=obj -o /dev/null 23; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32 -filetype=obj -o /dev/null 24 25; RUN: not --crash llc < %s -mcpu=generic -mtriple=x86_64-solaris 2> %t.log 26; RUN: FileCheck %s -input-file=%t.log -check-prefix=X64-Solaris 27; RUN: not --crash llc < %s -mcpu=generic -mtriple=i686-freebsd 2> %t.log 28; RUN: FileCheck %s -input-file=%t.log -check-prefix=X86-FreeBSD 29 30; X64-Solaris: Segmented stacks not supported on this platform 31; X86-FreeBSD: Segmented stacks not supported on FreeBSD i386 32 33; Just to prevent the alloca from being optimized away 34declare void @dummy_use(i32*, i32) 35 36define void @test_basic() #0 { 37 %mem = alloca i32, i32 10 38 call void @dummy_use (i32* %mem, i32 10) 39 ret void 40 41; X86-Linux-LABEL: test_basic: 42 43; X86-Linux: cmpl %gs:48, %esp 44; X86-Linux-NEXT: jbe .LBB0_1 45 46; X86-Linux: pushl $0 47; X86-Linux-NEXT: pushl $44 48; X86-Linux-NEXT: calll __morestack 49; X86-Linux-NEXT: ret 50 51; X64-Linux-LABEL: test_basic: 52 53; X64-Linux: cmpq %fs:112, %rsp 54; X64-Linux-NEXT: jbe .LBB0_1 55 56; X64-Linux: movabsq $40, %r10 57; X64-Linux-NEXT: movabsq $0, %r11 58; X64-Linux-NEXT: callq __morestack 59; X64-Linux-NEXT: ret 60 61; X64-Linux-Large-LABEL: test_basic: 62 63; X64-Linux-Large: cmpq %fs:112, %rsp 64; X64-Linux-Large-NEXT: jbe .LBB0_1 65 66; X64-Linux-Large: movabsq $40, %r10 67; X64-Linux-Large-NEXT: movabsq $0, %r11 68; X64-Linux-Large-NEXT: callq *__morestack_addr(%rip) 69; X64-Linux-Large-NEXT: ret 70 71; X32ABI-LABEL: test_basic: 72 73; X32ABI: cmpl %fs:64, %esp 74; X32ABI-NEXT: jbe .LBB0_1 75 76; X32ABI: movl $40, %r10d 77; X32ABI-NEXT: movl $0, %r11d 78; X32ABI-NEXT: callq __morestack 79; X32ABI-NEXT: ret 80 81; X86-Darwin-LABEL: test_basic: 82 83; X86-Darwin: movl $432, %ecx 84; X86-Darwin-NEXT: cmpl %gs:(%ecx), %esp 85; X86-Darwin-NEXT: jbe LBB0_1 86 87; X86-Darwin: pushl $0 88; X86-Darwin-NEXT: pushl $60 89; X86-Darwin-NEXT: calll ___morestack 90; X86-Darwin-NEXT: ret 91 92; X64-Darwin-LABEL: test_basic: 93 94; X64-Darwin: cmpq %gs:816, %rsp 95; X64-Darwin-NEXT: jbe LBB0_1 96 97; X64-Darwin: movabsq $40, %r10 98; X64-Darwin-NEXT: movabsq $0, %r11 99; X64-Darwin-NEXT: callq ___morestack 100; X64-Darwin-NEXT: ret 101 102; X86-MinGW-LABEL: test_basic: 103 104; X86-MinGW: cmpl %fs:20, %esp 105; X86-MinGW-NEXT: jbe LBB0_1 106 107; X86-MinGW: pushl $0 108; X86-MinGW-NEXT: pushl $40 109; X86-MinGW-NEXT: calll ___morestack 110; X86-MinGW-NEXT: ret 111 112; X64-MinGW-LABEL: test_basic: 113 114; X64-MinGW: cmpq %gs:40, %rsp 115; X64-MinGW-NEXT: jbe .LBB0_1 116 117; X64-MinGW: movabsq $72, %r10 118; X64-MinGW-NEXT: movabsq $32, %r11 119; X64-MinGW-NEXT: callq __morestack 120; X64-MinGW-NEXT: retq 121 122; X64-FreeBSD-LABEL: test_basic: 123 124; X64-FreeBSD: cmpq %fs:24, %rsp 125; X64-FreeBSD-NEXT: jbe .LBB0_1 126 127; X64-FreeBSD: movabsq $40, %r10 128; X64-FreeBSD-NEXT: movabsq $0, %r11 129; X64-FreeBSD-NEXT: callq __morestack 130; X64-FreeBSD-NEXT: ret 131 132; X86-DFlyBSD-LABEL: test_basic: 133 134; X86-DFlyBSD: cmpl %fs:16, %esp 135; X86-DFlyBSD-NEXT: jbe .LBB0_1 136 137; X86-DFlyBSD: pushl $0 138; X86-DFlyBSD-NEXT: pushl $40 139; X86-DFlyBSD-NEXT: calll __morestack 140; X86-DFlyBSD-NEXT: ret 141 142; X64-DFlyBSD-LABEL: test_basic: 143 144; X64-DFlyBSD: cmpq %fs:32, %rsp 145; X64-DFlyBSD-NEXT: jbe .LBB0_1 146 147; X64-DFlyBSD: movabsq $40, %r10 148; X64-DFlyBSD-NEXT: movabsq $0, %r11 149; X64-DFlyBSD-NEXT: callq __morestack 150; X64-DFlyBSD-NEXT: ret 151 152} 153 154define i32 @test_nested(i32 * nest %closure, i32 %other) #0 { 155 %addend = load i32 , i32 * %closure 156 %result = add i32 %other, %addend 157 %mem = alloca i32, i32 10 158 call void @dummy_use (i32* %mem, i32 10) 159 ret i32 %result 160 161; X86-Linux: cmpl %gs:48, %esp 162; X86-Linux-NEXT: jbe .LBB1_1 163 164; X86-Linux: pushl $4 165; X86-Linux-NEXT: pushl $44 166; X86-Linux-NEXT: calll __morestack 167; X86-Linux-NEXT: ret 168 169; X64-Linux: cmpq %fs:112, %rsp 170; X64-Linux-NEXT: jbe .LBB1_1 171 172; X64-Linux: movq %r10, %rax 173; X64-Linux-NEXT: movabsq $56, %r10 174; X64-Linux-NEXT: movabsq $0, %r11 175; X64-Linux-NEXT: callq __morestack 176; X64-Linux-NEXT: ret 177; X64-Linux-NEXT: movq %rax, %r10 178 179; X32ABI: cmpl %fs:64, %esp 180; X32ABI-NEXT: jbe .LBB1_1 181 182; X32ABI: movl %r10d, %eax 183; X32ABI-NEXT: movl $56, %r10d 184; X32ABI-NEXT: movl $0, %r11d 185; X32ABI-NEXT: callq __morestack 186; X32ABI-NEXT: ret 187; X32ABI-NEXT: movq %rax, %r10 188 189; X86-Darwin: movl $432, %edx 190; X86-Darwin-NEXT: cmpl %gs:(%edx), %esp 191; X86-Darwin-NEXT: jbe LBB1_1 192 193; X86-Darwin: pushl $4 194; X86-Darwin-NEXT: pushl $60 195; X86-Darwin-NEXT: calll ___morestack 196; X86-Darwin-NEXT: ret 197 198; X64-Darwin: cmpq %gs:816, %rsp 199; X64-Darwin-NEXT: jbe LBB1_1 200 201; X64-Darwin: movq %r10, %rax 202; X64-Darwin-NEXT: movabsq $56, %r10 203; X64-Darwin-NEXT: movabsq $0, %r11 204; X64-Darwin-NEXT: callq ___morestack 205; X64-Darwin-NEXT: ret 206; X64-Darwin-NEXT: movq %rax, %r10 207 208; X86-MinGW: cmpl %fs:20, %esp 209; X86-MinGW-NEXT: jbe LBB1_1 210 211; X86-MinGW: pushl $4 212; X86-MinGW-NEXT: pushl $44 213; X86-MinGW-NEXT: calll ___morestack 214; X86-MinGW-NEXT: ret 215 216; X64-MinGW-LABEL: test_nested: 217; X64-MinGW: cmpq %gs:40, %rsp 218; X64-MinGW-NEXT: jbe .LBB1_1 219 220; X64-MinGW: movq %r10, %rax 221; X64-MinGW-NEXT: movabsq $88, %r10 222; X64-MinGW-NEXT: movabsq $32, %r11 223; X64-MinGW-NEXT: callq __morestack 224; X64-MinGW-NEXT: retq 225; X64-MinGW-NEXT: movq %rax, %r10 226 227; X64-FreeBSD: cmpq %fs:24, %rsp 228; X64-FreeBSD-NEXT: jbe .LBB1_1 229 230; X64-FreeBSD: movq %r10, %rax 231; X64-FreeBSD-NEXT: movabsq $56, %r10 232; X64-FreeBSD-NEXT: movabsq $0, %r11 233; X64-FreeBSD-NEXT: callq __morestack 234; X64-FreeBSD-NEXT: ret 235; X64-FreeBSD-NEXT: movq %rax, %r10 236 237; X86-DFlyBSD: cmpl %fs:16, %esp 238; X86-DFlyBSD-NEXT: jbe .LBB1_1 239 240; X86-DFlyBSD: pushl $4 241; X86-DFlyBSD-NEXT: pushl $44 242; X86-DFlyBSD-NEXT: calll __morestack 243; X86-DFlyBSD-NEXT: ret 244 245; X64-DFlyBSD: cmpq %fs:32, %rsp 246; X64-DFlyBSD-NEXT: jbe .LBB1_1 247 248; X64-DFlyBSD: movq %r10, %rax 249; X64-DFlyBSD-NEXT: movabsq $56, %r10 250; X64-DFlyBSD-NEXT: movabsq $0, %r11 251; X64-DFlyBSD-NEXT: callq __morestack 252; X64-DFlyBSD-NEXT: ret 253; X64-DFlyBSD-NEXT: movq %rax, %r10 254 255} 256 257define void @test_large() #0 { 258 %mem = alloca i32, i32 10000 259 call void @dummy_use (i32* %mem, i32 3) 260 ret void 261 262; X86-Linux-LABEL: test_large: 263 264; X86-Linux: leal -40012(%esp), %ecx 265; X86-Linux-NEXT: cmpl %gs:48, %ecx 266; X86-Linux-NEXT: jbe .LBB2_1 267 268; X86-Linux: pushl $0 269; X86-Linux-NEXT: pushl $40012 270; X86-Linux-NEXT: calll __morestack 271; X86-Linux-NEXT: ret 272 273; X64-Linux: leaq -40008(%rsp), %r11 274; X64-Linux-NEXT: cmpq %fs:112, %r11 275; X64-Linux-NEXT: jbe .LBB2_1 276 277; X64-Linux: movabsq $40008, %r10 278; X64-Linux-NEXT: movabsq $0, %r11 279; X64-Linux-NEXT: callq __morestack 280; X64-Linux-NEXT: ret 281 282; X32ABI: leal -40008(%rsp), %r11d 283; X32ABI-NEXT: cmpl %fs:64, %r11d 284; X32ABI-NEXT: jbe .LBB2_1 285 286; X32ABI: movl $40008, %r10d 287; X32ABI-NEXT: movl $0, %r11d 288; X32ABI-NEXT: callq __morestack 289; X32ABI-NEXT: ret 290 291; X86-Darwin: leal -40012(%esp), %ecx 292; X86-Darwin-NEXT: movl $432, %eax 293; X86-Darwin-NEXT: cmpl %gs:(%eax), %ecx 294; X86-Darwin-NEXT: jbe LBB2_1 295 296; X86-Darwin: pushl $0 297; X86-Darwin-NEXT: pushl $40012 298; X86-Darwin-NEXT: calll ___morestack 299; X86-Darwin-NEXT: ret 300 301; X64-Darwin: leaq -40008(%rsp), %r11 302; X64-Darwin-NEXT: cmpq %gs:816, %r11 303; X64-Darwin-NEXT: jbe LBB2_1 304 305; X64-Darwin: movabsq $40008, %r10 306; X64-Darwin-NEXT: movabsq $0, %r11 307; X64-Darwin-NEXT: callq ___morestack 308; X64-Darwin-NEXT: ret 309 310; X86-MinGW: leal -40000(%esp), %ecx 311; X86-MinGW-NEXT: cmpl %fs:20, %ecx 312; X86-MinGW-NEXT: jbe LBB2_1 313 314; X86-MinGW: pushl $0 315; X86-MinGW-NEXT: pushl $40000 316; X86-MinGW-NEXT: calll ___morestack 317; X86-MinGW-NEXT: ret 318 319; X64-MinGW-LABEL: test_large: 320; X64-MinGW: leaq -40040(%rsp), %r11 321; X64-MinGW-NEXT: cmpq %gs:40, %r11 322; X64-MinGW-NEXT: jbe .LBB2_1 323 324; X64-MinGW: movabsq $40040, %r10 325; X64-MinGW-NEXT: movabsq $32, %r11 326; X64-MinGW-NEXT: callq __morestack 327; X64-MinGW-NEXT: retq 328 329; X64-FreeBSD: leaq -40008(%rsp), %r11 330; X64-FreeBSD-NEXT: cmpq %fs:24, %r11 331; X64-FreeBSD-NEXT: jbe .LBB2_1 332 333; X64-FreeBSD: movabsq $40008, %r10 334; X64-FreeBSD-NEXT: movabsq $0, %r11 335; X64-FreeBSD-NEXT: callq __morestack 336; X64-FreeBSD-NEXT: ret 337 338; X86-DFlyBSD: leal -40000(%esp), %ecx 339; X86-DFlyBSD-NEXT: cmpl %fs:16, %ecx 340; X86-DFlyBSD-NEXT: jbe .LBB2_1 341 342; X86-DFlyBSD: pushl $0 343; X86-DFlyBSD-NEXT: pushl $40000 344; X86-DFlyBSD-NEXT: calll __morestack 345; X86-DFlyBSD-NEXT: ret 346 347; X64-DFlyBSD: leaq -40008(%rsp), %r11 348; X64-DFlyBSD-NEXT: cmpq %fs:32, %r11 349; X64-DFlyBSD-NEXT: jbe .LBB2_1 350 351; X64-DFlyBSD: movabsq $40008, %r10 352; X64-DFlyBSD-NEXT: movabsq $0, %r11 353; X64-DFlyBSD-NEXT: callq __morestack 354; X64-DFlyBSD-NEXT: ret 355 356} 357 358define fastcc void @test_fastcc() #0 { 359 %mem = alloca i32, i32 10 360 call void @dummy_use (i32* %mem, i32 10) 361 ret void 362 363; X86-Linux-LABEL: test_fastcc: 364 365; X86-Linux: cmpl %gs:48, %esp 366; X86-Linux-NEXT: jbe .LBB3_1 367 368; X86-Linux: pushl $0 369; X86-Linux-NEXT: pushl $44 370; X86-Linux-NEXT: calll __morestack 371; X86-Linux-NEXT: ret 372 373; X64-Linux-LABEL: test_fastcc: 374 375; X64-Linux: cmpq %fs:112, %rsp 376; X64-Linux-NEXT: jbe .LBB3_1 377 378; X64-Linux: movabsq $40, %r10 379; X64-Linux-NEXT: movabsq $0, %r11 380; X64-Linux-NEXT: callq __morestack 381; X64-Linux-NEXT: ret 382 383; X32ABI-LABEL: test_fastcc: 384 385; X32ABI: cmpl %fs:64, %esp 386; X32ABI-NEXT: jbe .LBB3_1 387 388; X32ABI: movl $40, %r10d 389; X32ABI-NEXT: movl $0, %r11d 390; X32ABI-NEXT: callq __morestack 391; X32ABI-NEXT: ret 392 393; X86-Darwin-LABEL: test_fastcc: 394 395; X86-Darwin: movl $432, %eax 396; X86-Darwin-NEXT: cmpl %gs:(%eax), %esp 397; X86-Darwin-NEXT: jbe LBB3_1 398 399; X86-Darwin: pushl $0 400; X86-Darwin-NEXT: pushl $60 401; X86-Darwin-NEXT: calll ___morestack 402; X86-Darwin-NEXT: ret 403 404; X64-Darwin-LABEL: test_fastcc: 405 406; X64-Darwin: cmpq %gs:816, %rsp 407; X64-Darwin-NEXT: jbe LBB3_1 408 409; X64-Darwin: movabsq $40, %r10 410; X64-Darwin-NEXT: movabsq $0, %r11 411; X64-Darwin-NEXT: callq ___morestack 412; X64-Darwin-NEXT: ret 413 414; X86-MinGW-LABEL: test_fastcc: 415 416; X86-MinGW: cmpl %fs:20, %esp 417; X86-MinGW-NEXT: jbe LBB3_1 418 419; X86-MinGW: pushl $0 420; X86-MinGW-NEXT: pushl $40 421; X86-MinGW-NEXT: calll ___morestack 422; X86-MinGW-NEXT: ret 423 424; X64-MinGW-LABEL: test_fastcc: 425 426; X64-MinGW: cmpq %gs:40, %rsp 427; X64-MinGW-NEXT: jbe .LBB3_1 428 429; X64-MinGW: movabsq $72, %r10 430; X64-MinGW-NEXT: movabsq $32, %r11 431; X64-MinGW-NEXT: callq __morestack 432; X64-MinGW-NEXT: retq 433 434; X64-FreeBSD-LABEL: test_fastcc: 435 436; X64-FreeBSD: cmpq %fs:24, %rsp 437; X64-FreeBSD-NEXT: jbe .LBB3_1 438 439; X64-FreeBSD: movabsq $40, %r10 440; X64-FreeBSD-NEXT: movabsq $0, %r11 441; X64-FreeBSD-NEXT: callq __morestack 442; X64-FreeBSD-NEXT: ret 443 444; X86-DFlyBSD-LABEL: test_fastcc: 445 446; X86-DFlyBSD: cmpl %fs:16, %esp 447; X86-DFlyBSD-NEXT: jbe .LBB3_1 448 449; X86-DFlyBSD: pushl $0 450; X86-DFlyBSD-NEXT: pushl $40 451; X86-DFlyBSD-NEXT: calll __morestack 452; X86-DFlyBSD-NEXT: ret 453 454; X64-DFlyBSD-LABEL: test_fastcc: 455 456; X64-DFlyBSD: cmpq %fs:32, %rsp 457; X64-DFlyBSD-NEXT: jbe .LBB3_1 458 459; X64-DFlyBSD: movabsq $40, %r10 460; X64-DFlyBSD-NEXT: movabsq $0, %r11 461; X64-DFlyBSD-NEXT: callq __morestack 462; X64-DFlyBSD-NEXT: ret 463 464} 465 466define fastcc void @test_fastcc_large() #0 { 467 %mem = alloca i32, i32 10000 468 call void @dummy_use (i32* %mem, i32 3) 469 ret void 470 471; X86-Linux-LABEL: test_fastcc_large: 472 473; X86-Linux: leal -40012(%esp), %eax 474; X86-Linux-NEXT: cmpl %gs:48, %eax 475; X86-Linux-NEXT: jbe .LBB4_1 476 477; X86-Linux: pushl $0 478; X86-Linux-NEXT: pushl $40012 479; X86-Linux-NEXT: calll __morestack 480; X86-Linux-NEXT: ret 481 482; X64-Linux-LABEL: test_fastcc_large: 483 484; X64-Linux: leaq -40008(%rsp), %r11 485; X64-Linux-NEXT: cmpq %fs:112, %r11 486; X64-Linux-NEXT: jbe .LBB4_1 487 488; X64-Linux: movabsq $40008, %r10 489; X64-Linux-NEXT: movabsq $0, %r11 490; X64-Linux-NEXT: callq __morestack 491; X64-Linux-NEXT: ret 492 493; X32ABI-LABEL: test_fastcc_large: 494 495; X32ABI: leal -40008(%rsp), %r11d 496; X32ABI-NEXT: cmpl %fs:64, %r11d 497; X32ABI-NEXT: jbe .LBB4_1 498 499; X32ABI: movl $40008, %r10d 500; X32ABI-NEXT: movl $0, %r11d 501; X32ABI-NEXT: callq __morestack 502; X32ABI-NEXT: ret 503 504; X86-Darwin-LABEL: test_fastcc_large: 505 506; X86-Darwin: leal -40012(%esp), %eax 507; X86-Darwin-NEXT: movl $432, %ecx 508; X86-Darwin-NEXT: cmpl %gs:(%ecx), %eax 509; X86-Darwin-NEXT: jbe LBB4_1 510 511; X86-Darwin: pushl $0 512; X86-Darwin-NEXT: pushl $40012 513; X86-Darwin-NEXT: calll ___morestack 514; X86-Darwin-NEXT: ret 515 516; X64-Darwin-LABEL: test_fastcc_large: 517 518; X64-Darwin: leaq -40008(%rsp), %r11 519; X64-Darwin-NEXT: cmpq %gs:816, %r11 520; X64-Darwin-NEXT: jbe LBB4_1 521 522; X64-Darwin: movabsq $40008, %r10 523; X64-Darwin-NEXT: movabsq $0, %r11 524; X64-Darwin-NEXT: callq ___morestack 525; X64-Darwin-NEXT: ret 526 527; X86-MinGW-LABEL: test_fastcc_large: 528 529; X86-MinGW: leal -40000(%esp), %eax 530; X86-MinGW-NEXT: cmpl %fs:20, %eax 531; X86-MinGW-NEXT: jbe LBB4_1 532 533; X86-MinGW: pushl $0 534; X86-MinGW-NEXT: pushl $40000 535; X86-MinGW-NEXT: calll ___morestack 536; X86-MinGW-NEXT: ret 537 538; X64-MinGW-LABEL: test_fastcc_large: 539 540; X64-MinGW: leaq -40040(%rsp), %r11 541; X64-MinGW-NEXT: cmpq %gs:40, %r11 542; X64-MinGW-NEXT: jbe .LBB4_1 543 544; X64-MinGW: movabsq $40040, %r10 545; X64-MinGW-NEXT: movabsq $32, %r11 546; X64-MinGW-NEXT: callq __morestack 547; X64-MinGW-NEXT: retq 548 549; X64-FreeBSD-LABEL: test_fastcc_large: 550 551; X64-FreeBSD: leaq -40008(%rsp), %r11 552; X64-FreeBSD-NEXT: cmpq %fs:24, %r11 553; X64-FreeBSD-NEXT: jbe .LBB4_1 554 555; X64-FreeBSD: movabsq $40008, %r10 556; X64-FreeBSD-NEXT: movabsq $0, %r11 557; X64-FreeBSD-NEXT: callq __morestack 558; X64-FreeBSD-NEXT: ret 559 560; X86-DFlyBSD-LABEL: test_fastcc_large: 561 562; X86-DFlyBSD: leal -40000(%esp), %eax 563; X86-DFlyBSD-NEXT: cmpl %fs:16, %eax 564; X86-DFlyBSD-NEXT: jbe .LBB4_1 565 566; X86-DFlyBSD: pushl $0 567; X86-DFlyBSD-NEXT: pushl $40000 568; X86-DFlyBSD-NEXT: calll __morestack 569; X86-DFlyBSD-NEXT: ret 570 571; X64-DFlyBSD-LABEL: test_fastcc_large: 572 573; X64-DFlyBSD: leaq -40008(%rsp), %r11 574; X64-DFlyBSD-NEXT: cmpq %fs:32, %r11 575; X64-DFlyBSD-NEXT: jbe .LBB4_1 576 577; X64-DFlyBSD: movabsq $40008, %r10 578; X64-DFlyBSD-NEXT: movabsq $0, %r11 579; X64-DFlyBSD-NEXT: callq __morestack 580; X64-DFlyBSD-NEXT: ret 581 582} 583 584define fastcc void @test_fastcc_large_with_ecx_arg(i32 %a) #0 { 585 %mem = alloca i32, i32 10000 586 call void @dummy_use (i32* %mem, i32 %a) 587 ret void 588 589; This is testing that the Mac implementation preserves ecx 590 591; X86-Darwin-LABEL: test_fastcc_large_with_ecx_arg: 592 593; X86-Darwin: leal -40012(%esp), %eax 594; X86-Darwin-NEXT: pushl %ecx 595; X86-Darwin-NEXT: movl $432, %ecx 596; X86-Darwin-NEXT: cmpl %gs:(%ecx), %eax 597; X86-Darwin-NEXT: popl %ecx 598; X86-Darwin-NEXT: jbe LBB5_1 599 600; X86-Darwin: pushl $0 601; X86-Darwin-NEXT: pushl $40012 602; X86-Darwin-NEXT: calll ___morestack 603; X86-Darwin-NEXT: ret 604 605} 606 607define void @test_nostack() #0 { 608 ret void 609 610; X86-Linux-LABEL: test_nostack: 611; X86-Linux-NOT: calll __morestack 612 613; X64-Linux-LABEL: test_nostack: 614; X64-Linux-NOT: callq __morestack 615 616; X32ABI-LABEL: test_nostack: 617; X32ABI-NOT: callq __morestack 618 619; X86-Darwin-LABEL: test_nostack: 620; X86-Darwin-NOT: calll __morestack 621 622; X64-Darwin-LABEL: test_nostack: 623; X64-Darwin-NOT: callq __morestack 624 625; X86-MinGW-LABEL: test_nostack: 626; X86-MinGW-NOT: calll __morestack 627 628; X64-MinGW-LABEL: test_nostack: 629; X64-MinGW-NOT: callq __morestack 630 631; X64-FreeBSD-LABEL: test_nostack: 632; X64-FreeBSD-NOT: callq __morestack 633 634; X86-DFlyBSD-LABEL: test_nostack: 635; X86-DFlyBSD-NOT: calll __morestack 636 637; X64-DFlyBSD-LABEL: test_nostack: 638; X64-DFlyBSD-NOT: callq __morestack 639} 640 641define void @test_nosplitstck() { 642 ret void 643} 644 645; Test to make sure that a morestack call is generated if there is a 646; sibling call, even if the function in question has no stack frame 647; (PR37807). 648 649declare i32 @callee(i32) 650 651define i32 @test_sibling_call_empty_frame(i32 %x) #0 { 652 %call = tail call i32 @callee(i32 %x) #0 653 ret i32 %call 654 655; X86-Linux-LABEL: test_sibling_call_empty_frame: 656; X86-Linux: calll __morestack 657 658; X64-Linux-LABEL: test_sibling_call_empty_frame: 659; X64-Linux: callq __morestack 660 661; X64-Linux-Large-LABEL: test_sibling_call_empty_frame: 662; X64-Linux-Large: callq *__morestack_addr(%rip) 663 664; X32ABI-LABEL: test_sibling_call_empty_frame: 665; X32ABI: callq __morestack 666 667; X86-Darwin-LABEL: test_sibling_call_empty_frame: 668; X86-Darwin: calll ___morestack 669 670; X64-Darwin-LABEL: test_sibling_call_empty_frame: 671; X64-Darwin: callq ___morestack 672 673; X86-MinGW-LABEL: test_sibling_call_empty_frame: 674; X86-MinGW: calll ___morestack 675 676; X64-MinGW-LABEL: test_sibling_call_empty_frame: 677; X64-MinGW: callq __morestack 678 679; X64-FreeBSD-LABEL: test_sibling_call_empty_frame: 680; X64-FreeBSD: callq __morestack 681 682; X86-DFlyBSD-LABEL: test_sibling_call_empty_frame: 683; X86-DFlyBSD: calll __morestack 684; X86-DFlyBSD-NEXT: ret 685 686; X64-DFlyBSD-LABEL: test_sibling_call_empty_frame: 687; X64-DFlyBSD: callq __morestack 688 689} 690 691; Test that unused nested argument doesn't need saving/restoring. 692 693define i32 @test_nested_unused(i32 * nest %unused) #0 { 694 %mem = alloca i32, i32 10 695 call void @dummy_use (i32* %mem, i32 10) 696 ret i32 123 697 698; X64-Linux-LABEL: test_nested_unused: 699; X64-Linux-NOT: movq %r10, %rax 700; X64-Linux: callq __morestack 701; X64-Linux-NOT: movq %rax, %r10 702 703; X64-Darwin-LABEL: test_nested_unused: 704; X64-Darwin-NOT: movq %r10, %rax 705; X64-Darwin: callq ___morestack 706; X64-Darwin-NOT: movq %rax, %r10 707 708; X64-FreeBSD-LABEL: test_nested_unused: 709; X64-FreeBSD-NOT: movq %r10, %rax 710; X64-FreeBSD: callq __morestack 711; X64-FreeBSD-NOT: movq %rax, %r10 712 713; X64-DFlyBSD-LABEL: test_nested_unused: 714; X64-DFlyBSD-NOT: movq %r10, %rax 715; X64-DFlyBSD: callq __morestack 716; X64-DFlyBSD-NOT: movq %rax, %r10 717 718; X64-MinGW-LABEL: test_nested_unused: 719; X64-MinGW-NOT: movq %r10, %rax 720; X64-MinGW: callq __morestack 721; X64-MinGW-NOT: movq %rax, %r10 722 723; X32ABI-LABEL: test_nested_unused: 724; X32ABI-NOT: movl %r10d, %eax 725; X32ABI: callq __morestack 726; X32ABI-NOT: movq %rax, %r10 727 728} 729 730attributes #0 = { "split-stack" } 731 732; X64-Linux-Large: .rodata 733; X64-Linux-Large-NEXT: __morestack_addr: 734; X64-Linux-Large-NEXT: .quad __morestack 735 736; X86-Linux: .section ".note.GNU-split-stack","",@progbits 737; X86-Linux: .section ".note.GNU-no-split-stack","",@progbits 738 739; X64-Linux: .section ".note.GNU-split-stack","",@progbits 740; X64-Linux: .section ".note.GNU-no-split-stack","",@progbits 741 742; X64-FreeBSD: .section ".note.GNU-split-stack","",@progbits 743; X64-FreeBSD: .section ".note.GNU-no-split-stack","",@progbits 744 745; X86-DFlyBSD: .section ".note.GNU-split-stack","",@progbits 746; X86-DFlyBSD: .section ".note.GNU-no-split-stack","",@progbits 747 748; X64-DFlyBSD: .section ".note.GNU-split-stack","",@progbits 749; X64-DFlyBSD: .section ".note.GNU-no-split-stack","",@progbits 750