diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2018-10-17 22:39:06 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2018-10-23 18:53:46 +0300 |
commit | 713c1a3744aa8c0bfadf85a76377dd2c7dd63519 (patch) | |
tree | 6083e195f3d27791598bbf7a1976ef2a2379c84c /lib/Expr | |
parent | ca1a1083a8a9cce249dd46511072c00676a4c3d5 (diff) | |
download | klee-713c1a3744aa8c0bfadf85a76377dd2c7dd63519.tar.gz |
optimizeExpr: return the result as return value instead as function argument
simplifies code a lot.
Diffstat (limited to 'lib/Expr')
-rw-r--r-- | lib/Expr/ArrayExprOptimizer.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Expr/ArrayExprOptimizer.cpp b/lib/Expr/ArrayExprOptimizer.cpp index 3a071665..2d817e83 100644 --- a/lib/Expr/ArrayExprOptimizer.cpp +++ b/lib/Expr/ArrayExprOptimizer.cpp @@ -42,20 +42,17 @@ llvm::cl::opt<double> ArrayValueSymbRatio( llvm::cl::init(1.0), llvm::cl::value_desc("Symbolic Values / Array Size")); }; -void ExprOptimizer::optimizeExpr(const ref<Expr> &e, ref<Expr> &result, - bool valueOnly) { +ref<Expr> ExprOptimizer::optimizeExpr(const ref<Expr> &e, bool valueOnly) { unsigned hash = e->hash(); - if (cacheExprUnapplicable.find(hash) != cacheExprUnapplicable.end()) { - return; - } + if (cacheExprUnapplicable.find(hash) != cacheExprUnapplicable.end()) + return e; // Find cached expressions auto cached = cacheExprOptimized.find(hash); - if (cached != cacheExprOptimized.end()) { - result = cached->second; - return; - } + if (cached != cacheExprOptimized.end()) + return cached->second; + ref<Expr> result; // ----------------------- INDEX-BASED OPTIMIZATION ------------------------- if (!valueOnly && (OptimizeArray == ALL || OptimizeArray == INDEX)) { array2idx_ty arrays; @@ -69,7 +66,7 @@ void ExprOptimizer::optimizeExpr(const ref<Expr> &e, ref<Expr> &result, // when we are not combining the optimizations if (OptimizeArray == INDEX) { cacheExprUnapplicable.insert(hash); - return; + return e; } } else { mapIndexOptimizedExpr_ty idx_valIdx; @@ -107,7 +104,7 @@ void ExprOptimizer::optimizeExpr(const ref<Expr> &e, ref<Expr> &result, if (reads.size() == 0 || are.isIncompatible()) { cacheExprUnapplicable.insert(hash); - return; + return e; } ref<Expr> selectOpt = @@ -121,6 +118,9 @@ void ExprOptimizer::optimizeExpr(const ref<Expr> &e, ref<Expr> &result, cacheExprUnapplicable.insert(hash); } } + if (result.isNull()) + return e; + return result; } bool ExprOptimizer::computeIndexes(array2idx_ty &arrays, const ref<Expr> &e, |