[llvm] [AMDGPU] Assert when stack grows upwards (PR #119883)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 06:56:47 PST 2024
https://github.com/easyonaadit updated https://github.com/llvm/llvm-project/pull/119883
>From 082170149d0fcd382312dd423a60452485bca026 Mon Sep 17 00:00:00 2001
From: easyonaadit <aaditya.alokdeshpande at amd.com>
Date: Fri, 13 Dec 2024 18:28:18 +0530
Subject: [PATCH] assert if stack grows upwards
---
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp | 3 +--
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 7 ++-----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index e5baffc0f064b2..0dfcb4f86b0142 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -1181,8 +1181,7 @@ bool AMDGPURegisterBankInfo::applyMappingDynStackAlloc(
// Guard in case the stack growth direction ever changes with scratch
// instructions.
- if (TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsDown)
- return false;
+ assert(TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp && "Stack grows upwards for AMDGPU\n");
Register Dst = MI.getOperand(0).getReg();
Register AllocSize = MI.getOperand(1).getReg();
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 8dfebd36a962e1..3446906e76e7ee 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -4041,17 +4041,14 @@ 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\n");
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
if (Alignment && *Alignment > StackAlign) {
Tmp1 = DAG.getNode(
ISD::AND, dl, VT, Tmp1,
More information about the llvm-commits
mailing list