retdec
|
A manager managing optimizations. More...
#include <optimizer_manager.h>
Public Member Functions | |
OptimizerManager (const StringSet &enabledOpts, const StringSet &disabledOpts, ShPtr< HLLWriter > hllWriter, ShPtr< ValueAnalysis > va, ShPtr< CallInfoObtainer > cio, ShPtr< ArithmExprEvaluator > arithmExprEvaluator, bool enableAggressiveOpts, bool enableDebug=false) | |
Constructs a new optimizer manager. More... | |
void | optimize (ShPtr< Module > m) |
Runs the optimizations over m. More... | |
Private Member Functions | |
void | printOptimization (const std::string &optName) const |
Prints debug information about the currently run optimization with optId. More... | |
bool | optShouldBeRun (const std::string &optName) const |
Returns true if the optimization with optId should be run, false otherwise. More... | |
void | runOptimizerProvidedItShouldBeRun (ShPtr< Optimizer > optimizer) |
Runs the given optimizer provided that it should be run. More... | |
bool | shouldSecondCopyPropagationBeRun () const |
Returns true if a second pass of CopyPropagation should be run, false otherwise. More... | |
template<typename Optimization , typename... Args> | |
void | run (ShPtr< Module > m, Args &&... args) |
Runs the given optimization (specified in the template parameter) over m with the given arguments. More... | |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable ()=default | |
~NonCopyable ()=default | |
Private Attributes | |
const StringSet | enabledOpts |
No other optimization than these will be run. More... | |
const StringSet | disabledOpts |
Optimizations that won't be run. More... | |
ShPtr< HLLWriter > | hllWriter |
Used HLL writer. More... | |
ShPtr< ValueAnalysis > | va |
Used value analysis. More... | |
ShPtr< CallInfoObtainer > | cio |
Used call info obtainer. More... | |
ShPtr< ArithmExprEvaluator > | arithmExprEvaluator |
Used evaluator of arithmetical expressions. More... | |
bool | enableAggressiveOpts |
Enable aggressive optimizations? More... | |
bool | enableDebug |
Enable emission of debug messages? More... | |
bool | recoverFromOutOfMemory |
Should we recover from out-of-memory errors during optimizations? More... | |
StringSet | backendRunOpts |
List of our optimizations that were run. More... | |
A manager managing optimizations.
Instances of this class have reference object semantics. This class is not meant to be subclassed.
retdec::llvmir2hll::OptimizerManager::OptimizerManager | ( | const StringSet & | enabledOpts, |
const StringSet & | disabledOpts, | ||
ShPtr< HLLWriter > | hllWriter, | ||
ShPtr< ValueAnalysis > | va, | ||
ShPtr< CallInfoObtainer > | cio, | ||
ShPtr< ArithmExprEvaluator > | arithmExprEvaluator, | ||
bool | enableAggressiveOpts, | ||
bool | enableDebug = false |
||
) |
Constructs a new optimizer manager.
[in] | enabledOpts | Names of optimizations. No other optimizations than these will be run. |
[in] | disabledOpts | Names of optimizations. These optimizations will not be run. |
[in] | hllWriter | HLL writer. |
[in] | va | Value analysis. |
[in] | cio | Call info obtainer. |
[in] | arithmExprEvaluator | Used evaluator of arithmetical expressions. |
[in] | enableAggressiveOpts | Enables aggressive optimizations. |
[in] | enableDebug | Enables emission of debug messages. |
To perform the actual optimizations, call optimize(). To get a list of available optimizations and their names, see our wiki. The names are class names of optimizers (like CopyPropagationOptimizer). You may or may not include the "Optimizer" suffix.
If enabledOpts is empty, all optimizations are run. If disabledOpts is empty, also all optimizations are run. If an optimization is in both enabledOpts and disabledOpts, it is not run.
Aggressive optimizations are run only if enableAggressiveOpts is true
, or they are specified in enabledOpts.
hllWriter, va, and cio are needed in some optimizations, so they have to be provided.
Runs the optimizations over m.
|
private |
Returns true
if the optimization with optId should be run, false
otherwise.
|
private |
Prints debug information about the currently run optimization with optId.
If enableDebug
is false
, this function does nothing.
|
private |
Runs the given optimization (specified in the template parameter) over m with the given arguments.
Optimization | Optimization to be performed. |
[in] | m | Module to be optimized. |
[in] | args | Arguments to be passed to the optimization. |
If the optimization is in disabledOpts
, it is not run. If enabledOpts
is non-empty and it doesn't contain the optimization, it is also not run.
If enableDebug
is true
, debug messages are emitted.
|
private |
Runs the given optimizer provided that it should be run.
|
private |
Returns true
if a second pass of CopyPropagation should be run, false
otherwise.
|
private |
Used evaluator of arithmetical expressions.
|
private |
List of our optimizations that were run.
|
private |
Used call info obtainer.
|
private |
Optimizations that won't be run.
|
private |
Enable aggressive optimizations?
|
private |
Enable emission of debug messages?
|
private |
No other optimization than these will be run.
|
private |
Should we recover from out-of-memory errors during optimizations?
|
private |
Used value analysis.