[PATCH] D121728: [BOLT] LongJmp: Fix hot text section alignment
Vladislav Khmelevsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 12:24:10 PDT 2022
yota9 created this revision.
yota9 added reviewers: maksfb, rafauler, Amir.
Herald added a subscriber: ayermolo.
Herald added a project: All.
yota9 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The BinaryEmitter uses opts::AlignText value to align the hot text
section. Also check that the opts::AlignText is at least
equal opts::AlignFunctions for the same reason, as described in D121392 <https://reviews.llvm.org/D121392>.
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121728
Files:
bolt/lib/Passes/LongJmp.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1743,6 +1743,9 @@
if (!opts::AlignText.getNumOccurrences())
opts::AlignText = BC->PageAlign;
+ if (opts::AlignText < opts::AlignFunctions)
+ opts::AlignText = (unsigned)opts::AlignFunctions;
+
if (BC->isX86() && opts::Lite.getNumOccurrences() == 0 && !opts::StrictMode &&
!opts::UseOldText)
opts::Lite = true;
Index: bolt/lib/Passes/LongJmp.cpp
===================================================================
--- bolt/lib/Passes/LongJmp.cpp
+++ bolt/lib/Passes/LongJmp.cpp
@@ -18,6 +18,7 @@
namespace opts {
extern cl::OptionCategory BoltOptCategory;
+extern llvm::cl::opt<unsigned> AlignText;
extern cl::opt<unsigned> AlignFunctions;
extern cl::opt<bool> UseOldText;
extern cl::opt<bool> HotFunctionsAtEnd;
@@ -342,7 +343,7 @@
tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);
ColdLayoutDone = true;
if (opts::HotFunctionsAtEnd)
- DotAddress = alignTo(DotAddress, BC.PageAlign);
+ DotAddress = alignTo(DotAddress, opts::AlignText);
}
DotAddress = alignTo(DotAddress, BinaryFunction::MinAlign);
@@ -390,11 +391,11 @@
// Initial padding
if (opts::UseOldText && EstimatedTextSize <= BC.OldTextSectionSize) {
DotAddress = BC.OldTextSectionAddress;
- uint64_t Pad = offsetToAlignment(DotAddress, llvm::Align(BC.PageAlign));
+ uint64_t Pad = offsetToAlignment(DotAddress, llvm::Align(opts::AlignText));
if (Pad + EstimatedTextSize <= BC.OldTextSectionSize)
DotAddress += Pad;
} else {
- DotAddress = alignTo(BC.LayoutStartAddress, BC.PageAlign);
+ DotAddress = alignTo(BC.LayoutStartAddress, opts::AlignText);
}
tentativeLayoutRelocMode(BC, SortedFunctions, DotAddress);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121728.415539.patch
Type: text/x-patch
Size: 1914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220315/e4dd28eb/attachment.bin>
More information about the llvm-commits
mailing list