[llvm] [CodeGen] Allow negative frame indicies in Register class. (PR #164459)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 13:01:26 PDT 2025


================
@@ -87,7 +92,8 @@ class Register {
   /// Compute the frame index from a register value representing a stack slot.
   int stackSlotIndex() const {
     assert(isStack() && "Not a stack slot");
-    return static_cast<int>(Reg - Register::FirstStackSlot);
+    return static_cast<int>(
+        SignExtend64<MaxFrameIndexBitwidth>(Reg & Register::StackSlotMask));
----------------
mgudim wrote:

@topperc @arsenm 

We use `unsigned` to represent a register, but we implicitly assume that it is 32 bits at least. Isn't it wrong? should we use `uint32_t` for register values?

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


More information about the llvm-commits mailing list