[BOLT] Automatically enable -hot-text

Summary:
Enable -hot-text by default if reordering functions.

Also fail immediately if function reordering is specified on the command
line in non-relocation mode.

(cherry picked from FBD15095178)
This commit is contained in:
Maksim Panchenko 2019-04-25 17:00:05 -07:00
parent 91b2de3c23
commit 492e4a515e
2 changed files with 16 additions and 10 deletions

View File

@ -277,12 +277,6 @@ std::vector<std::string> readFunctionOrderFile() {
}
void ReorderFunctions::runOnFunctions(BinaryContext &BC) {
if (!BC.HasRelocations && opts::ReorderFunctions != RT_NONE) {
errs() << "BOLT-ERROR: Function reordering only works when "
<< "relocs are enabled.\n";
exit(1);
}
auto &BFs = BC.getBinaryFunctions();
if (opts::ReorderFunctions != RT_NONE &&
opts::ReorderFunctions != RT_EXEC_COUNT &&

View File

@ -10,6 +10,7 @@
//===----------------------------------------------------------------------===//
#include "RewriteInstance.h"
#include "BinaryBasicBlock.h"
#include "BinaryContext.h"
#include "BinaryFunction.h"
@ -21,10 +22,10 @@
#include "Exceptions.h"
#include "ExecutableFileMemoryManager.h"
#include "MCPlusBuilder.h"
#include "Passes/ReorderFunctions.h"
#include "ProfileReader.h"
#include "ProfileWriter.h"
#include "Relocation.h"
#include "RewriteInstance.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/Dwarf.h"
@ -89,6 +90,7 @@ extern cl::OptionCategory AggregatorCategory;
extern cl::opt<MacroFusionType> AlignMacroOpFusion;
extern cl::opt<JumpTableSupportLevel> JumpTables;
extern cl::list<std::string> ReorderData;
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
static cl::opt<bool>
ForceToDataRelocations("force-data-relocations",
@ -1799,7 +1801,7 @@ void RewriteInstance::adjustCommandLineOptions() {
}
if (opts::SplitEH && !BC->HasRelocations) {
outs() << "BOLT-WARNING: disabling -split-eh in non-relocation mode\n";
errs() << "BOLT-WARNING: disabling -split-eh in non-relocation mode\n";
opts::SplitEH = false;
}
@ -1812,8 +1814,18 @@ void RewriteInstance::adjustCommandLineOptions() {
opts::AlignMacroOpFusion = MFT_ALL;
}
if (opts::HotText && !BC->HasRelocations) {
outs() << "BOLT-WARNING: hot text is disabled in non-relocation mode\n";
if (!BC->HasRelocations &&
opts::ReorderFunctions != ReorderFunctions::RT_NONE) {
errs() << "BOLT-ERROR: function reordering only works when "
<< "relocations are enabled\n";
exit(1);
}
if (opts::ReorderFunctions != ReorderFunctions::RT_NONE &&
!opts::HotText.getNumOccurrences()) {
opts::HotText = true;
} else if (opts::HotText && !BC->HasRelocations) {
errs() << "BOLT-WARNING: hot text is disabled in non-relocation mode\n";
opts::HotText = false;
}