Skip to content

Commit

Permalink
[BOLT] Refactor --keep-nops option. NFC. (llvm#72228)
Browse files Browse the repository at this point in the history
Run RemoveNops pass only if --keep-nops is set to false (default).
  • Loading branch information
maksfb authored Nov 14, 2023
1 parent b7669ed commit e823136
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ class BinaryFunction {
/// 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; }
Expand Down
4 changes: 0 additions & 4 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion bolt/lib/Rewrite/BinaryPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down
5 changes: 0 additions & 5 deletions bolt/lib/Utils/CommandLineOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>"),
Expand Down

0 comments on commit e823136

Please sign in to comment.