[llvm] [ARM][Thumb1] Improve EstimateFunctionSizeInBytes accuracy (PR #203318)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 08:39:40 PDT 2026


================
@@ -2346,16 +2346,146 @@ bool ARMFrameLowering::restoreCalleeSavedRegisters(
 
 // FIXME: Make generic?
 static unsigned EstimateFunctionSizeInBytes(const MachineFunction &MF,
-                                            const ARMBaseInstrInfo &TII) {
+                                            const ARMBaseInstrInfo &TII,
+                                            const ARMSubtarget &STI,
+                                            bool BigFrameOffsets) {
   unsigned FnSize = 0;
+
+  if (MF.shouldSplitStack()) {
+    // Split stack prologue saves r4,r5; makes a copy of sp and loads
+    // a literal; compares the two, and if sp < literal, pushes
+    // further registers and calls __morestack.
+    FnSize += 0x24;
----------------
smithp35 wrote:

One thought about how we might be able to keep these constants in sync with, presumably, the frame lowering code. Could these be made static constants, then in the code that generates the instructions we could check that these constants weren't exceeded?

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


More information about the llvm-commits mailing list