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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 10:26:56 PDT 2025


topperc wrote:

> > > I don't understand what a "negative frame index" is supposed to be. The `Register` class can encode references to stack slots which are indices into an array of stack objects in `MachineFrameInfo` and negative indexes make no sense there, no?
> > 
> > 
> > From MachineFrameInfo.h
> > ```
> > /// To support this, the class assigns unique integer identifiers to stack       
> > /// objects requested clients.  These identifiers are negative integers for      
> > /// fixed stack objects (such as arguments passed on the stack) or nonnegative   
> > /// for objects that may be reordered.  Instructions which refer to stack        
> > /// objects use a special MO_FrameIndex operand to represent these frame         
> > /// indexes.  
> > ```
> 
> @MatzeB @topperc @arsenm We expect vast majority of the indices to be positive and a few negative ones. In theory we could "shift" the values so that we use the same 30 bits but only represent say 100 negative values and the rest are positive. I can do this too if people think its necessary.

I don't think its necessary. Having more than 2^29 frame indices in either direction seems unlikely. The amount of memory consumed by MachineFrameInfo just to track that would be excessive.

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


More information about the llvm-commits mailing list