summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@google.com>2012-04-30 16:57:15 +0000
committerDerek Schuff <dschuff@google.com>2012-04-30 16:57:15 +0000
commitb051adf26382d4169cc496a50da7c0a70cd71898 (patch)
tree085e3ad7fa6296f84c6f96a68ae8d42c16cb7efc /llvm
parent9245c936566d119c908cabdca16cd31b93da3ca3 (diff)
downloadbcm5719-llvm-b051adf26382d4169cc496a50da7c0a70cd71898.tar.gz
bcm5719-llvm-b051adf26382d4169cc496a50da7c0a70cd71898.zip
Fix fastcc structure return with fast-isel on x86-32
On x86-32, structure return via sret lets the callee pop the hidden pointer argument off the stack, which the caller then re-pushes. However if the calling convention is fastcc, then a register is used instead, and the caller should not adjust the stack. This is implemented with a check of IsTailCallConvention X86TargetLowering::LowerCall but is now checked properly in X86FastISel::DoSelectCall. (this time, actually commit what was reviewed!) llvm-svn: 155825
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/X86/X86FastISel.cpp2
-rw-r--r--llvm/test/CodeGen/X86/fast-isel-x86.ll14
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index eca0e780828..d757926c715 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -1858,6 +1858,8 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
unsigned AdjStackUp = TII.getCallFrameDestroyOpcode();
unsigned NumBytesCallee = 0;
if (!Subtarget->is64Bit() && !Subtarget->isTargetWindows() &&
+ !(CS.getCallingConv() == CallingConv::Fast ||
+ CS.getCallingConv() == CallingConv::GHC) &&
CS.paramHasAttr(1, Attribute::StructRet))
NumBytesCallee = 4;
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(AdjStackUp))
diff --git a/llvm/test/CodeGen/X86/fast-isel-x86.ll b/llvm/test/CodeGen/X86/fast-isel-x86.ll
index b9598bb465c..19f38882a6c 100644
--- a/llvm/test/CodeGen/X86/fast-isel-x86.ll
+++ b/llvm/test/CodeGen/X86/fast-isel-x86.ll
@@ -46,3 +46,17 @@ entry:
; CHECK: addl $40
}
declare void @test3sret(%struct.a* sret)
+
+; Check that fast-isel sret works with fastcc (and does not callee-pop)
+define void @test4() nounwind ssp {
+entry:
+ %tmp = alloca %struct.a, align 8
+ call fastcc void @test4fastccsret(%struct.a* sret %tmp)
+ ret void
+; CHECK: test4:
+; CHECK: subl $28
+; CHECK: leal (%esp), %ecx
+; CHECK: calll _test4fastccsret
+; CHECK addl $28
+}
+declare fastcc void @test4fastccsret(%struct.a* sret)
OpenPOWER on IntegriCloud