Description
If a function is a leaf and does not contain any spills it does not need a frame.
POC mraleph@a70a694 reveals that a lot of functions in Flutter Gallery fit this definition - and dropping frame setup leads to a significant code size improvement (and potentially performance improvement as well).
Store barrier introduces a slight complication into this on ARM/ARM64 because of its outlined slow-path. This slow-path can only call leaf-runtime entry, but nevertheless calling the slow-path clobbers LR
. We already support generating store barriers in intrinsics - which are also frameless and thus don't have LR
saved - however this introduces explicit pushing and popping of LR
which needs to be taken into account when deciding if it is worth to setup a frame (e.g. POC allows at most 1 instruction with a store barrier per frameless function). One dodgy part here is the lack of static guarantee: location summaries capture which instructions perform calls and which don't, with the exception of store barrier call. I suggest that turning POC into a real implementation requires at least adding an assertion that checks that branch-link instruction is only allows to be emitted when IL instruction is marked as clobbering LR.
part of go/dart-llvm-assessment
/cc @mkustermann for triage and assignment