Skip to content

Commit

Permalink
[BOLT] LongJmp: Use per-function alignment values
Browse files Browse the repository at this point in the history
The per-function alignment values must be used in order to create
tentative layout.

Differential Revision: https://reviews.llvm.org/D121298
  • Loading branch information
yota9 committed Mar 10, 2022
1 parent b24de9f commit 04b87cf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions bolt/lib/Passes/LongJmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace opts {
extern cl::OptionCategory BoltOptCategory;

extern cl::opt<bool> UseOldText;
extern cl::opt<unsigned> AlignFunctions;
extern cl::opt<unsigned> AlignFunctionsMaxBytes;
extern cl::opt<bool> HotFunctionsAtEnd;

static cl::opt<bool>
Expand Down Expand Up @@ -302,8 +300,8 @@ uint64_t LongJmpPass::tentativeLayoutRelocColdPart(
continue;
DotAddress = alignTo(DotAddress, BinaryFunction::MinAlign);
uint64_t Pad =
offsetToAlignment(DotAddress, llvm::Align(opts::AlignFunctions));
if (Pad <= opts::AlignFunctionsMaxBytes)
offsetToAlignment(DotAddress, llvm::Align(Func->getAlignment()));
if (Pad <= Func->getMaxColdAlignmentBytes())
DotAddress += Pad;
ColdAddresses[Func] = DotAddress;
LLVM_DEBUG(dbgs() << Func->getPrintName() << " cold tentative: "
Expand Down Expand Up @@ -349,8 +347,8 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(

DotAddress = alignTo(DotAddress, BinaryFunction::MinAlign);
uint64_t Pad =
offsetToAlignment(DotAddress, llvm::Align(opts::AlignFunctions));
if (Pad <= opts::AlignFunctionsMaxBytes)
offsetToAlignment(DotAddress, llvm::Align(Func->getAlignment()));
if (Pad <= Func->getMaxAlignmentBytes())
DotAddress += Pad;
HotAddresses[Func] = DotAddress;
LLVM_DEBUG(dbgs() << Func->getPrintName() << " tentative: "
Expand Down

0 comments on commit 04b87cf

Please sign in to comment.