Linker optimization hints are used for marking a sequence of
instructions used for synthesizing an address, like ADRP+ADD. If the
referenced symbol ends up close enough, it can be replaced by a faster
sequence of instructions like ADR+NOP.
This commit adds support for 2 of the 7 defined ARM64 optimization
hints:
- LOH_ARM64_ADRP_ADD, which transforms a pair of ADRP+ADD into ADR+NOP if the referenced address is within +/- 1 MiB
- LOH_ARM64_ADRP_ADRP, which transforms two ADRP instructions into ADR+NOP if they reference the same page
These two kinds already cover more than 50% of all cases in Chromium.
I test-built Chromium with this patch applied.
The added overhead on linking Chromium is 200 milliseconds on my M1 Mac mini, which accounts for about 4% of the total runtime. About half of that is used for parsing the optimization hint data, and the rest is spent actually checking if the optimization can be done and performing it.
Suggestions on how to make it quicker are appreciated :)
Please commit this diff with the following author info:
Daniel Bertalan <dani@danielbertalan.dev>
You could move the ADD into the anonymous namespace above.