summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86FastISel.cpp
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2013-03-28 21:30:04 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2013-03-28 21:30:04 +0000
commita2fd5fdd7ac37f1d0c4d9dd4bf927aaf3f1b6ee4 (patch)
tree24a92d9a532f83979bc47c89cfe4ed7ca8511c31 /llvm/lib/Target/X86/X86FastISel.cpp
parent07d06d7cf51b49edb05638a78c74d8f27f0d0b0f (diff)
downloadbcm5719-llvm-a2fd5fdd7ac37f1d0c4d9dd4bf927aaf3f1b6ee4.tar.gz
bcm5719-llvm-a2fd5fdd7ac37f1d0c4d9dd4bf927aaf3f1b6ee4.zip
Make Win32 put the SRet address into EAX, fixes PR15556
llvm-svn: 178291
Diffstat (limited to 'llvm/lib/Target/X86/X86FastISel.cpp')
-rw-r--r--llvm/lib/Target/X86/X86FastISel.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index 85155f55e0f..c5da0b9b164 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -816,14 +816,16 @@ bool X86FastISel::X86SelectRet(const Instruction *I) {
// The x86-64 ABI for returning structs by value requires that we copy
// the sret argument into %rax for the return. We saved the argument into
// a virtual register in the entry block, so now we copy the value out
- // and into %rax.
- if (Subtarget->is64Bit() && F.hasStructRetAttr()) {
+ // and into %rax. We also do the same with %eax for Win32.
+ if (F.hasStructRetAttr() &&
+ (Subtarget->is64Bit() || Subtarget->isTargetWindows())) {
unsigned Reg = X86MFInfo->getSRetReturnReg();
assert(Reg &&
"SRetReturnReg should have been set in LowerFormalArguments()!");
+ unsigned RetReg = Subtarget->is64Bit() ? X86::RAX : X86::EAX;
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
- X86::RAX).addReg(Reg);
- RetRegs.push_back(X86::RAX);
+ RetReg).addReg(Reg);
+ RetRegs.push_back(RetReg);
}
// Now emit the RET.
OpenPOWER on IntegriCloud