I've been asked the following question by someone investigating performance/codegen in Firefox:
Do you know why rust chooses to align branch targets on 16-byte boundaries, and where in the code this is controlled?
I don't know the answer but maybe some here does? Any help is appreciated!
This has to happen somewhere in the x86 backend (or whatever architecture they're referring to), and rather late at that (around MC emission, probably?). I'm not familiar enough with it to give a more precise answer.
I should add for completeness that "happens in the x86 backend" may mean "there is an small hard-to-find hook being overriden somewhere in the target which is used by shared code in lib/CodeGen that actually inserts the padding"
Oh, as for why, general optimization advice from Intel is to align hot jump targets to a cache line
Very interesting! Thank you, @rkruppe! I'll pass it on.