brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 35fc13b Raw
137 lines · plain
1; RUN: llc < %s -mtriple=x86_64-pc-win32-coreclr -verify-machineinstrs | FileCheck %s -check-prefix=WIN_X642; RUN: llc < %s -mtriple=x86_64-pc-linux         | FileCheck %s -check-prefix=LINUX3 4; By default, windows CoreCLR requires an inline prologue stack expansion check5; if more than 4096 bytes are allocated on the stack.6 7; Prolog stack allocation >= 4096 bytes will require the probe sequence8define i32 @main4k() nounwind {9entry:10; WIN_X64-LABEL:main4k:11; WIN_X64: # %bb.0:12; WIN_X64:      movl    $4096, %eax13; WIN_X64:	xorq	%rcx, %rcx14; WIN_X64:	movq	%rsp, %rdx15; WIN_X64:	subq	%rax, %rdx16; WIN_X64:	cmovbq	%rcx, %rdx17; WIN_X64:	movq	%gs:16, %rcx18; WIN_X64:	cmpq	%rcx, %rdx19; WIN_X64:	jae	.LBB0_320; WIN_X64:# %bb.1:21; WIN_X64:	andq	$-4096, %rdx22; WIN_X64:.LBB0_2:23; WIN_X64:	addq	$-4096, %rcx24; WIN_X64:	movb	$0, (%rcx)25; WIN_X64:	cmpq	%rcx, %rdx26; WIN_X64:	jne	.LBB0_227; WIN_X64:.LBB0_3:28; WIN_X64:	subq	%rax, %rsp29; WIN_X64:	xorl	%eax, %eax30; WIN_X64:	addq	$4096, %rsp31; WIN_X64:	retq32; LINUX-LABEL:main4k:33; LINUX-NOT:    movq    %gs:16, %rcx34; LINUX: 	retq35  %a = alloca [4096 x i8]36  ret i32 037}38 39; Prolog stack allocation >= 4096 bytes will require the probe sequence40; Case with frame pointer41define i32 @main4k_frame() nounwind "frame-pointer"="all" {42entry:43; WIN_X64-LABEL:main4k_frame:44; WIN_X64:      movq    %gs:16, %rcx45; LINUX-LABEL:main4k_frame:46; LINUX-NOT:    movq    %gs:16, %rcx47; LINUX: 	retq48  %a = alloca [4096 x i8]49  ret i32 050}51 52; Prolog stack allocation >= 4096 bytes will require the probe sequence53; Case with INT args54define i32 @main4k_intargs(i32 %x, i32 %y) nounwind {55entry:56; WIN_X64:      movq    %gs:16, %rcx57; LINUX-NOT:    movq    %gs:16, %rcx58; LINUX: 	retq59  %a = alloca [4096 x i8]60  %t = add i32 %x, %y61  ret i32 %t62}63 64; Prolog stack allocation >= 4096 bytes will require the probe sequence65; Case with FP regs66define i32 @main4k_fpargs(double %x, double %y) nounwind {67entry:68; WIN_X64:      movq    %gs:16, %rcx69; LINUX-NOT:    movq    %gs:16, %rcx70; LINUX: 	retq71  %a = alloca [4096 x i8]72  ret i32 073}74 75; Prolog stack allocation >= 4096 bytes will require the probe sequence76; Case with mixed regs77define i32 @main4k_mixargs(double %x, i32 %y) nounwind {78entry:79; WIN_X64:      movq    %gs:16, %rcx80; LINUX-NOT:    movq    %gs:16, %rcx81; LINUX: 	retq82  %a = alloca [4096 x i8]83  ret i32 %y84}85 86; Make sure we don't emit the probe for a smaller prolog stack allocation.87define i32 @main128() nounwind {88entry:89; WIN_X64-NOT:  movq    %gs:16, %rcx90; WIN_X64:      retq91; LINUX-NOT:    movq    %gs:16, %rcx92; LINUX: 	retq93  %a = alloca [128 x i8]94  ret i32 095}96 97; Make sure we don't emit the probe sequence if not on windows even if the98; caller has the Win64 calling convention.99define win64cc i32 @main4k_win64() nounwind {100entry:101; WIN_X64:      movq    %gs:16, %rcx102; LINUX-NOT:    movq    %gs:16, %rcx103; LINUX: 	retq104  %a = alloca [4096 x i8]105  ret i32 0106}107 108declare i32 @bar(ptr) nounwind109 110; Within-body inline probe expansion111define win64cc i32 @main4k_alloca(i64 %n) nounwind {112entry:113; WIN_X64: 	callq	bar114; WIN_X64:  	movq	%gs:16, [[R:%r.*]]115; WIN_X64: 	callq	bar116; LINUX: 	callq	bar117; LINUX-NOT:  	movq	%gs:16, [[R:%r.*]]118; LINUX: 	callq	bar119  %a = alloca i8, i64 1024120  %ra = call i32 @bar(ptr %a) nounwind121  %b = alloca i8, i64 %n122  %rb = call i32 @bar(ptr %b) nounwind123  %r = add i32 %ra, %rb124  ret i32 %r125}126 127; Influence of stack-probe-size attribute128; Note this is not exposed in coreclr129define i32 @test_probe_size() "stack-probe-size"="8192" nounwind {130; WIN_X64-NOT:  movq    %gs:16, %rcx131; WIN_X64: 	retq132; LINUX-NOT:    movq    %gs:16, %rcx133; LINUX: 	retq134  %a = alloca [4096 x i8]135  ret i32 0136}137