aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Mips
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2011-11-15 18:42:25 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2011-11-15 18:42:25 +0000
commit160408546cce8243ea5d8e2e447eeafcf94539af (patch)
tree9fcd64c9b34147de9087557f36d4d349b8e0ee46 /lib/Target/Mips
parent00e1fa499d73d4674e50de313199877512caaf10 (diff)
downloadexternal_llvm-160408546cce8243ea5d8e2e447eeafcf94539af.zip
external_llvm-160408546cce8243ea5d8e2e447eeafcf94539af.tar.gz
external_llvm-160408546cce8243ea5d8e2e447eeafcf94539af.tar.bz2
Simplify function PassByValArg64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144664 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips')
-rw-r--r--lib/Target/Mips/MipsISelLowering.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/Target/Mips/MipsISelLowering.cpp b/lib/Target/Mips/MipsISelLowering.cpp
index b595f03..23592fd 100644
--- a/lib/Target/Mips/MipsISelLowering.cpp
+++ b/lib/Target/Mips/MipsISelLowering.cpp
@@ -2063,6 +2063,7 @@ PassByValArg64(SDValue& ByValChain, SDValue Chain, DebugLoc dl,
bool IsRegLoc = VA.isRegLoc();
unsigned Offset = 0; // Offset in # of bytes from the beginning of struct.
unsigned LocMemOffset = 0;
+ unsigned MemCpySize = ByValSize;
if (!IsRegLoc)
LocMemOffset = VA.getLocMemOffset();
@@ -2082,9 +2083,13 @@ PassByValArg64(SDValue& ByValChain, SDValue Chain, DebugLoc dl,
RegsToPass.push_back(std::make_pair(*Reg, LoadVal));
}
+ // Return if the struct has been fully copied.
+ if (!(MemCpySize = ByValSize - Offset))
+ return;
+
// If there is an argument register available, copy the remainder of the
// byval argument with sub-doubleword loads and shifts.
- if ((Reg != RegEnd) && (ByValSize != Offset)) {
+ if (Reg != RegEnd) {
assert((ByValSize < Offset + 8) &&
"Size of the remainder should be smaller than 8-byte.");
SDValue Val;
@@ -2119,19 +2124,18 @@ PassByValArg64(SDValue& ByValChain, SDValue Chain, DebugLoc dl,
}
}
- unsigned MemCpySize = ByValSize - Offset;
- if (MemCpySize) {
- // Create a fixed object on stack at offset LocMemOffset and copy
- // remainder of byval arg to it with memcpy.
- SDValue Src = DAG.getNode(ISD::ADD, dl, PtrTy, Arg,
- DAG.getConstant(Offset, PtrTy));
- LastFI = MFI->CreateFixedObject(MemCpySize, LocMemOffset, true);
- SDValue Dst = DAG.getFrameIndex(LastFI, PtrTy);
- ByValChain = DAG.getMemcpy(ByValChain, dl, Dst, Src,
- DAG.getConstant(MemCpySize, PtrTy), Alignment,
- /*isVolatile=*/false, /*AlwaysInline=*/false,
- MachinePointerInfo(0), MachinePointerInfo(0));
- }
+ assert(MemCpySize && "MemCpySize must not be zero.");
+
+ // Create a fixed object on stack at offset LocMemOffset and copy
+ // remainder of byval arg to it with memcpy.
+ SDValue Src = DAG.getNode(ISD::ADD, dl, PtrTy, Arg,
+ DAG.getConstant(Offset, PtrTy));
+ LastFI = MFI->CreateFixedObject(MemCpySize, LocMemOffset, true);
+ SDValue Dst = DAG.getFrameIndex(LastFI, PtrTy);
+ ByValChain = DAG.getMemcpy(ByValChain, dl, Dst, Src,
+ DAG.getConstant(MemCpySize, PtrTy), Alignment,
+ /*isVolatile=*/false, /*AlwaysInline=*/false,
+ MachinePointerInfo(0), MachinePointerInfo(0));
}
/// LowerCall - functions arguments are copied from virtual regs to