mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 20:33:15 +00:00
- 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1defe2df5d
commit
4515779fa3
@ -2329,21 +2329,21 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) {
|
|||||||
AllocSize = DAG.getNode(ISD::MUL, IntPtr, AllocSize,
|
AllocSize = DAG.getNode(ISD::MUL, IntPtr, AllocSize,
|
||||||
getIntPtrConstant(TySize));
|
getIntPtrConstant(TySize));
|
||||||
|
|
||||||
// Handle alignment. If the requested alignment is less than the stack
|
// Handle alignment. If the requested alignment is less than or equal to
|
||||||
// alignment, ignore it and round the size of the allocation up to the stack
|
// the stack alignment, ignore it. If the size is greater than or equal to
|
||||||
// alignment size. If the size is greater than or equal to the stack
|
// the stack alignment, we note this in the DYNAMIC_STACKALLOC node.
|
||||||
// alignment, we note this in the DYNAMIC_STACKALLOC node.
|
|
||||||
unsigned StackAlign =
|
unsigned StackAlign =
|
||||||
TLI.getTargetMachine().getFrameInfo()->getStackAlignment();
|
TLI.getTargetMachine().getFrameInfo()->getStackAlignment();
|
||||||
if (Align < StackAlign) {
|
if (Align <= StackAlign)
|
||||||
Align = 0;
|
Align = 0;
|
||||||
// Add SA-1 to the size.
|
|
||||||
AllocSize = DAG.getNode(ISD::ADD, AllocSize.getValueType(), AllocSize,
|
// Round the size of the allocation up to the stack alignment size
|
||||||
getIntPtrConstant(StackAlign-1));
|
// by add SA-1 to the size.
|
||||||
// Mask out the low bits for alignment purposes.
|
AllocSize = DAG.getNode(ISD::ADD, AllocSize.getValueType(), AllocSize,
|
||||||
AllocSize = DAG.getNode(ISD::AND, AllocSize.getValueType(), AllocSize,
|
getIntPtrConstant(StackAlign-1));
|
||||||
getIntPtrConstant(~(uint64_t)(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) };
|
SDOperand Ops[] = { getRoot(), AllocSize, getIntPtrConstant(Align) };
|
||||||
const MVT::ValueType *VTs = DAG.getNodeValueTypes(AllocSize.getValueType(),
|
const MVT::ValueType *VTs = DAG.getNodeValueTypes(AllocSize.getValueType(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user