[PATCH] D156113: [CodeGen] Store call frame size in MachineBasicBlock

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 05:58:54 PDT 2023


foad added inline comments.


================
Comment at: llvm/lib/CodeGen/PrologEpilogInserter.cpp:391-394
+    // We can't track the call frame size after call frame pseudos have been
+    // eliminated. Set it to zero everywhere to keep MachineVerifier happy.
+    for (MachineBasicBlock &MBB : MF)
+      MBB.setCallFrameSize(0);
----------------
arsenm wrote:
> Should the pseudo elimination itself take care of this?
I don't see how that would work. You could (at least in theory) have block with a non-0 call frame size on entry, that doesn't contain any call frame pseudos. In any case it seems a bit weird for the per-instruction call `eliminateCallFramePseudoInstr` to change per-block state.


================
Comment at: llvm/lib/CodeGen/TargetInstrInfo.cpp:1467
+  // block.
+  return MBB->getCallFrameSize();
+}
----------------
arsenm wrote:
> I'd assume this would be a compute this to set this situation, not a try to compute and fallback to precomputed?
It's not really a matter of computing vs using a precomputed value.

To find the call frame size at an arbitrary point, conceptually you should start with the stored value at the start of the BB and then walk forwards updating it on every call frame pseudo. But because call frame pseudos are not allowed to be nested it is quicker to walk backwards and stop at the first pseudo you hit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156113/new/

https://reviews.llvm.org/D156113



More information about the llvm-commits mailing list