[llvm] c37e6a2 - [Hexagon] Check if register is non-null before calling subregs_inclusive

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 02:40:19 PDT 2023


Author: Sergei Barannikov
Date: 2023-06-04T12:40:04+03:00
New Revision: c37e6a269ef3df0cde217feca945edfa8fcf68fe

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

LOG: [Hexagon] Check if register is non-null before calling subregs_inclusive

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.

Reviewed By: kparzysz

Differential Revision: https://reviews.llvm.org/D151406

Added: 
    

Modified: 
    llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
index 5d5566141a91a..231ac0825ee1d 100644
--- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
@@ -307,6 +307,9 @@ static bool needsStackFrame(const MachineBasicBlock &MBB, const BitVector &CSR,
           return true;
         if (MO.isReg()) {
           Register R = MO.getReg();
+          // Debug instructions may refer to $noreg.
+          if (!R)
+            continue;
           // Virtual registers will need scavenging, which then may require
           // a stack slot.
           if (R.isVirtual())


        


More information about the llvm-commits mailing list