-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove --backend-aggressive-opts and all the related code #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
|
@@ -122,11 +121,6 @@ bool Parameters::isBackendEmitCg() const | |
return _backendEmitCg; | ||
} | ||
|
||
bool Parameters::isBackendAggressiveOpts() const | ||
{ | ||
return _backendAggressiveOpts; | ||
} | ||
|
||
bool Parameters::isBackendKeepAllBrackets() const | ||
{ | ||
return _backendKeepAllBrackets; | ||
|
@@ -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; | ||
|
@@ -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()); | ||
|
@@ -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) ); | ||
Comment on lines
576
to
581
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
} | ||
Comment on lines
195
to
200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Recommended Solution: Implement error handling for |
||
|
||
|
@@ -603,7 +603,6 @@ void LlvmIr2Hll::runOptimizations() | |
llvmir2hll::ValueAnalysis::create(aliasAnalysis, true), | ||
cio, | ||
arithmExprEvaluator, | ||
globalConfig->parameters.isBackendAggressiveOpts(), | ||
Debug | ||
) | ||
); | ||
|
@@ -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. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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. | ||
|
@@ -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 | ||
|
@@ -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. | ||
* | ||
|
@@ -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() { | ||
Comment on lines
116
to
125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constructor of Recommendation: Add explicit checks for the validity of these shared pointers and handle the error cases appropriately, possibly by throwing an exception or using an assertion. |
||
PRECONDITION_NON_NULL(hllWriter); | ||
PRECONDITION_NON_NULL(va); | ||
|
@@ -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. | ||
|
@@ -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(); | ||
} | ||
Comment on lines
268
to
269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function Recommendation: Consider adding a warning or error message when |
||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
serdes::serializeBool
function calls are repeated multiple times with similar parameters. This repetition can lead to code bloat and makes the code harder to maintain. Consider refactoring these calls into a loop or a helper function to improve maintainability and reduce redundancy.