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 BoltOptCategory;
|
||||||
extern cl::OptionCategory BoltRelocCategory;
|
extern cl::OptionCategory BoltRelocCategory;
|
||||||
|
|
||||||
|
extern cl::opt<unsigned> AlignText;
|
||||||
extern cl::opt<bool> HotText;
|
extern cl::opt<bool> HotText;
|
||||||
extern cl::opt<bool> Instrument;
|
extern cl::opt<bool> Instrument;
|
||||||
extern cl::opt<JumpTableSupportLevel> JumpTables;
|
extern cl::opt<JumpTableSupportLevel> JumpTables;
|
||||||
|
@ -194,7 +195,7 @@ private:
|
||||||
void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
|
void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
|
||||||
Streamer.InitSections(false);
|
Streamer.InitSections(false);
|
||||||
|
|
||||||
BC.getTextSection()->setAlignment(BC.PageAlign);
|
BC.getTextSection()->setAlignment(opts::AlignText);
|
||||||
|
|
||||||
emitFunctions();
|
emitFunctions();
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,13 @@ extern cl::list<std::string> ReorderData;
|
||||||
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
|
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
|
||||||
extern cl::opt<bool> TimeBuild;
|
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>
|
cl::opt<bool>
|
||||||
Instrument("instrument",
|
Instrument("instrument",
|
||||||
cl::desc("instrument code to generate accurate profile data"),
|
cl::desc("instrument code to generate accurate profile data"),
|
||||||
|
@ -1669,8 +1676,7 @@ void RewriteInstance::adjustCommandLineOptions() {
|
||||||
opts::AlignMacroOpFusion = MFT_NONE;
|
opts::AlignMacroOpFusion = MFT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts::AlignMacroOpFusion != MFT_NONE &&
|
if (opts::AlignMacroOpFusion != MFT_NONE && !BC->HasRelocations) {
|
||||||
!BC->HasRelocations) {
|
|
||||||
outs() << "BOLT-INFO: disabling -align-macro-fusion in non-relocation "
|
outs() << "BOLT-INFO: disabling -align-macro-fusion in non-relocation "
|
||||||
"mode\n";
|
"mode\n";
|
||||||
opts::AlignMacroOpFusion = MFT_NONE;
|
opts::AlignMacroOpFusion = MFT_NONE;
|
||||||
|
@ -1729,6 +1735,10 @@ void RewriteInstance::adjustCommandLineOptions() {
|
||||||
"\n";
|
"\n";
|
||||||
opts::UseOldText = false;
|
opts::UseOldText = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!opts::AlignText.getNumOccurrences()) {
|
||||||
|
opts::AlignText = BC->PageAlign;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -2865,12 +2875,12 @@ void RewriteInstance::mapCodeSections(orc::VModuleKey Key) {
|
||||||
|
|
||||||
if (CodeSize <= BC->OldTextSectionSize) {
|
if (CodeSize <= BC->OldTextSectionSize) {
|
||||||
outs() << "BOLT-INFO: using original .text for new code with 0x"
|
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;
|
AllocationDone = true;
|
||||||
} else {
|
} else {
|
||||||
errs() << "BOLT-WARNING: original .text too small to fit the new code"
|
errs() << "BOLT-WARNING: original .text too small to fit the new code"
|
||||||
<< " using 0x" << Twine::utohexstr(BC->PageAlign)
|
<< " using 0x" << Twine::utohexstr(opts::AlignText)
|
||||||
<< " page alignment. " << CodeSize
|
<< " alignment. " << CodeSize
|
||||||
<< " bytes needed, have " << BC->OldTextSectionSize
|
<< " bytes needed, have " << BC->OldTextSectionSize
|
||||||
<< " bytes available.\n";
|
<< " bytes available.\n";
|
||||||
opts::UseOldText = false;
|
opts::UseOldText = false;
|
||||||
|
|
Loading…
Reference in New Issue