diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-11-06 09:00:38 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-11-06 09:00:38 +0000 |
commit | 3ee3e695562135b67405939c8ecadaaca794c5f7 (patch) | |
tree | 98361755dac65b720a13c65e8b88d320d9593bcf /llvm/lib/CodeGen | |
parent | c5455bcbd2457fe987fc7df66165de293a6629a2 (diff) | |
download | bcm5719-llvm-3ee3e695562135b67405939c8ecadaaca794c5f7.tar.gz bcm5719-llvm-3ee3e695562135b67405939c8ecadaaca794c5f7.zip |
Add the necessary support to the ISel to allow targets to codegen the new
alignment information appropriately. Includes code for PowerPC to support
fixed-size allocas with alignment larger than the stack. Support for
arbitrarily aligned dynamic allocas coming soon.
llvm-svn: 24224
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/PrologEpilogInserter.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 7 |
2 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index e38c740e8dd..95932207a58 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -258,6 +258,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { MachineFrameInfo *FFI = Fn.getFrameInfo(); unsigned StackAlignment = TFI.getStackAlignment(); + unsigned MaxAlign = StackAlignment; // Start at the beginning of the local area. // The Offset is the distance from the stack top in the direction @@ -295,9 +296,11 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { Offset += FFI->getObjectSize(i); unsigned Align = FFI->getObjectAlignment(i); - assert(Align <= StackAlignment && "Cannot align stack object to higher " - "alignment boundary than the stack itself!"); - Offset = (Offset+Align-1)/Align*Align; // Adjust to Alignment boundary... + // If the alignment of this object is greater than that of the stack, then + // increase the stack alignment to match. + MaxAlign = std::max(MaxAlign, Align); + // Adjust to alignment boundary + Offset = (Offset+Align-1)/Align*Align; if (StackGrowsDown) { FFI->setObjectOffset(i, -Offset); // Set the computed offset @@ -315,6 +318,11 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { // Set the final value of the stack pointer... FFI->setStackSize(Offset+TFI.getOffsetOfLocalArea()); + // If we have a new stack alignment, set the preferred stack alignment so that + // the targets can do the appropriate thing to properly align the stack above + // the default alignment. + if (MaxAlign > StackAlignment) + FFI->setMaxAlignment(MaxAlign); } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 3b5ef32e3c3..64256c963eb 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -147,7 +147,9 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli, if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(AI->getArraySize())) { const Type *Ty = AI->getAllocatedType(); uint64_t TySize = TLI.getTargetData().getTypeSize(Ty); - unsigned Align = TLI.getTargetData().getTypeAlignment(Ty); + unsigned Align = + std::max((unsigned)TLI.getTargetData().getTypeAlignment(Ty), + AI->getAlignment()); // If the alignment of the value is smaller than the size of the value, // and if the size of the value is particularly small (<= 8 bytes), @@ -636,7 +638,8 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) { const Type *Ty = I.getAllocatedType(); uint64_t TySize = TLI.getTargetData().getTypeSize(Ty); - unsigned Align = TLI.getTargetData().getTypeAlignment(Ty); + unsigned Align = std::max((unsigned)TLI.getTargetData().getTypeAlignment(Ty), + I.getAlignment()); SDOperand AllocSize = getValue(I.getArraySize()); MVT::ValueType IntPtr = TLI.getPointerTy(); |