diff options
author | Mon P Wang <wangmp@apple.com> | 2008-07-02 17:07:12 +0000 |
---|---|---|
committer | Mon P Wang <wangmp@apple.com> | 2008-07-02 17:07:12 +0000 |
commit | bee98c66c0c3d1f43244cdf237e572a9df031e40 (patch) | |
tree | 60b7a784e42ba0fb9c700f9710d6e8baed919b52 /lib/CodeGen | |
parent | 349db1738d58d52cae2ab1e06cbd128dd9f0aab6 (diff) |
Fixed problem in EmitStackConvert where the source and target type
have different alignment by creating a stack slot with the max
alignment of source and target type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 24 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 7 |
2 files changed, 19 insertions, 12 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 78e640f46b..196b2fcfb4 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -4872,35 +4872,41 @@ SDOperand SelectionDAGLegalize::EmitStackConvert(SDOperand SrcOp, MVT SlotVT, MVT DestVT) { // Create the stack frame object. - SDOperand FIPtr = DAG.CreateStackTemporary(SlotVT); - + unsigned SrcAlign = TLI.getTargetData()->getPrefTypeAlignment( + SrcOp.getValueType().getTypeForMVT()); + SDOperand FIPtr = DAG.CreateStackTemporary(SlotVT, SrcAlign); + FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(FIPtr); int SPFI = StackPtrFI->getIndex(); - + unsigned SrcSize = SrcOp.getValueType().getSizeInBits(); unsigned SlotSize = SlotVT.getSizeInBits(); unsigned DestSize = DestVT.getSizeInBits(); + const Type* SlotTy = SlotVT.getTypeForMVT(); + unsigned SlotAlign = TLI.getTargetData()->getPrefTypeAlignment(SlotTy); // Emit a store to the stack slot. Use a truncstore if the input value is // later than DestVT. SDOperand Store; + if (SrcSize > SlotSize) Store = DAG.getTruncStore(DAG.getEntryNode(), SrcOp, FIPtr, - PseudoSourceValue::getFixedStack(), - SPFI, SlotVT); + PseudoSourceValue::getFixedStack(), SPFI, SlotVT, + false, SlotAlign); else { assert(SrcSize == SlotSize && "Invalid store"); Store = DAG.getStore(DAG.getEntryNode(), SrcOp, FIPtr, - PseudoSourceValue::getFixedStack(), - SPFI); + PseudoSourceValue::getFixedStack(), SPFI, + false, SlotAlign); } // Result is a load from the stack slot. if (SlotSize == DestSize) - return DAG.getLoad(DestVT, Store, FIPtr, NULL, 0); + return DAG.getLoad(DestVT, Store, FIPtr, NULL, 0, false, SlotAlign); assert(SlotSize < DestSize && "Unknown extension!"); - return DAG.getExtLoad(ISD::EXTLOAD, DestVT, Store, FIPtr, NULL, 0, SlotVT); + return DAG.getExtLoad(ISD::EXTLOAD, DestVT, Store, FIPtr, NULL, 0, SlotVT, + false, SlotAlign); } SDOperand SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index b22bf1dc62..e23e0459e8 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1080,16 +1080,17 @@ SDOperand SelectionDAG::getMemOperand(const MachineMemOperand &MO) { /// CreateStackTemporary - Create a stack temporary, suitable for holding the /// specified value type. -SDOperand SelectionDAG::CreateStackTemporary(MVT VT) { +SDOperand SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) { MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo(); unsigned ByteSize = VT.getSizeInBits()/8; const Type *Ty = VT.getTypeForMVT(); - unsigned StackAlign = (unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty); + unsigned StackAlign = + std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), minAlign); + int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign); return getFrameIndex(FrameIdx, TLI.getPointerTy()); } - SDOperand SelectionDAG::FoldSetCC(MVT VT, SDOperand N1, SDOperand N2, ISD::CondCode Cond) { // These setcc operations always fold. |