[llvm] [AMDGPU] Update base addr of dyn alloca considering GrowingUp stack (PR #119822)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 03:11:02 PST 2024


================
@@ -4023,10 +4024,20 @@ SDValue SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(SDValue Op,
   Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl);
 
   SDValue Size = Tmp2.getOperand(1);
-  SDValue SP = DAG.getCopyFromReg(Chain, dl, SPReg, VT);
-  Chain = SP.getValue(1);
+  SDValue SPOld = DAG.getCopyFromReg(Chain, dl, SPReg, VT);
+  Chain = SPOld.getValue(1);
   MaybeAlign Alignment = cast<ConstantSDNode>(Tmp3)->getMaybeAlignValue();
   const TargetFrameLowering *TFL = Subtarget->getFrameLowering();
+  Align StackAlign = TFL->getStackAlign();
----------------
easyonaadit wrote:

The order in which the two operations (aligning the base address, and bumping the stack pointer) are performed, is non-trivial. The previous implementation was suitable for a growing down stack, hence first SP was bumped, and then alignment was performed. But for a growing up stack, first we have to align CurrSP, and then bump. 
It will not be in our best interest to move the code back down, as that will swap the order.  

https://github.com/llvm/llvm-project/pull/119822


More information about the llvm-commits mailing list