diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-04-28 20:19:12 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-04-28 20:19:12 +0000 |
| commit | 7cd5101ad3dccbe406b69598ddf04129e801d292 (patch) | |
| tree | 6def4b7d1f71dfd485e815b2fa0fcc561ab78be1 /llvm | |
| parent | 101720fb58a133ced215b76909e8dc70212c70ec (diff) | |
| download | bcm5719-llvm-7cd5101ad3dccbe406b69598ddf04129e801d292.tar.gz bcm5719-llvm-7cd5101ad3dccbe406b69598ddf04129e801d292.zip | |
fast-isel sret calls, try 2. We actually do need to do something on x86-32. rdar://problem/9303592 .
llvm-svn: 130429
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/X86/X86FastISel.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/fast-isel-x86-64.ll | 13 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/fast-isel-x86.ll | 15 |
3 files changed, 32 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index 82ed9bad43b..1382f184c34 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -1618,7 +1618,6 @@ bool X86FastISel::X86SelectCall(const Instruction *I) { // FIXME: Only handle *easy* calls for now. if (CS.paramHasAttr(AttrInd, Attribute::InReg) || - CS.paramHasAttr(AttrInd, Attribute::StructRet) || CS.paramHasAttr(AttrInd, Attribute::Nest) || CS.paramHasAttr(AttrInd, Attribute::ByVal)) return false; @@ -1811,8 +1810,11 @@ bool X86FastISel::X86SelectCall(const Instruction *I) { // Issue CALLSEQ_END unsigned AdjStackUp = TM.getRegisterInfo()->getCallFrameDestroyOpcode(); + unsigned NumBytesCallee = 0; + if (!Subtarget->is64Bit() && CS.paramHasAttr(1, Attribute::StructRet)) + NumBytesCallee = 4; BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(AdjStackUp)) - .addImm(NumBytes).addImm(0); + .addImm(NumBytes).addImm(NumBytesCallee); // Now handle call return value (if any). SmallVector<unsigned, 4> UsedRegs; diff --git a/llvm/test/CodeGen/X86/fast-isel-x86-64.ll b/llvm/test/CodeGen/X86/fast-isel-x86-64.ll index a810af5c784..c4afc10ffab 100644 --- a/llvm/test/CodeGen/X86/fast-isel-x86-64.ll +++ b/llvm/test/CodeGen/X86/fast-isel-x86-64.ll @@ -239,6 +239,19 @@ define void @test19(double* %p1) { ; CHECK: pxor } +; Check that we fast-isel sret +%struct.a = type { i64, i64, i64 } +define void @test20() nounwind ssp { +entry: + %tmp = alloca %struct.a, align 8 + call void @test20sret(%struct.a* sret %tmp) + ret void +; CHECK: test20: +; CHECK: leaq (%rsp), %rdi +; CHECK: callq _test20sret +} +declare void @test20sret(%struct.a* sret) + ; Check that -0.0 is not materialized using pxor define void @test21(double* %p1) { store double -0.0, double* %p1 diff --git a/llvm/test/CodeGen/X86/fast-isel-x86.ll b/llvm/test/CodeGen/X86/fast-isel-x86.ll index fba96718ad5..19972f74b2b 100644 --- a/llvm/test/CodeGen/X86/fast-isel-x86.ll +++ b/llvm/test/CodeGen/X86/fast-isel-x86.ll @@ -31,3 +31,18 @@ define i32 @test2() nounwind { %t = load i32* @HHH ret i32 %t } + +; Check that we fast-isel sret, and handle the callee-pops behavior correctly. +%struct.a = type { i64, i64, i64 } +define void @test3() nounwind ssp { +entry: + %tmp = alloca %struct.a, align 8 + call void @test3sret(%struct.a* sret %tmp) + ret void +; CHECK: test3: +; CHECK: subl $44 +; CHECK: leal 16(%esp) +; CHECK: calll _test3sret +; CHECK: addl $40 +} +declare void @test3sret(%struct.a* sret) |

