[llvm] [AMDGPU] Assert if stack grows downwards. (PR #119888)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 09:19:09 PST 2024
================
@@ -4041,17 +4041,15 @@ SDValue SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(SDValue Op,
Chain = SP.getValue(1);
MaybeAlign Alignment = cast<ConstantSDNode>(Tmp3)->getMaybeAlignValue();
const TargetFrameLowering *TFL = Subtarget->getFrameLowering();
- unsigned Opc =
- TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp
- ? ISD::ADD
- : ISD::SUB;
+ assert(TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp &&
+ "Stack grows upwards for AMDGPU");
SDValue ScaledSize = DAG.getNode(
ISD::SHL, dl, VT, Size,
DAG.getConstant(Subtarget->getWavefrontSizeLog2(), dl, MVT::i32));
Align StackAlign = TFL->getStackAlign();
- Tmp1 = DAG.getNode(Opc, dl, VT, SP, ScaledSize); // Value
+ Tmp1 = DAG.getNode(ISD::ADD, dl, VT, SP, ScaledSize); // Value
----------------
easyonaadit wrote:
Hi,
There are 2 things to consider here:
1. For AMDGPU, the Stack grows upwards (low addr to high addr)
2. The code here is based on the default implementation, which itself doesn't seem to adjust for a growing up stack.
This patch is actually just a part of fixing the logic flaw you pointed out. There is a fix in progress, you could follow it here:
https://github.com/llvm/llvm-project/pull/119822
https://github.com/llvm/llvm-project/pull/119888
More information about the llvm-commits
mailing list