forked from OSchip/llvm-project
[BOLT] Option to control .text alignment
Summary: Add option `-align-text=<n>` to control .text alignment within a segment. Set to page size by default. (cherry picked from FBD21120063)
This commit is contained in:
parent
10245b5c5b
commit
23edb3ed9c
|
@ -32,6 +32,7 @@ extern cl::OptionCategory BoltCategory;
|
|||
extern cl::OptionCategory BoltOptCategory;
|
||||
extern cl::OptionCategory BoltRelocCategory;
|
||||
|
||||
extern cl::opt<unsigned> AlignText;
|
||||
extern cl::opt<bool> HotText;
|
||||
extern cl::opt<bool> Instrument;
|
||||
extern cl::opt<JumpTableSupportLevel> JumpTables;
|
||||
|
@ -194,7 +195,7 @@ private:
|
|||
void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
|
||||
Streamer.InitSections(false);
|
||||
|
||||
BC.getTextSection()->setAlignment(BC.PageAlign);
|
||||
BC.getTextSection()->setAlignment(opts::AlignText);
|
||||
|
||||
emitFunctions();
|
||||
|
||||
|
|
|
@ -96,6 +96,13 @@ extern cl::list<std::string> ReorderData;
|
|||
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
|
||||
extern cl::opt<bool> TimeBuild;
|
||||
|
||||
cl::opt<unsigned>
|
||||
AlignText("align-text",
|
||||
cl::desc("alignment of .text section"),
|
||||
cl::ZeroOrMore,
|
||||
cl::Hidden,
|
||||
cl::cat(BoltCategory));
|
||||
|
||||
cl::opt<bool>
|
||||
Instrument("instrument",
|
||||
cl::desc("instrument code to generate accurate profile data"),
|
||||
|
@ -1669,8 +1676,7 @@ void RewriteInstance::adjustCommandLineOptions() {
|
|||
opts::AlignMacroOpFusion = MFT_NONE;
|
||||
}
|
||||
|
||||
if (opts::AlignMacroOpFusion != MFT_NONE &&
|
||||
!BC->HasRelocations) {
|
||||
if (opts::AlignMacroOpFusion != MFT_NONE && !BC->HasRelocations) {
|
||||
outs() << "BOLT-INFO: disabling -align-macro-fusion in non-relocation "
|
||||
"mode\n";
|
||||
opts::AlignMacroOpFusion = MFT_NONE;
|
||||
|
@ -1729,6 +1735,10 @@ void RewriteInstance::adjustCommandLineOptions() {
|
|||
"\n";
|
||||
opts::UseOldText = false;
|
||||
}
|
||||
|
||||
if (!opts::AlignText.getNumOccurrences()) {
|
||||
opts::AlignText = BC->PageAlign;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -2865,12 +2875,12 @@ void RewriteInstance::mapCodeSections(orc::VModuleKey Key) {
|
|||
|
||||
if (CodeSize <= BC->OldTextSectionSize) {
|
||||
outs() << "BOLT-INFO: using original .text for new code with 0x"
|
||||
<< Twine::utohexstr(BC->PageAlign) << " alignment\n";
|
||||
<< Twine::utohexstr(opts::AlignText) << " alignment\n";
|
||||
AllocationDone = true;
|
||||
} else {
|
||||
errs() << "BOLT-WARNING: original .text too small to fit the new code"
|
||||
<< " using 0x" << Twine::utohexstr(BC->PageAlign)
|
||||
<< " page alignment. " << CodeSize
|
||||
<< " using 0x" << Twine::utohexstr(opts::AlignText)
|
||||
<< " alignment. " << CodeSize
|
||||
<< " bytes needed, have " << BC->OldTextSectionSize
|
||||
<< " bytes available.\n";
|
||||
opts::UseOldText = false;
|
||||
|
|
Loading…
Reference in New Issue