[BOLT][AArch64] Fix error message for failed ADR relaxation (#142533)

Do not recommend the strict mode to the user when ADR relaxation fails
on a non-simple function, i.e. a function with unknown CFG.

We cannot rely on relocations to reconstruct compiler-generated jump
tables for AArch64, hence strict mode does not work as intended.
This commit is contained in:
Maksim Panchenko
2025-06-03 11:27:00 -07:00
committed by GitHub
parent b994299e59
commit 8d869637e8
6 changed files with 72 additions and 85 deletions

View File

@@ -81,17 +81,15 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
It = BB.eraseInstruction(std::prev(It));
} else if (std::next(It) != BB.end() && BC.MIB->isNoop(*std::next(It))) {
BB.eraseInstruction(std::next(It));
} else if (!opts::StrictMode && !BF.isSimple()) {
} else if (!BF.isSimple()) {
// If the function is not simple, it may contain a jump table undetected
// by us. This jump table may use an offset from the branch instruction
// to land in the desired place. If we add new instructions, we
// invalidate this offset, so we have to rely on linker-inserted NOP to
// replace it with ADRP, and abort if it is not present.
auto L = BC.scopeLock();
BC.errs() << formatv(
"BOLT-ERROR: Cannot relax adr in non-simple function "
"{0}. Use --strict option to override\n",
BF.getOneName());
BC.errs() << "BOLT-ERROR: cannot relax ADR in non-simple function "
<< BF << '\n';
PassFailed = true;
return;
}