[llvm] 4a5b1cd - [RISCV][NFC] Simplify isSupportedStackID (#229117)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 17:08:51 PDT 2026


Author: Sudharsan Veeravalli
Date: 2026-10-07T05:38:39+05:30
New Revision: 4a5b1cd476369168598b769187ef8c9934ef326e

URL: https://github.com/llvm/llvm-project/commit/4a5b1cd476369168598b769187ef8c9934ef326e
DIFF: https://github.com/llvm/llvm-project/commit/4a5b1cd476369168598b769187ef8c9934ef326e.diff

LOG: [RISCV][NFC] Simplify isSupportedStackID (#229117)

The switch case approach meant that we had to add a case every time a
new `TargetStackID` gets added. The original switch was added in
https://reviews.llvm.org/D94465 at which time I guess we had only a few
valid cases.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index ac31c070242d8..8086732cf0cba 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -2752,18 +2752,7 @@ bool RISCVFrameLowering::canUseAsEpilogue(const MachineBasicBlock &MBB) const {
 }
 
 bool RISCVFrameLowering::isSupportedStackID(TargetStackID::Value ID) const {
-  switch (ID) {
-  case TargetStackID::Default:
-  case TargetStackID::ScalableVector:
-    return true;
-  case TargetStackID::NoAlloc:
-  case TargetStackID::SGPRSpill:
-  case TargetStackID::WasmLocal:
-  case TargetStackID::ScalablePredicateVector:
-  case TargetStackID::AvrAlign:
-    return false;
-  }
-  llvm_unreachable("Invalid TargetStackID::Value");
+  return ID == TargetStackID::Default || ID == TargetStackID::ScalableVector;
 }
 
 TargetStackID::Value RISCVFrameLowering::getStackIDForScalableVectors() const {


        


More information about the llvm-commits mailing list