[all-commits] [llvm/llvm-project] 9d3e37: [ARM][Thumb1] Improve EstimateFunctionSizeInBytes ...

Simon Tatham via All-commits all-commits at lists.llvm.org
Thu Jun 11 09:02:10 PDT 2026


  Branch: refs/heads/users/statham-arm/thumb1-estimation-fix
  Home:   https://github.com/llvm/llvm-project
  Commit: 9d3e378f3e7d28b36bf94a3c04ca386203a58da8
      https://github.com/llvm/llvm-project/commit/9d3e378f3e7d28b36bf94a3c04ca386203a58da8
  Author: Simon Tatham <simon.tatham at arm.com>
  Date:   2026-06-11 (Thu, 11 Jun 2026)

  Changed paths:
    M llvm/lib/Target/ARM/ARMFrameLowering.cpp
    M llvm/lib/Target/ARM/ARMMachineFunctionInfo.h

  Log Message:
  -----------
  [ARM][Thumb1] Improve EstimateFunctionSizeInBytes accuracy

The estimate of a function size now includes (what I hope are) upper
bounds on the size of the prologue and epilogue; adds size estimates
for some pseudo-instructions that were previously counted as 0; and
increases the estimates for things that were previously optimistic,
such as assuming no constant pool entry ever needs to be duplicated.
The estimation function is also passed extra information to use for
adjusting its estimates, such as the BigFrameOffsets flag which makes
some pseudos have much longer expansions.

Background:

EstimateFunctionSizeInBytes is supposed to estimate how large a Thumb1
function will end up, in advance of actually doing the full code
generation. It must overestimate rather than underestimating, because
large functions need a special precaution (namely, making sure LR is
stacked, so that BL can be used for an intra-function long branch). In
multiple cases recently it has underestimated, leading to a crash
later in code generation, when ARMConstantIslandsPass needs to insert
an intra-function BL and finds that it isn't safe to corrupt LR.

Discussion on Discourse suggested that it's OK to overestimate by
quite a large factor, because any significantly large function won't
be badly impacted by a push of LR that turns out to be unnecessary.
The main place where we want to leave out those unnecessary pushes is
_really_ small leaf functions, where the extra push and pop might be a
significant fraction of the whole call.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list