From 7ef508afbc4651362f05e0989f7a1700f50a5f22 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 9 Jun 2009 07:42:33 +0000 Subject: Add initial support for constant Arrays. - This doesn't actually start using them, it just attempts to update all clients to do the right thing in the presence of them. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@73130 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Solver/FastCexSolver.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'lib/Solver/FastCexSolver.cpp') diff --git a/lib/Solver/FastCexSolver.cpp b/lib/Solver/FastCexSolver.cpp index 608388bb..af2666ab 100644 --- a/lib/Solver/FastCexSolver.cpp +++ b/lib/Solver/FastCexSolver.cpp @@ -341,7 +341,13 @@ public: CexRangeEvaluator(std::map &_objects) : objects(_objects) {} - ValueRange getInitialReadRange(const Array &os, ValueRange index) { + ValueRange getInitialReadRange(const Array &array, ValueRange index) { + // Check for a concrete read of a constant array. + if (array.isConstantArray() && + index.isFixed() && + index.min() < array.size) + return ValueRange(array.constantValues[index.min()]->getConstantValue()); + return ValueRange(0, 255); } }; @@ -765,16 +771,22 @@ public: // We reached the initial array write, update the exact range if possible. if (index.isFixed()) { - CexValueData cvd = cod.getExactValues(index.min()); - if (range.min() > cvd.min()) { - assert(range.min() <= cvd.max()); - cvd = CexValueData(range.min(), cvd.max()); - } - if (range.max() < cvd.max()) { - assert(range.max() >= cvd.min()); - cvd = CexValueData(cvd.min(), range.max()); + if (array->isConstantArray()) { + // Verify the range. + propogateExactValues(array->constantValues[index.min()], + range); + } else { + CexValueData cvd = cod.getExactValues(index.min()); + if (range.min() > cvd.min()) { + assert(range.min() <= cvd.max()); + cvd = CexValueData(range.min(), cvd.max()); + } + if (range.max() < cvd.max()) { + assert(range.max() >= cvd.min()); + cvd = CexValueData(cvd.min(), range.max()); + } + cod.setExactValues(index.min(), cvd); } - cod.setExactValues(index.min(), cvd); } break; } -- cgit 1.4.1