forked from OSchip/llvm-project
Always split functions under '-split-functions=1' option.
Summary: Force the splitting of the function into hot/cold even when the function fits into original slot. This reduces BOLT optimization time by 50% without affecting hhvm performance. (cherry picked from FBD2973773)
This commit is contained in:
parent
73e9afe99c
commit
62da18d32a
|
@ -472,18 +472,6 @@ void RewriteInstance::run() {
|
|||
runOptimizationPasses();
|
||||
emitFunctions();
|
||||
|
||||
if (opts::SplitFunctions && splitLargeFunctions()) {
|
||||
// Emit again because now some functions have been split
|
||||
outs() << "BOLT: split-functions: starting pass 2...\n";
|
||||
reset();
|
||||
discoverStorage();
|
||||
readSymbolTable();
|
||||
readSpecialSections();
|
||||
disassembleFunctions();
|
||||
runOptimizationPasses();
|
||||
emitFunctions();
|
||||
}
|
||||
|
||||
// Copy input file to output
|
||||
std::error_code EC;
|
||||
Out = llvm::make_unique<tool_output_file>(opts::OutputFilename, EC,
|
||||
|
@ -838,8 +826,7 @@ void RewriteInstance::runOptimizationPasses() {
|
|||
}
|
||||
|
||||
if (opts::ReorderBlocks != BinaryFunction::LT_NONE) {
|
||||
bool ShouldSplit = ToSplit.find(BFI.first) != ToSplit.end();
|
||||
BFI.second.modifyLayout(opts::ReorderBlocks, ShouldSplit);
|
||||
BFI.second.modifyLayout(opts::ReorderBlocks, opts::SplitFunctions);
|
||||
if (opts::PrintAll || opts::PrintReordered)
|
||||
Function.print(errs(), "after reordering blocks");
|
||||
}
|
||||
|
@ -1225,24 +1212,6 @@ void RewriteInstance::emitFunctions() {
|
|||
TempOut->keep();
|
||||
}
|
||||
|
||||
bool RewriteInstance::splitLargeFunctions() {
|
||||
bool Changed = false;
|
||||
for (auto &BFI : BinaryFunctions) {
|
||||
auto &Function = BFI.second;
|
||||
|
||||
// Ignore this function if we failed to map it to the output binary
|
||||
if (Function.getImageAddress() == 0 || Function.getImageSize() == 0)
|
||||
continue;
|
||||
|
||||
if (Function.getImageSize() <= Function.getMaxSize())
|
||||
continue;
|
||||
|
||||
ToSplit.insert(BFI.first);
|
||||
Changed = true;
|
||||
}
|
||||
return Changed;
|
||||
}
|
||||
|
||||
void RewriteInstance::patchELF() {
|
||||
auto ELF64LEFile = dyn_cast<ELF64LEObjectFile>(File);
|
||||
if (!ELF64LEFile) {
|
||||
|
|
|
@ -127,13 +127,6 @@ public:
|
|||
/// performing final relaxation.
|
||||
void emitFunctions();
|
||||
|
||||
/// Check which functions became larger than their original version and
|
||||
/// annotate function splitting information.
|
||||
///
|
||||
/// Returns true if any function was annotated, requiring us to perform a
|
||||
/// second pass to emit those functions in two parts.
|
||||
bool splitLargeFunctions();
|
||||
|
||||
/// Rewrite back all functions (hopefully optimized) that fit in the original
|
||||
/// memory footprint for that function. If the function is now larger and does
|
||||
/// not fit in the binary, reject it and preserve the original version of the
|
||||
|
@ -213,9 +206,6 @@ private:
|
|||
/// rewriting CFI info for these functions.
|
||||
std::vector<uint64_t> FailedAddresses;
|
||||
|
||||
/// Keep track of which functions to split in a second pass.
|
||||
std::set<uint64_t> ToSplit;
|
||||
|
||||
/// Total hotness score according to profiling data for this binary.
|
||||
uint64_t TotalScore{0};
|
||||
|
||||
|
|
Loading…
Reference in New Issue