diff options
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsISelLowering.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 33 | 
2 files changed, 23 insertions, 18 deletions
| diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index 7efd34db990..f3a6910fa3c 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -2660,20 +2660,22 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain,        InVals.push_back(Load);        OutChains.push_back(Load.getValue(1));      } +  } +  for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {      // The mips ABIs for returning structs by value requires that we copy      // the sret argument into $v0 for the return. Save the argument into      // a virtual register so that we can access it from the return points. -    if (Flags.isSRet()) { +    if (Ins[i].Flags.isSRet()) {        unsigned Reg = MipsFI->getSRetReturnReg();        if (!Reg) {          Reg = MF.getRegInfo().createVirtualRegister(              getRegClassFor(isN64() ? MVT::i64 : MVT::i32));          MipsFI->setSRetReturnReg(Reg);        } -      SDValue Copy = -          DAG.getCopyToReg(DAG.getEntryNode(), DL, Reg, InVals.back()); +      SDValue Copy = DAG.getCopyToReg(DAG.getEntryNode(), DL, Reg, InVals[i]);        Chain = DAG.getNode(ISD::TokenFactor, DL, MVT::Other, Copy, Chain); +      break;      }    } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 5cca93449bf..bae3e05d657 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -2299,23 +2299,26 @@ X86TargetLowering::LowerFormalArguments(SDValue Chain,                               MachinePointerInfo(), false, false, false, 0);      InVals.push_back(ArgValue); +  } -    // The x86-64 ABIs require that for returning structs by value we copy -    // the sret argument into %rax/%eax (depending on ABI) for the return. -    // Win32 requires us to put the sret argument to %eax as well. -    // Save the argument into a virtual register so that we can access it -    // from the return points. -    if (Ins[i].Flags.isSRet() && -        (Subtarget->is64Bit() || Subtarget->isTargetKnownWindowsMSVC())) { -      unsigned Reg = FuncInfo->getSRetReturnReg(); -      if (!Reg) { -        MVT PtrTy = getPointerTy(); -        Reg = MF.getRegInfo().createVirtualRegister(getRegClassFor(PtrTy)); -        FuncInfo->setSRetReturnReg(Reg); +  if (Subtarget->is64Bit() || Subtarget->isTargetKnownWindowsMSVC()) { +    for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { +      // The x86-64 ABIs require that for returning structs by value we copy +      // the sret argument into %rax/%eax (depending on ABI) for the return. +      // Win32 requires us to put the sret argument to %eax as well. +      // Save the argument into a virtual register so that we can access it +      // from the return points. +      if (Ins[i].Flags.isSRet()) { +        unsigned Reg = FuncInfo->getSRetReturnReg(); +        if (!Reg) { +          MVT PtrTy = getPointerTy(); +          Reg = MF.getRegInfo().createVirtualRegister(getRegClassFor(PtrTy)); +          FuncInfo->setSRetReturnReg(Reg); +        } +        SDValue Copy = DAG.getCopyToReg(DAG.getEntryNode(), dl, Reg, InVals[i]); +        Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Copy, Chain); +        break;        } -      SDValue Copy = -          DAG.getCopyToReg(DAG.getEntryNode(), dl, Reg, InVals.back()); -      Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Copy, Chain);      }    } | 

