diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-08-16 23:46:29 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-08-16 23:46:29 +0000 |
commit | 95667c532c1d0cb0127e1eabe3fc6fef5fdb6a27 (patch) | |
tree | aaeae8dd76652fdc65b98bf68334bcbdb594193d /llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | |
parent | f5023a7a848e2016648698d045f35260bc47a3be (diff) | |
download | bcm5719-llvm-95667c532c1d0cb0127e1eabe3fc6fef5fdb6a27.tar.gz bcm5719-llvm-95667c532c1d0cb0127e1eabe3fc6fef5fdb6a27.zip |
- If a dynamic_stackalloc alignment requirement is <= stack alignment, then the alignment argument is ignored.
- *Always* round up the size of the allocation to multiples of stack
alignment to ensure the stack ptr is never left in an invalid state after a dynamic_stackalloc.
llvm-svn: 41132
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 90ed4545bd0..a99640a1704 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -2329,21 +2329,21 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) { AllocSize = DAG.getNode(ISD::MUL, IntPtr, AllocSize, getIntPtrConstant(TySize)); - // Handle alignment. If the requested alignment is less than the stack - // alignment, ignore it and round the size of the allocation up to the stack - // alignment size. If the size is greater than or equal to the stack - // alignment, we note this in the DYNAMIC_STACKALLOC node. + // Handle alignment. If the requested alignment is less than or equal to + // the stack alignment, ignore it. If the size is greater than or equal to + // the stack alignment, we note this in the DYNAMIC_STACKALLOC node. unsigned StackAlign = TLI.getTargetMachine().getFrameInfo()->getStackAlignment(); - if (Align < StackAlign) { + if (Align <= StackAlign) Align = 0; - // Add SA-1 to the size. - AllocSize = DAG.getNode(ISD::ADD, AllocSize.getValueType(), AllocSize, - getIntPtrConstant(StackAlign-1)); - // Mask out the low bits for alignment purposes. - AllocSize = DAG.getNode(ISD::AND, AllocSize.getValueType(), AllocSize, - getIntPtrConstant(~(uint64_t)(StackAlign-1))); - } + + // Round the size of the allocation up to the stack alignment size + // by add SA-1 to the size. + AllocSize = DAG.getNode(ISD::ADD, AllocSize.getValueType(), AllocSize, + getIntPtrConstant(StackAlign-1)); + // Mask out the low bits for alignment purposes. + AllocSize = DAG.getNode(ISD::AND, AllocSize.getValueType(), AllocSize, + getIntPtrConstant(~(uint64_t)(StackAlign-1))); SDOperand Ops[] = { getRoot(), AllocSize, getIntPtrConstant(Align) }; const MVT::ValueType *VTs = DAG.getNodeValueTypes(AllocSize.getValueType(), |