diff options
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/cleanuppad-inalloca.ll | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/dynamic-alloca-in-entry.ll | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/inalloca-ctor.ll | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/inalloca-invoke.ll | 3 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/inalloca-stdcall.ll | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/inalloca.ll | 12 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/shrink-wrap-chkstk.ll | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/win-alloca-expander.ll | 153 |
8 files changed, 170 insertions, 16 deletions
diff --git a/llvm/test/CodeGen/X86/cleanuppad-inalloca.ll b/llvm/test/CodeGen/X86/cleanuppad-inalloca.ll index 2e34ada52e6..c0660fee2f1 100644 --- a/llvm/test/CodeGen/X86/cleanuppad-inalloca.ll +++ b/llvm/test/CodeGen/X86/cleanuppad-inalloca.ll @@ -38,8 +38,8 @@ ehcleanup: ; preds = %entry ; CHECK: pushl %ebp ; CHECK: movl %esp, %ebp ; CHECK: subl ${{[0-9]+}}, %esp -; CHECK: movl $8, %eax -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: pushl %eax ; CHECK: calll "??0A@@QAE@XZ" ; CHECK: calll "??0A@@QAE@XZ" ; CHECK: calll _takes_two diff --git a/llvm/test/CodeGen/X86/dynamic-alloca-in-entry.ll b/llvm/test/CodeGen/X86/dynamic-alloca-in-entry.ll index 7ed471c2f50..2b5721d7fcf 100644 --- a/llvm/test/CodeGen/X86/dynamic-alloca-in-entry.ll +++ b/llvm/test/CodeGen/X86/dynamic-alloca-in-entry.ll @@ -15,5 +15,5 @@ define void @bar() { ret void } ; CHECK-LABEL: _bar: -; CHECK: calll __chkstk +; CHECK: pushl %eax ; CHECK: retl diff --git a/llvm/test/CodeGen/X86/inalloca-ctor.ll b/llvm/test/CodeGen/X86/inalloca-ctor.ll index eba4e72f933..f13d537d90b 100644 --- a/llvm/test/CodeGen/X86/inalloca-ctor.ll +++ b/llvm/test/CodeGen/X86/inalloca-ctor.ll @@ -12,8 +12,8 @@ define void @g() { entry: %args = alloca inalloca %frame %c = getelementptr %frame, %frame* %args, i32 0, i32 2 -; CHECK: movl $20, %eax -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: subl $16, %esp ; CHECK: movl %esp, call void @Foo_ctor(%Foo* %c) ; CHECK: leal 12(%{{.*}}), diff --git a/llvm/test/CodeGen/X86/inalloca-invoke.ll b/llvm/test/CodeGen/X86/inalloca-invoke.ll index 9a184e563b1..d90e5012ba4 100644 --- a/llvm/test/CodeGen/X86/inalloca-invoke.ll +++ b/llvm/test/CodeGen/X86/inalloca-invoke.ll @@ -21,7 +21,8 @@ blah: %beg = getelementptr %frame.reverse, %frame.reverse* %rev_args, i32 0, i32 0 %end = getelementptr %frame.reverse, %frame.reverse* %rev_args, i32 0, i32 1 -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: subl $20, %esp ; CHECK: movl %esp, %[[beg:[^ ]*]] ; CHECK: leal 12(%[[beg]]), %[[end:[^ ]*]] diff --git a/llvm/test/CodeGen/X86/inalloca-stdcall.ll b/llvm/test/CodeGen/X86/inalloca-stdcall.ll index 4f7e4092a99..69d94d8bfa7 100644 --- a/llvm/test/CodeGen/X86/inalloca-stdcall.ll +++ b/llvm/test/CodeGen/X86/inalloca-stdcall.ll @@ -8,8 +8,8 @@ declare x86_stdcallcc void @i(i32 %a) define void @g() { ; CHECK-LABEL: _g: %b = alloca inalloca %Foo -; CHECK: movl $8, %eax -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: pushl %eax %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1 store i32 13, i32* %f1 diff --git a/llvm/test/CodeGen/X86/inalloca.ll b/llvm/test/CodeGen/X86/inalloca.ll index e523c945a69..134de2f58dd 100644 --- a/llvm/test/CodeGen/X86/inalloca.ll +++ b/llvm/test/CodeGen/X86/inalloca.ll @@ -8,8 +8,8 @@ define void @a() { ; CHECK-LABEL: _a: entry: %b = alloca inalloca %Foo -; CHECK: movl $8, %eax -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: pushl %eax %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1 store i32 13, i32* %f1 @@ -28,8 +28,8 @@ define void @b() { ; CHECK-LABEL: _b: entry: %b = alloca inalloca %Foo -; CHECK: movl $8, %eax -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: pushl %eax %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1 store i32 13, i32* %f1 @@ -49,8 +49,8 @@ define void @c() { ; CHECK-LABEL: _c: entry: %b = alloca inalloca %Foo -; CHECK: movl $8, %eax -; CHECK: calll __chkstk +; CHECK: pushl %eax +; CHECK: pushl %eax %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1 store i32 13, i32* %f1 diff --git a/llvm/test/CodeGen/X86/shrink-wrap-chkstk.ll b/llvm/test/CodeGen/X86/shrink-wrap-chkstk.ll index 94501b5764e..099ef137d8d 100644 --- a/llvm/test/CodeGen/X86/shrink-wrap-chkstk.ll +++ b/llvm/test/CodeGen/X86/shrink-wrap-chkstk.ll @@ -7,7 +7,7 @@ target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" target triple = "i686-pc-windows-msvc18.0.0" -%struct.S = type { [12 x i8] } +%struct.S = type { [8192 x i8] } define x86_thiscallcc void @call_inalloca(i1 %x) { entry: @@ -29,7 +29,7 @@ bb2: ; CHECK-LABEL: _call_inalloca: # @call_inalloca ; CHECK: pushl %ebp ; CHECK: movl %esp, %ebp -; CHECK: movl $12, %eax +; CHECK: movl $8192, %eax ; CHECK: calll __chkstk ; CHECK: calll _inalloca_params ; CHECK: movl %ebp, %esp diff --git a/llvm/test/CodeGen/X86/win-alloca-expander.ll b/llvm/test/CodeGen/X86/win-alloca-expander.ll new file mode 100644 index 00000000000..0dca72cae1a --- /dev/null +++ b/llvm/test/CodeGen/X86/win-alloca-expander.ll @@ -0,0 +1,153 @@ +; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s + +%struct.S = type { [1024 x i8] } +%struct.T = type { [3000 x i8] } +%struct.U = type { [10000 x i8] } + +define void @basics() { +; CHECK-LABEL: basics: +entry: + br label %bb1 + +; Allocation move sizes should have been removed. +; CHECK-NOT: movl $1024 +; CHECK-NOT: movl $3000 + +bb1: + %p0 = alloca %struct.S +; The allocation is small enough not to require stack probing, but the %esp +; offset after the prologue is not known, so the stack must be touched before +; the pointer is adjusted. +; CHECK: pushl %eax +; CHECK: subl $1020, %esp + + %saved_stack = tail call i8* @llvm.stacksave() + + %p1 = alloca %struct.S +; We know the %esp offset from above, so there is no need to touch the stack +; before adjusting it. +; CHECK: subl $1024, %esp + + %p2 = alloca %struct.T +; The offset is now 2048 bytes, so allocating a T must touch the stack again. +; CHECK: pushl %eax +; CHECK: subl $2996, %esp + + call void @f(%struct.S* %p0) +; CHECK: calll + + %p3 = alloca %struct.T +; The call above touched the stack, so there is room for a T object. +; CHECK: subl $3000, %esp + + %p4 = alloca %struct.U +; The U object is large enough to require stack probing. +; CHECK: movl $10000, %eax +; CHECK: calll __chkstk + + %p5 = alloca %struct.T +; The stack probing above touched the tip of the stack, so there's room for a T. +; CHECK: subl $3000, %esp + + call void @llvm.stackrestore(i8* %saved_stack) + %p6 = alloca %struct.S +; The stack restore means we lose track of the stack pointer and must probe. +; CHECK: pushl %eax +; CHECK: subl $1020, %esp + +; Use the pointers so they're not optimized away. + call void @f(%struct.S* %p1) + call void @g(%struct.T* %p2) + call void @g(%struct.T* %p3) + call void @h(%struct.U* %p4) + call void @g(%struct.T* %p5) + ret void +} + +define void @loop() { +; CHECK-LABEL: loop: +entry: + br label %bb1 + +bb1: + %p1 = alloca %struct.S +; The entry offset is unknown; touch-and-sub. +; CHECK: pushl %eax +; CHECK: subl $1020, %esp + br label %loop1 + +loop1: + %i1 = phi i32 [ 10, %bb1 ], [ %dec1, %loop1 ] + %p2 = alloca %struct.S +; We know the incoming offset from bb1, but from the back-edge, we assume the +; worst, and therefore touch-and-sub to allocate. +; CHECK: pushl %eax +; CHECK: subl $1020, %esp + %dec1 = sub i32 %i1, 1 + %cmp1 = icmp sgt i32 %i1, 0 + br i1 %cmp1, label %loop1, label %end +; CHECK: decl +; CHECK: jg + +end: + call void @f(%struct.S* %p1) + call void @f(%struct.S* %p2) + ret void +} + +define void @probe_size_attribute() "stack-probe-size"="512" { +; CHECK-LABEL: probe_size_attribute: +entry: + br label %bb1 + +bb1: + %p0 = alloca %struct.S +; The allocation would be small enough not to require probing, if it wasn't +; for the stack-probe-size attribute. +; CHECK: movl $1024, %eax +; CHECK: calll __chkstk + call void @f(%struct.S* %p0) + ret void +} + +define void @cfg(i1 %x, i1 %y) { +; Test that the blocks are analyzed in the correct order. +; CHECK-LABEL: cfg: +entry: + br i1 %x, label %bb1, label %bb2 + +bb1: + %p1 = alloca %struct.S +; CHECK: pushl %eax +; CHECK: subl $1020, %esp + br label %bb3 +bb2: + %p2 = alloca %struct.T +; CHECK: pushl %eax +; CHECK: subl $2996, %esp + br label %bb3 + +bb3: + br i1 %y, label %bb4, label %bb5 + +bb4: + %p4 = alloca %struct.S +; CHECK: subl $1024, %esp + call void @f(%struct.S* %p4) + ret void + +bb5: + %p5 = alloca %struct.T +; CHECK: pushl %eax +; CHECK: subl $2996, %esp + call void @g(%struct.T* %p5) + ret void +} + + +declare void @f(%struct.S*) +declare void @g(%struct.T*) +declare void @h(%struct.U*) + +declare i8* @llvm.stacksave() +declare void @llvm.stackrestore(i8*) |

