[PATCH] D137620: [BOLT] Don't align .text to pageAlign

Maksim Panchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 23 13:55:01 PST 2022


maksfb added a comment.

In D137620#4010305 <https://reviews.llvm.org/D137620#4010305>, @treapster wrote:

>> How do you define what makes sense?
>
> Well, something makes sense when benefits outweigh costs. The benefits of aligning after PHDR are not clear because PHDR occupies a small fraction of a page, especially in the context of huge pages, so it's unlikely to significantly increase TLB misses or otherwise affect performance. However, a benchmark would be interesting. While the costs are 2MB in padding space + in case of AArch64, more stubs inserted during longJmp. Processing clang without any flags renders 347691 stubs, with -no-huge-pages - 327125, and difference in .text size is 176 kb. Not that much, but it think it's reasonable to keep sections together unless there is a performance penalty. And i guess those 20k additional stubs also have some performance implications.

Now we just have to find more or less a reasonable strict definition for the alignment threshold. Some refactoring is required, but once we can pass `MaxBytesToEmit` to `MCStreamer::emitCodeAlignment()` for `.text`, it will solve the problem while also being future-proof. I believe it will also be helpful for the work you were planning to do on the complete binary rewrite.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137620/new/

https://reviews.llvm.org/D137620



More information about the llvm-commits mailing list