diff options
author | Dan Gohman <gohman@apple.com> | 2008-06-09 15:21:47 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-06-09 15:21:47 +0000 |
commit | 9115c7e89bca18364dba54ec8c7bba2da39b20d8 (patch) | |
tree | 817e8aacadb3276873991228326533d036d3c918 /lib | |
parent | 9fc6cb0724b58a47ffa68ac610b58a70cfd74ba9 (diff) | |
download | external_llvm-9115c7e89bca18364dba54ec8c7bba2da39b20d8.zip external_llvm-9115c7e89bca18364dba54ec8c7bba2da39b20d8.tar.gz external_llvm-9115c7e89bca18364dba54ec8c7bba2da39b20d8.tar.bz2 |
Handle empty aggregate values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 189a1f1..92eee9b 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -649,10 +649,6 @@ public: void setCurrentBasicBlock(MachineBasicBlock *MBB) { CurMBB = MBB; } - SDOperand getLoadFrom(const Type *Ty, SDOperand Ptr, - const Value *SV, SDOperand Root, - bool isVolatile, unsigned Alignment); - SDOperand getValue(const Value *V); void setValue(const Value *V, SDOperand NewN) { @@ -1169,6 +1165,8 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { assert((isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) && "Unknown array constant!"); unsigned NumElts = ATy->getNumElements(); + if (NumElts == 0) + return SDOperand(); // empty array MVT EltVT = TLI.getValueType(ATy->getElementType()); SmallVector<SDOperand, 4> Constants(NumElts); SmallVector<MVT, 4> ValueVTs(NumElts, EltVT); @@ -1189,6 +1187,8 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { assert((isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) && "Unknown struct constant!"); unsigned NumElts = STy->getNumElements(); + if (NumElts == 0) + return SDOperand(); // empty struct SmallVector<SDOperand, 4> Constants(NumElts); SmallVector<MVT, 4> ValueVTs(NumElts); for (unsigned i = 0, e = NumElts; i != e; ++i) { @@ -2850,7 +2850,19 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) { } void SelectionDAGLowering::visitLoad(LoadInst &I) { - SDOperand Ptr = getValue(I.getOperand(0)); + const Value *SV = I.getOperand(0); + SDOperand Ptr = getValue(SV); + + const Type *Ty = I.getType(); + bool isVolatile = I.isVolatile(); + unsigned Alignment = I.getAlignment(); + + SmallVector<MVT, 4> ValueVTs; + SmallVector<uint64_t, 4> Offsets; + ComputeValueVTs(TLI, Ty, ValueVTs, &Offsets); + unsigned NumValues = ValueVTs.size(); + if (NumValues == 0) + return; SDOperand Root; if (I.isVolatile()) @@ -2860,19 +2872,6 @@ void SelectionDAGLowering::visitLoad(LoadInst &I) { Root = DAG.getRoot(); } - setValue(&I, getLoadFrom(I.getType(), Ptr, I.getOperand(0), - Root, I.isVolatile(), I.getAlignment())); -} - -SDOperand SelectionDAGLowering::getLoadFrom(const Type *Ty, SDOperand Ptr, - const Value *SV, SDOperand Root, - bool isVolatile, - unsigned Alignment) { - SmallVector<MVT, 4> ValueVTs; - SmallVector<uint64_t, 4> Offsets; - ComputeValueVTs(TLI, Ty, ValueVTs, &Offsets); - unsigned NumValues = ValueVTs.size(); - SmallVector<SDOperand, 4> Values(NumValues); SmallVector<SDOperand, 4> Chains(NumValues); MVT PtrVT = Ptr.getValueType(); @@ -2893,9 +2892,9 @@ SDOperand SelectionDAGLowering::getLoadFrom(const Type *Ty, SDOperand Ptr, else PendingLoads.push_back(Chain); - return DAG.getNode(ISD::MERGE_VALUES, - DAG.getVTList(&ValueVTs[0], NumValues), - &Values[0], NumValues); + setValue(&I, DAG.getNode(ISD::MERGE_VALUES, + DAG.getVTList(&ValueVTs[0], NumValues), + &Values[0], NumValues)); } @@ -2909,6 +2908,8 @@ void SelectionDAGLowering::visitStore(StoreInst &I) { SmallVector<uint64_t, 4> Offsets; ComputeValueVTs(TLI, SrcV->getType(), ValueVTs, &Offsets); unsigned NumValues = ValueVTs.size(); + if (NumValues == 0) + return; SDOperand Root = getRoot(); SmallVector<SDOperand, 4> Chains(NumValues); |