summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-03-04 01:40:40 +0000
committerMatthias Braun <matze@braunis.de>2017-03-04 01:40:40 +0000
commit21f340fd2550e2407fdd80ed533bf69b2ad1d3dd (patch)
tree410c568508b803e00fd76dd922d4b808cd96a8ca /llvm/lib
parentf0bb90b126de850f21655c6a175b2a58ca6c7e1a (diff)
downloadbcm5719-llvm-21f340fd2550e2407fdd80ed533bf69b2ad1d3dd.tar.gz
bcm5719-llvm-21f340fd2550e2407fdd80ed533bf69b2ad1d3dd.zip
X86ISelLowering: Only perform copy elision on legal types.
This fixes cases where i1 types were not properly legalized yet and lead to the creating of 0-sized stack slots. This fixes http://llvm.org/PR32136 llvm-svn: 296950
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp70
1 files changed, 37 insertions, 33 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 317edc419e7..3993e47a051 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2736,40 +2736,44 @@ X86TargetLowering::LowerMemArgument(SDValue Chain, CallingConv::ID CallConv,
// This is an argument in memory. We might be able to perform copy elision.
if (Flags.isCopyElisionCandidate()) {
EVT ArgVT = Ins[i].ArgVT;
- SDValue PartAddr;
- if (Ins[i].PartOffset == 0) {
- // If this is a one-part value or the first part of a multi-part value,
- // create a stack object for the entire argument value type and return a
- // load from our portion of it. This assumes that if the first part of an
- // argument is in memory, the rest will also be in memory.
- int FI = MFI.CreateFixedObject(ArgVT.getSizeInBits() / 8,
- VA.getLocMemOffset(), /*Immutable=*/false);
- PartAddr = DAG.getFrameIndex(FI, PtrVT);
- return DAG.getLoad(
- ValVT, dl, Chain, PartAddr,
- MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI));
- } else {
- // This is not the first piece of an argument in memory. See if there is
- // already a fixed stack object including this offset. If so, assume it
- // was created by the PartOffset == 0 branch above and create a load from
- // the appropriate offset into it.
- int64_t PartBegin = VA.getLocMemOffset();
- int64_t PartEnd = PartBegin + ValVT.getSizeInBits() / 8;
- int FI = MFI.getObjectIndexBegin();
- for (; MFI.isFixedObjectIndex(FI); ++FI) {
- int64_t ObjBegin = MFI.getObjectOffset(FI);
- int64_t ObjEnd = ObjBegin + MFI.getObjectSize(FI);
- if (ObjBegin <= PartBegin && PartEnd <= ObjEnd)
- break;
- }
- if (MFI.isFixedObjectIndex(FI)) {
- SDValue Addr =
- DAG.getNode(ISD::ADD, dl, PtrVT, DAG.getFrameIndex(FI, PtrVT),
- DAG.getIntPtrConstant(Ins[i].PartOffset, dl));
+ if (isTypeLegal(ArgVT)) {
+ SDValue PartAddr;
+ if (Ins[i].PartOffset == 0) {
+ // If this is a one-part value or the first part of a multi-part value,
+ // create a stack object for the entire argument value type and return a
+ // load from our portion of it. This assumes that if the first part of
+ // an argument is in memory, the rest will also be in memory.
+ unsigned SizeInBits = ArgVT.getSizeInBits();
+ assert(SizeInBits % 8 == 0);
+ int FI = MFI.CreateFixedObject(SizeInBits / 8, VA.getLocMemOffset(),
+ /*Immutable=*/false);
+ PartAddr = DAG.getFrameIndex(FI, PtrVT);
return DAG.getLoad(
- ValVT, dl, Chain, Addr,
- MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI,
- Ins[i].PartOffset));
+ ValVT, dl, Chain, PartAddr,
+ MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI));
+ } else {
+ // This is not the first piece of an argument in memory. See if there is
+ // already a fixed stack object including this offset. If so, assume it
+ // was created by the PartOffset == 0 branch above and create a load
+ // from the appropriate offset into it.
+ int64_t PartBegin = VA.getLocMemOffset();
+ int64_t PartEnd = PartBegin + ValVT.getSizeInBits() / 8;
+ int FI = MFI.getObjectIndexBegin();
+ for (; MFI.isFixedObjectIndex(FI); ++FI) {
+ int64_t ObjBegin = MFI.getObjectOffset(FI);
+ int64_t ObjEnd = ObjBegin + MFI.getObjectSize(FI);
+ if (ObjBegin <= PartBegin && PartEnd <= ObjEnd)
+ break;
+ }
+ if (MFI.isFixedObjectIndex(FI)) {
+ SDValue Addr =
+ DAG.getNode(ISD::ADD, dl, PtrVT, DAG.getFrameIndex(FI, PtrVT),
+ DAG.getIntPtrConstant(Ins[i].PartOffset, dl));
+ return DAG.getLoad(
+ ValVT, dl, Chain, Addr,
+ MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI,
+ Ins[i].PartOffset));
+ }
}
}
}
OpenPOWER on IntegriCloud