Skip to content

Commit 7fe97f0

Browse files
authored
[BOLT] Always run CheckLargeFunctions in non-relocation mode (#80922)
We run CheckLargeFunctions pass in non-relocation mode to prevent the emission of functions that later could not be written to the output due to their large size. The main reason behind the pass is to prevent the emission of metadata for such functions since this metadata becomes incorrect if the function is left unmodified. Currently, the pass is enabled in non-relocation mode only when debug info output is also enabled. As we emit increasingly more kinds of metadata, e.g. for the Linux kernel, it becomes more challenging to track metadata that needs to be fixed. Hence, I'm enabling the pass to always run in non-relocation mode.
1 parent a6f42ad commit 7fe97f0

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,8 @@ void CheckLargeFunctions::runOnFunctions(BinaryContext &BC) {
554554
if (BC.HasRelocations)
555555
return;
556556

557-
if (!opts::UpdateDebugSections)
558-
return;
559-
560557
// If the function wouldn't fit, mark it as non-simple. Otherwise, we may emit
561-
// incorrect debug info.
558+
// incorrect meta data.
562559
ParallelUtilities::WorkFuncTy WorkFun = [&](BinaryFunction &BF) {
563560
uint64_t HotSize, ColdSize;
564561
std::tie(HotSize, ColdSize) =

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,6 +3631,7 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
36313631
Function.setImageAddress(FuncSection->getAllocAddress());
36323632
Function.setImageSize(FuncSection->getOutputSize());
36333633
if (Function.getImageSize() > Function.getMaxSize()) {
3634+
assert(!BC->isX86() && "Unexpected large function.");
36343635
TooLarge = true;
36353636
FailedAddresses.emplace_back(Function.getAddress());
36363637
}
@@ -5367,6 +5368,7 @@ void RewriteInstance::rewriteFile() {
53675368
continue;
53685369

53695370
if (Function->getImageSize() > Function->getMaxSize()) {
5371+
assert(!BC->isX86() && "Unexpected large function.");
53705372
if (opts::Verbosity >= 1)
53715373
errs() << "BOLT-WARNING: new function size (0x"
53725374
<< Twine::utohexstr(Function->getImageSize())

0 commit comments

Comments
 (0)