[llvm] 740a1da - [NFC] SimplifyCFG: refactor/deduplicate command-line settings override handling
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 16 03:40:32 PDT 2020
Author: Roman Lebedev
Date: 2020-07-16T13:40:02+03:00
New Revision: 740a1da108ab9097268b509c85ed9ede7f4d5df5
URL: https://github.com/llvm/llvm-project/commit/740a1da108ab9097268b509c85ed9ede7f4d5df5
DIFF: https://github.com/llvm/llvm-project/commit/740a1da108ab9097268b509c85ed9ede7f4d5df5.diff
LOG: [NFC] SimplifyCFG: refactor/deduplicate command-line settings override handling
Added:
Modified:
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index d48d5408dd3c..9d810a1ecfa6 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -213,22 +213,21 @@ static bool simplifyFunctionCFG(Function &F, const TargetTransformInfo &TTI,
}
// Command-line settings override compile-time settings.
+static void applyCommandLineOverridesToOptions(SimplifyCFGOptions &Options) {
+ if (UserBonusInstThreshold.getNumOccurrences())
+ Options.BonusInstThreshold = UserBonusInstThreshold;
+ if (UserForwardSwitchCond.getNumOccurrences())
+ Options.ForwardSwitchCondToPhi = UserForwardSwitchCond;
+ if (UserSwitchToLookup.getNumOccurrences())
+ Options.ConvertSwitchToLookupTable = UserSwitchToLookup;
+ if (UserKeepLoops.getNumOccurrences())
+ Options.NeedCanonicalLoop = UserKeepLoops;
+ if (UserSinkCommonInsts.getNumOccurrences())
+ Options.SinkCommonInsts = UserSinkCommonInsts;
+}
+
SimplifyCFGPass::SimplifyCFGPass(const SimplifyCFGOptions &Opts) {
- Options.BonusInstThreshold = UserBonusInstThreshold.getNumOccurrences()
- ? UserBonusInstThreshold
- : Opts.BonusInstThreshold;
- Options.ForwardSwitchCondToPhi = UserForwardSwitchCond.getNumOccurrences()
- ? UserForwardSwitchCond
- : Opts.ForwardSwitchCondToPhi;
- Options.ConvertSwitchToLookupTable = UserSwitchToLookup.getNumOccurrences()
- ? UserSwitchToLookup
- : Opts.ConvertSwitchToLookupTable;
- Options.NeedCanonicalLoop = UserKeepLoops.getNumOccurrences()
- ? UserKeepLoops
- : Opts.NeedCanonicalLoop;
- Options.SinkCommonInsts = UserSinkCommonInsts.getNumOccurrences()
- ? UserSinkCommonInsts
- : Opts.SinkCommonInsts;
+ applyCommandLineOverridesToOptions(Options);
}
PreservedAnalyses SimplifyCFGPass::run(Function &F,
@@ -255,20 +254,7 @@ struct CFGSimplifyPass : public FunctionPass {
initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry());
// Check for command-line overrides of options for debug/customization.
- if (UserBonusInstThreshold.getNumOccurrences())
- Options.BonusInstThreshold = UserBonusInstThreshold;
-
- if (UserForwardSwitchCond.getNumOccurrences())
- Options.ForwardSwitchCondToPhi = UserForwardSwitchCond;
-
- if (UserSwitchToLookup.getNumOccurrences())
- Options.ConvertSwitchToLookupTable = UserSwitchToLookup;
-
- if (UserKeepLoops.getNumOccurrences())
- Options.NeedCanonicalLoop = UserKeepLoops;
-
- if (UserSinkCommonInsts.getNumOccurrences())
- Options.SinkCommonInsts = UserSinkCommonInsts;
+ applyCommandLineOverridesToOptions(Options);
}
bool runOnFunction(Function &F) override {
More information about the llvm-commits
mailing list