llvm-6502/test/CodeGen/X86/inalloca-invoke.ll
Reid Kleckner 8a24e83550 Implement inalloca codegen for x86 with the new inalloca design
Calls with inalloca are lowered by skipping all stores for arguments
passed in memory and the initial stack adjustment to allocate argument
memory.

Now the frontend is responsible for the memory layout, and the backend
doesn't have to do any work.  As a result these changes are pretty
minimal.

Reviewers: echristo

Differential Revision: http://llvm-reviews.chandlerc.com/D2637

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200596 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31 23:50:57 +00:00

55 lines
1.5 KiB
LLVM

; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s
%Iter = type { i32, i32, i32 }
%frame.reverse = type { %Iter, %Iter }
declare void @llvm.stackrestore(i8*)
declare i8* @llvm.stacksave()
declare void @begin(%Iter* sret)
declare void @plus(%Iter* sret, %Iter*, i32)
declare void @reverse(%frame.reverse* inalloca align 4)
define i32 @main() {
%temp.lvalue = alloca %Iter
br label %blah
blah:
%inalloca.save = call i8* @llvm.stacksave()
%rev_args = alloca %frame.reverse, inalloca, align 4
%beg = getelementptr %frame.reverse* %rev_args, i32 0, i32 0
%end = getelementptr %frame.reverse* %rev_args, i32 0, i32 1
; CHECK: calll __chkstk
; CHECK: movl %[[beg:[^,]*]], %esp
; CHECK: leal 12(%[[beg]]), %[[end:[^ ]*]]
call void @begin(%Iter* sret %temp.lvalue)
; CHECK: calll _begin
invoke void @plus(%Iter* sret %end, %Iter* %temp.lvalue, i32 4)
to label %invoke.cont unwind label %lpad
; Uses end as sret param.
; CHECK: movl %[[end]], (%esp)
; CHECK: calll _plus
invoke.cont:
call void @begin(%Iter* sret %beg)
; CHECK: movl %[[beg]],
; CHECK: calll _begin
invoke void @reverse(%frame.reverse* inalloca align 4 %rev_args)
to label %invoke.cont5 unwind label %lpad
invoke.cont5: ; preds = %invoke.cont
call void @llvm.stackrestore(i8* %inalloca.save)
ret i32 0
lpad: ; preds = %invoke.cont, %entry
%lp = landingpad { i8*, i32 } personality i8* null
cleanup
unreachable
}