Skip to content

Commit

Permalink
remove --backend-aggressive-opts and all the related code
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMatula committed Oct 1, 2021
1 parent 9eeb7db commit eba8d78
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 307 deletions.
3 changes: 0 additions & 3 deletions include/retdec/config/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class Parameters
bool isBackendNoOpts() const;
bool isBackendEmitCfg() const;
bool isBackendEmitCg() const;
bool isBackendAggressiveOpts() const;
bool isBackendKeepAllBrackets() const;
bool isBackendKeepLibraryFuncs() const;
bool isBackendNoTimeVaryingInfo() const;
Expand Down Expand Up @@ -76,7 +75,6 @@ class Parameters
void setIsBackendNoOpts(bool b);
void setIsBackendEmitCfg(bool b);
void setIsBackendEmitCg(bool b);
void setIsBackendAggressiveOpts(bool b);
void setIsBackendKeepAllBrackets(bool b);
void setIsBackendKeepLibraryFuncs(bool b);
void setIsBackendNoTimeVaryingInfo(bool b);
Expand Down Expand Up @@ -176,7 +174,6 @@ class Parameters
bool _backendNoOpts = false;
bool _backendEmitCfg = false;
bool _backendEmitCg = false;
bool _backendAggressiveOpts = false;
bool _backendKeepAllBrackets = false;
bool _backendKeepLibraryFuncs = false;
bool _backendNoTimeVaryingInfo = false;
Expand Down
1 change: 0 additions & 1 deletion include/retdec/llvmir2hll/llvmir2hll.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class LlvmIr2Hll: public llvm::ModulePass

llvmir2hll::StringSet parseListOfOpts(
const std::string &opts) const;
std::string getTypeOfRunOptimizations() const;
llvmir2hll::StringVector getIdsOfPatternFindersToBeRun() const;
llvmir2hll::PatternFinderRunner::PatternFinders instantiatePatternFinders(
const llvmir2hll::StringVector &pfsIds);
Expand Down
5 changes: 1 addition & 4 deletions include/retdec/llvmir2hll/optimizer/optimizer_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OptimizerManager final: private retdec::utils::NonCopyable {
OptimizerManager(const StringSet &enabledOpts, const StringSet &disabledOpts,
ShPtr<HLLWriter> hllWriter, ShPtr<ValueAnalysis> va,
ShPtr<CallInfoObtainer> cio, ShPtr<ArithmExprEvaluator> arithmExprEvaluator,
bool enableAggressiveOpts, bool enableDebug = false);
bool enableDebug = false);

void optimize(ShPtr<Module> m);

Expand Down Expand Up @@ -64,9 +64,6 @@ class OptimizerManager final: private retdec::utils::NonCopyable {
/// Used evaluator of arithmetical expressions.
ShPtr<ArithmExprEvaluator> arithmExprEvaluator;

/// Enable aggressive optimizations?
bool enableAggressiveOpts;

/// Enable emission of debug messages?
bool enableDebug;

Expand Down

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions src/config/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const std::string JSON_backendVarRenamer = "backendVarRenamer";
const std::string JSON_backendNoOpts = "backendNoOpts";
const std::string JSON_backendEmitCfg = "backendEmitCfg";
const std::string JSON_backendEmitCg = "backendEmitCg";
const std::string JSON_backendAggressiveOpts = "backendAggressiveOpts";
const std::string JSON_backendKeepAllBrackets = "backendKeepAllBrackets";
const std::string JSON_backendKeepLibraryFuncs = "backendKeepLibraryFuncs";
const std::string JSON_backendNoTimeVaryingInfo = "backendNoTimeVaryingInfo";
Expand Down Expand Up @@ -122,11 +121,6 @@ bool Parameters::isBackendEmitCg() const
return _backendEmitCg;
}

bool Parameters::isBackendAggressiveOpts() const
{
return _backendAggressiveOpts;
}

bool Parameters::isBackendKeepAllBrackets() const
{
return _backendKeepAllBrackets;
Expand Down Expand Up @@ -306,11 +300,6 @@ void Parameters::setIsBackendEmitCg(bool b)
_backendEmitCg = b;
}

void Parameters::setIsBackendAggressiveOpts(bool b)
{
_backendAggressiveOpts = b;
}

void Parameters::setIsBackendKeepAllBrackets(bool b)
{
_backendKeepAllBrackets = b;
Expand Down Expand Up @@ -519,7 +508,6 @@ void Parameters::serialize(Writer& writer) const
serdes::serializeBool(writer, JSON_backendEmitCfg, isBackendEmitCfg());
serdes::serializeBool(writer, JSON_backendEmitCg, isBackendEmitCg());
serdes::serializeBool(writer, JSON_detectStaticCode, isDetectStaticCode());
serdes::serializeBool(writer, JSON_backendAggressiveOpts, isBackendAggressiveOpts());
serdes::serializeBool(writer, JSON_backendKeepAllBrackets, isBackendKeepAllBrackets());
serdes::serializeBool(writer, JSON_backendKeepLibraryFuncs, isBackendKeepLibraryFuncs());
serdes::serializeBool(writer, JSON_backendNoTimeVaryingInfo, isBackendNoTimeVaryingInfo());
Expand Down Expand Up @@ -588,7 +576,6 @@ void Parameters::deserialize(const rapidjson::Value& val)
setIsBackendNoOpts( serdes::deserializeBool(val, JSON_backendNoOpts, false) );
setIsBackendEmitCfg( serdes::deserializeBool(val, JSON_backendEmitCfg, false) );
setIsBackendEmitCg( serdes::deserializeBool(val, JSON_backendEmitCg, false) );
setIsBackendAggressiveOpts( serdes::deserializeBool(val, JSON_backendAggressiveOpts, false) );
setIsBackendKeepAllBrackets( serdes::deserializeBool(val, JSON_backendKeepAllBrackets, false) );
setIsBackendKeepLibraryFuncs( serdes::deserializeBool(val, JSON_backendKeepLibraryFuncs, false) );
setIsBackendNoTimeVaryingInfo( serdes::deserializeBool(val, JSON_backendNoTimeVaryingInfo, false) );
Expand Down
2 changes: 0 additions & 2 deletions src/llvmir2hll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ add_library(llvmir2hll STATIC
optimizer/func_optimizer.cpp
optimizer/optimizer.cpp
optimizer/optimizer_manager.cpp
optimizer/optimizers/aggressive_deref_optimizer.cpp
optimizer/optimizers/aggressive_global_to_local_optimizer.cpp
optimizer/optimizers/bit_op_to_log_op_optimizer.cpp
optimizer/optimizers/bit_shift_optimizer.cpp
optimizer/optimizers/break_continue_return_optimizer.cpp
Expand Down
13 changes: 1 addition & 12 deletions src/llvmir2hll/llvmir2hll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool LlvmIr2Hll::runOnModule(llvm::Module &m)
Log::phase("alias analysis [" + aliasAnalysis->getId() + "]");
initAliasAnalysis();

Log::phase("optimizations [" + getTypeOfRunOptimizations() + "]");
Log::phase("optimizations");
runOptimizations();
}

Expand Down Expand Up @@ -603,7 +603,6 @@ void LlvmIr2Hll::runOptimizations()
llvmir2hll::ValueAnalysis::create(aliasAnalysis, true),
cio,
arithmExprEvaluator,
globalConfig->parameters.isBackendAggressiveOpts(),
Debug
)
);
Expand Down Expand Up @@ -844,16 +843,6 @@ retdec::llvmir2hll::StringSet LlvmIr2Hll::parseListOfOpts(
return llvmir2hll::StringSet(parsedOpts.begin(), parsedOpts.end());
}

/**
* @brief Returns the type of optimizations that should be run (as a string).
*/
std::string LlvmIr2Hll::getTypeOfRunOptimizations() const
{
return globalConfig->parameters.isBackendAggressiveOpts()
? "aggressive"
: "normal";
}

/**
* @brief Returns the IDs of pattern finders to be run.
*/
Expand Down
25 changes: 2 additions & 23 deletions src/llvmir2hll/optimizer/optimizer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "retdec/llvmir2hll/hll/hll_writer.h"
#include "retdec/llvmir2hll/obtainer/call_info_obtainer.h"
#include "retdec/llvmir2hll/optimizer/optimizer_manager.h"
#include "retdec/llvmir2hll/optimizer/optimizers/aggressive_deref_optimizer.h"
#include "retdec/llvmir2hll/optimizer/optimizers/aggressive_global_to_local_optimizer.h"
#include "retdec/llvmir2hll/optimizer/optimizers/bit_op_to_log_op_optimizer.h"
#include "retdec/llvmir2hll/optimizer/optimizers/bit_shift_optimizer.h"
#include "retdec/llvmir2hll/optimizer/optimizers/break_continue_return_optimizer.h"
Expand Down Expand Up @@ -65,9 +63,6 @@ namespace {
/// Suffix of all optimizers.
const std::string OPT_SUFFIX = "Optimizer";

/// Prefix of aggressive optimizations.
const std::string AGGRESSIVE_OPTS_PREFIX = "Aggressive";

/**
* @brief Trims the optional suffix "Optimizer" from all optimization names in
* @a opts.
Expand Down Expand Up @@ -101,7 +96,6 @@ StringSet trimOptimizerSuffix(const StringSet &opts) {
* @param[in] va Value analysis.
* @param[in] cio Call info obtainer.
* @param[in] arithmExprEvaluator Used evaluator of arithmetical expressions.
* @param[in] enableAggressiveOpts Enables aggressive optimizations.
* @param[in] enableDebug Enables emission of debug messages.
*
* To perform the actual optimizations, call optimize(). To get a list of
Expand All @@ -113,9 +107,6 @@ StringSet trimOptimizerSuffix(const StringSet &opts) {
* empty, also all optimizations are run. If an optimization is in both @a
* enabledOpts and @a disabledOpts, it is not run.
*
* Aggressive optimizations are run only if @a enableAggressiveOpts is @c true, or
* they are specified in @a enabledOpts.
*
* @a hllWriter, @a va, and @a cio are needed in some optimizations, so they
* have to be provided.
*
Expand All @@ -125,13 +116,12 @@ StringSet trimOptimizerSuffix(const StringSet &opts) {
OptimizerManager::OptimizerManager(const StringSet &enabledOpts,
const StringSet &disabledOpts, ShPtr<HLLWriter> hllWriter,
ShPtr<ValueAnalysis> va, ShPtr<CallInfoObtainer> cio,
ShPtr<ArithmExprEvaluator> arithmExprEvaluator,
bool enableAggressiveOpts, bool enableDebug):
ShPtr<ArithmExprEvaluator> arithmExprEvaluator, bool enableDebug):
enabledOpts(trimOptimizerSuffix(enabledOpts)),
disabledOpts(trimOptimizerSuffix(disabledOpts)),
hllWriter(hllWriter), va(va), cio(cio),
arithmExprEvaluator(arithmExprEvaluator),
enableAggressiveOpts(enableAggressiveOpts), enableDebug(enableDebug),
enableDebug(enableDebug),
recoverFromOutOfMemory(true), backendRunOpts() {
PRECONDITION_NON_NULL(hllWriter);
PRECONDITION_NON_NULL(va);
Expand Down Expand Up @@ -162,12 +152,6 @@ void OptimizerManager::optimize(ShPtr<Module> m) {
run<GotoStmtOptimizer>(m);
run<RemoveUselessCastsOptimizer>(m);

// The first part of removal of non-compound statements. The other part
// should be run after structure optimizations because they may introduce
// constructs that can be optimized.
run<AggressiveDerefOptimizer>(m);
run<AggressiveGlobalToLocalOptimizer>(m);

// Data-flow optimizations.
// The following optimizations should be run before CopyPropagation to
// speed it up.
Expand Down Expand Up @@ -281,11 +265,6 @@ bool OptimizerManager::optShouldBeRun(const std::string &optId) const {
return true;
}

if (enabledOpts.empty() && startsWith(optId, AGGRESSIVE_OPTS_PREFIX)) {
// It is an aggressive optimization.
return enableAggressiveOpts;
}

return enabledOpts.empty();
}

Expand Down
75 changes: 0 additions & 75 deletions src/llvmir2hll/optimizer/optimizers/aggressive_deref_optimizer.cpp

This file was deleted.

Loading

0 comments on commit eba8d78

Please sign in to comment.