This commit allows the outliner to avoid saving + restoring the link register on AArch64 when it is dead within an entire class of candidates. It also changes the interface for the outliner slightly to facilitate this.
By doing this, it's possible to find more outlining candidates in AArch64-- in the case that a candidate doesn't require a save/restore, that candidate can be far shorter. This allows us to find length 2 and 3 candidates and outline them.
This is still conservative. For example, if a length-3 candidate appears 20 times, and one of those times requires a save + restore, the outliner will assume all of them require a save + restore. Thus, none will be outlined. This will be fixed in later patches; the purpose of this is just to get the main idea going.
This, on average, improves the code size of the --benchmarking only SingleSource and MultiSource tests by about 2.94% in comparison to the current outliner. Several tests have no improvements; this is likely due to the conservative nature of the current technique. 36 of the tests improve by more than 10%. 4 tests regress, likely due to competing with linker deduping. This can likely be fixed by disallowing outlining from linkonceodr functions.
These were compiled with LNT using -Oz -mno-red-zone -mllvm -enable-machine-outliner and --benchmarking-only.
Full code size results: https://hastebin.com/raw/soloropiwo
I wonder why this parameter is called CandidateClass, from reading the description I wonder why there is a Class suffix.