Stream: t-compiler/wg-llvm

Topic: branch target alignment question


mw (Aug 20 2019 at 08:33, on Zulip):

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!

rkruppe (Aug 20 2019 at 09:59, on Zulip):

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.

rkruppe (Aug 20 2019 at 10:20, on Zulip):

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"

rkruppe (Aug 20 2019 at 10:21, on Zulip):

Oh, as for why, general optimization advice from Intel is to align hot jump targets to a cache line

mw (Aug 20 2019 at 13:29, on Zulip):

Very interesting! Thank you, @rkruppe! I'll pass it on.

Last update: Nov 15 2019 at 09:40UTC