Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorVladislav Khmelevsky <och95@yandex.ru>2022-03-15 22:17:51 +0300
committerVladislav Khmelevsky <och95@yandex.ru>2022-03-16 15:57:46 +0300
commit62a289d85c9fc8d7c0141e63477474c03a17e1b4 (patch)
tree6ae6e77d4d0ab5bc7c8dff07a3e6bc4aacb11bad /bolt
parent0389462587f8b89d6e724ccc4ff32d86963bfc22 (diff)
[BOLT] LongJmp: Fix hot text section alignment
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. Vladislav Khmelevsky, Advanced Software Technology Lab, Huawei Differential Revision: https://reviews.llvm.org/D121728
Diffstat (limited to 'bolt')
-rw-r--r--bolt/lib/Passes/LongJmp.cpp7
-rw-r--r--bolt/lib/Rewrite/RewriteInstance.cpp3
2 files changed, 7 insertions, 3 deletions
diff --git a/bolt/lib/Passes/LongJmp.cpp b/bolt/lib/Passes/LongJmp.cpp
index d576bf185621..fbbe0545c9a2 100644
--- a/bolt/lib/Passes/LongJmp.cpp
+++ b/bolt/lib/Passes/LongJmp.cpp
@@ -18,6 +18,7 @@ using namespace llvm;
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 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
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 @@ void LongJmpPass::tentativeLayout(
// 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);
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index b81486200ad4..8c8c55bc30ee 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1743,6 +1743,9 @@ void RewriteInstance::adjustCommandLineOptions() {
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;