diff options
author | Maksim Panchenko <maks@fb.com> | 2023-11-14 11:28:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 11:28:13 -0800 |
commit | e823136d43c40b0a9ba6930fd285768f1b46fcb6 (patch) | |
tree | ee8d415f215213562c9ae6d8a7fc2d1b4da50f04 /bolt | |
parent | b7669ed95f32a947f58909314c91053de1cff562 (diff) | |
download | llvm-e823136d43c40b0a9ba6930fd285768f1b46fcb6.zip llvm-e823136d43c40b0a9ba6930fd285768f1b46fcb6.tar.gz llvm-e823136d43c40b0a9ba6930fd285768f1b46fcb6.tar.bz2 |
[BOLT] Refactor --keep-nops option. NFC. (#72228)
Run RemoveNops pass only if --keep-nops is set to false (default).
Diffstat (limited to 'bolt')
-rw-r--r-- | bolt/include/bolt/Core/BinaryFunction.h | 2 | ||||
-rw-r--r-- | bolt/lib/Core/BinaryFunction.cpp | 4 | ||||
-rw-r--r-- | bolt/lib/Rewrite/BinaryPassManager.cpp | 8 | ||||
-rw-r--r-- | bolt/lib/Utils/CommandLineOpts.cpp | 5 |
4 files changed, 8 insertions, 11 deletions
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h index b1adf2d..63c0b11 100644 --- a/bolt/include/bolt/Core/BinaryFunction.h +++ b/bolt/include/bolt/Core/BinaryFunction.h @@ -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; } diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 1f4a7cc..7559c37 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -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; diff --git a/bolt/lib/Rewrite/BinaryPassManager.cpp b/bolt/lib/Rewrite/BinaryPassManager.cpp index cd27c71..37de3ea 100644 --- a/bolt/lib/Rewrite/BinaryPassManager.cpp +++ b/bolt/lib/Rewrite/BinaryPassManager.cpp @@ -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)); diff --git a/bolt/lib/Utils/CommandLineOpts.cpp b/bolt/lib/Utils/CommandLineOpts.cpp index 0c0e83c..a1df5de 100644 --- a/bolt/lib/Utils/CommandLineOpts.cpp +++ b/bolt/lib/Utils/CommandLineOpts.cpp @@ -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>"), |