[llvm] [RISCV] Order stack objects by access density (PR #217507)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 01:47:04 PDT 2026


================
@@ -2846,6 +2848,75 @@ void RISCVFrameLowering::inlineStackProbe(MachineFunction &MF,
   }
 }
 
+namespace {
+/// Bookkeeping record used while ordering local stack objects by access
+/// density. One record is created for each frame index passed to
+/// orderFrameObjects().
+struct RISCVFrameSortingObject {
+  int ObjectIndex;
+  uint64_t ObjectSize;
+  Align ObjectAlign;
+  uint64_t NumUses = 0;
+};
+} // end anonymous namespace
+
+void RISCVFrameLowering::orderFrameObjects(
+    const MachineFunction &MF, SmallVectorImpl<int> &ObjectsToAllocate) const {
+  // PEI has already removed callee-saved, dead, stack-protector, EH and other
+  // special objects from ObjectsToAllocate. The remaining objects are safe to
+  // reorder.
+  const MachineFrameInfo &MFI = MF.getFrameInfo();
----------------
refuseno wrote:

Yes, this PR was assisted by LLM. I've added disclosure in PR description. Thanks for reminder.

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


More information about the llvm-commits mailing list