+ AdjustStackOffset(MFI, SFI, StackGrowsDown, Offset, MaxAlign);
+ }
+
+ // FIXME: Once this is working, then enable flag will change to a target
+ // check for whether the frame is large enough to want to use virtual
+ // frame index registers. Functions which don't want/need this optimization
+ // will continue to use the existing code path.
+ if (EnableLocalStackAlloc) {
+ unsigned Align = MFI->getLocalFrameMaxAlign();
+
+ // Adjust to alignment boundary.
+ Offset = (Offset + Align - 1) / Align * Align;
+
+ // Store the offset of the start of the local allocation block. This
+ // will be used later when resolving frame base virtual register pseudos.
+ MFI->setLocalFrameBaseOffset(Offset);
+
+ DEBUG(dbgs() << "Local frame base offset: " << Offset << "\n");
+
+ // Allocate the local block
+ Offset += MFI->getLocalFrameSize();
+
+ // Resolve offsets for objects in the local block.
+ for (unsigned i = 0, e = MFI->getLocalFrameObjectCount(); i != e; ++i) {
+ std::pair<int, int64_t> Entry = MFI->getLocalFrameObjectMap(i);
+ int64_t FIOffset = MFI->getLocalFrameBaseOffset() + Entry.second;
+
+ AdjustStackOffset(MFI, Entry.first, StackGrowsDown, FIOffset, MaxAlign);
+ }