[BOLT] Refactor --keep-nops option. NFC. (#72228)

Run RemoveNops pass only if --keep-nops is set to false (default).
This commit is contained in:
Maksim Panchenko 2023-11-14 11:28:13 -08:00 committed by GitHub
parent b7669ed95f
commit e823136d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 11 deletions

View File

@ -1296,7 +1296,7 @@ public:
/// Return true if the function body is non-contiguous.
bool isSplit() const { return isSimple() && getLayout().isSplit(); }
bool shouldPreserveNops() const;
bool shouldPreserveNops() const { return PreserveNops; }
/// Return true if the function has exception handling tables.
bool hasEHRanges() const { return HasEHRanges; }

View File

@ -4367,10 +4367,6 @@ MCInst *BinaryFunction::getInstructionAtOffset(uint64_t Offset) {
}
}
bool BinaryFunction::shouldPreserveNops() const {
return PreserveNops || opts::KeepNops;
}
void BinaryFunction::printLoopInfo(raw_ostream &OS) const {
if (!opts::shouldPrint(*this))
return;

View File

@ -72,6 +72,11 @@ static cl::opt<bool> JTFootprintReductionFlag(
"instructions at jump sites"),
cl::cat(BoltOptCategory));
static cl::opt<bool>
KeepNops("keep-nops",
cl::desc("keep no-op instructions. By default they are removed."),
cl::Hidden, cl::cat(BoltOptCategory));
cl::opt<bool> NeverPrint("never-print", cl::desc("never print"),
cl::ReallyHidden, cl::cat(BoltOptCategory));
@ -359,7 +364,8 @@ void BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
Manager.registerPass(std::make_unique<ShortenInstructions>(NeverPrint));
Manager.registerPass(std::make_unique<RemoveNops>(NeverPrint));
Manager.registerPass(std::make_unique<RemoveNops>(NeverPrint),
!opts::KeepNops);
Manager.registerPass(std::make_unique<NormalizeCFG>(PrintNormalized));

View File

@ -129,11 +129,6 @@ cl::opt<bool>
cl::desc("instrument code to generate accurate profile data"),
cl::cat(BoltOptCategory));
cl::opt<bool>
KeepNops("keep-nops",
cl::desc("keep no-op instructions. By default they are removed."),
cl::Hidden, cl::cat(BoltOptCategory));
cl::opt<std::string>
OutputFilename("o",
cl::desc("<output file>"),