[PATCH] D121392: [BOLT] Set cold sections alignment explicitly

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 12 07:30:17 PST 2022


yota9 added inline comments.


================
Comment at: bolt/lib/Core/BinaryEmitter.cpp:294-296
+    // Set section alignment to at least maximum possible object alignment.
+    // We need this to support LongJmp and other passes that calculates
+    // tentative layout.
----------------
rafauler wrote:
> Why is this necessary? Is it possible to write a testcase that shows where we are getting the layout wrong?
As I said cold text section alignment is set using the maximum alignment value
passed to the emitCodeAlignment (see just under of these new lines). The thing is that when we calculate tentative layout in LongJmp currently we don't take into account that there will be the alignment gap between text and text.cold (see new line I've added there). In order to take cold text alignment in to the account we need to know the biggest alignment value we will pass to the emitCodeAlignment. So the simple idea here is to align the cold section ( which we didn't explicitly aligned before ) with the biggest possible value (opts::AlignFunctions). This way we are guaranteed that it will be the maximum possible value that might be passed to the emitCodeAlignment and now we can easily calculate tentative layout more precise. 
I will try to create the simple test soon, I hope it won't be difficult. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121392



More information about the llvm-commits mailing list