@@ -120,12 +120,18 @@ class MachineFrameInfo {
120120 // /< triggered protection. 3rd closest to the protector.
121121 };
122122
123+ static constexpr int NoUnderlyingSlot = std::numeric_limits<int >::min();
124+ static constexpr int IsUnderlyingSlot = std::numeric_limits<int >::min() + 1 ;
125+
123126private:
124127 // Represent a single object allocated on the stack.
125128 struct StackObject {
126129 // The offset of this object from the stack pointer on entry to
127130 // the function. This field has no meaning for a variable sized element.
128- int64_t SPOffset;
131+ // After getting placed this is relative to SP
132+ // If UnderlyingSlot is not NoUnderlyingSlot, this is relative to the start
133+ // of the UnderlyingSlot
134+ int64_t Offset;
129135
130136 // The size of this object on the stack. 0 means a variable sized object,
131137 // ~0ULL means a dead object.
@@ -134,6 +140,10 @@ class MachineFrameInfo {
134140 // The required alignment of this stack slot.
135141 Align Alignment;
136142
143+ // If not NoUnderlyingSlot, it Indicate that this slot should be placed
144+ // at Offset, into the slot UnderlyingSlot
145+ int UnderlyingSlot = NoUnderlyingSlot;
146+
137147 // If true, the value of the stack object is set before
138148 // entering the function and is not modified inside the function. By
139149 // default, fixed objects are immutable unless marked otherwise.
@@ -183,10 +193,10 @@ class MachineFrameInfo {
183193
184194 uint8_t SSPLayout = SSPLK_None;
185195
186- StackObject (uint64_t Size, Align Alignment, int64_t SPOffset ,
196+ StackObject (uint64_t Size, Align Alignment, int64_t Offset ,
187197 bool IsImmutable, bool IsSpillSlot, const AllocaInst *Alloca,
188198 bool IsAliased, uint8_t StackID = 0 )
189- : SPOffset(SPOffset ), Size(Size), Alignment(Alignment),
199+ : Offset(Offset ), Size(Size), Alignment(Alignment),
190200 isImmutable (IsImmutable), isSpillSlot(IsSpillSlot), StackID(StackID),
191201 Alloca(Alloca), isAliased(IsAliased) {}
192202 };
@@ -532,7 +542,7 @@ class MachineFrameInfo {
532542 " Invalid Object Idx!" );
533543 assert (!isDeadObjectIndex (ObjectIdx) &&
534544 " Getting frame offset for a dead object?" );
535- return Objects[ObjectIdx+ NumFixedObjects].SPOffset ;
545+ return Objects[ObjectIdx + NumFixedObjects].Offset ;
536546 }
537547
538548 bool isObjectZExt (int ObjectIdx) const {
@@ -561,12 +571,12 @@ class MachineFrameInfo {
561571
562572 // / Set the stack frame offset of the specified object. The
563573 // / offset is relative to the stack pointer on entry to the function.
564- void setObjectOffset (int ObjectIdx, int64_t SPOffset ) {
574+ void setObjectOffset (int ObjectIdx, int64_t Offset ) {
565575 assert (unsigned (ObjectIdx+NumFixedObjects) < Objects.size () &&
566576 " Invalid Object Idx!" );
567577 assert (!isDeadObjectIndex (ObjectIdx) &&
568578 " Setting frame offset for a dead object?" );
569- Objects[ObjectIdx+ NumFixedObjects].SPOffset = SPOffset ;
579+ Objects[ObjectIdx + NumFixedObjects].Offset = Offset ;
570580 }
571581
572582 SSPLayoutKind getObjectSSPLayout (int ObjectIdx) const {
@@ -762,6 +772,18 @@ class MachineFrameInfo {
762772 // If ID == 0, MaxAlignment will need to be updated separately.
763773 }
764774
775+ int getUnderlyingSlot (int ObjectIdx) {
776+ assert (unsigned (ObjectIdx + NumFixedObjects) < Objects.size () &&
777+ " Invalid Object Idx!" );
778+ return Objects[ObjectIdx + NumFixedObjects].UnderlyingSlot ;
779+ }
780+
781+ void setUnderlyingSlot (int ObjectIdx, int Underlying) {
782+ assert (unsigned (ObjectIdx + NumFixedObjects) < Objects.size () &&
783+ " Invalid Object Idx!" );
784+ Objects[ObjectIdx + NumFixedObjects].UnderlyingSlot = Underlying;
785+ }
786+
765787 // / Returns true if the specified index corresponds to a dead object.
766788 bool isDeadObjectIndex (int ObjectIdx) const {
767789 assert (unsigned (ObjectIdx+NumFixedObjects) < Objects.size () &&
0 commit comments