diff options
author | Lukas Wölfer <lukas.woelfer@rwth-aachen.de> | 2017-06-24 19:31:04 +0200 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2018-05-15 15:18:36 +0100 |
commit | e5a18f47a8cdd37a5c2721e89df68ea7aafed8a0 (patch) | |
tree | 620bd0ab0ce7f737db5ab7f8f656d32ea0849f4a /lib/Core/Searcher.cpp | |
parent | 0cf0150da0f674c85f9eaccee8b487ed004c3edc (diff) | |
download | klee-e5a18f47a8cdd37a5c2721e89df68ea7aafed8a0.tar.gz |
Implemented incomplete merging
Diffstat (limited to 'lib/Core/Searcher.cpp')
-rw-r--r-- | lib/Core/Searcher.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp index 05ebe6a6..dfeb15de 100644 --- a/lib/Core/Searcher.cpp +++ b/lib/Core/Searcher.cpp @@ -15,6 +15,7 @@ #include "StatsTracker.h" #include "klee/ExecutionState.h" +#include "klee/MergeHandler.h" #include "klee/Statistics.h" #include "klee/Internal/Module/InstructionInfoTable.h" #include "klee/Internal/Module/KInstruction.h" @@ -42,6 +43,7 @@ using namespace klee; using namespace llvm; + namespace klee { extern RNG theRNG; } @@ -257,7 +259,6 @@ bool WeightedRandomSearcher::empty() { } /// - RandomPathSearcher::RandomPathSearcher(Executor &_executor) : executor(_executor) { } @@ -268,7 +269,6 @@ RandomPathSearcher::~RandomPathSearcher() { ExecutionState &RandomPathSearcher::selectState() { unsigned flips=0, bits=0; PTree::Node *n = executor.processTree->root; - while (!n->data) { if (!n->left) { n = n->right; @@ -299,6 +299,42 @@ bool RandomPathSearcher::empty() { /// +MergingSearcher::MergingSearcher(Executor &_executor, Searcher *_baseSearcher) + : executor(_executor), + baseSearcher(_baseSearcher){} + +MergingSearcher::~MergingSearcher() { + delete baseSearcher; +} + +ExecutionState& MergingSearcher::selectState() { + assert(!baseSearcher->empty() && "base searcher is empty"); + + // Iterate through all MergeHandlers + for (auto cur_mergehandler: executor.mergeGroups) { + // Find one that has states that could be released + if (!cur_mergehandler->hasMergedStates()) { + continue; + } + // Find a state that can be prioritized + ExecutionState *es = cur_mergehandler->getPrioritizeState(); + if (es) { + return *es; + } else { + if (DebugLogIncompleteMerge){ + llvm::errs() << "Preemptively releasing states\n"; + } + // If no state can be prioritized, they all exceeded the amount of time we + // are willing to wait for them. Release the states that already arrived at close_merge. + cur_mergehandler->releaseStates(); + } + } + // If we were not able to prioritize a merging state, just return some state + return baseSearcher->selectState(); +} + +/// + BatchingSearcher::BatchingSearcher(Searcher *_baseSearcher, double _timeBudget, unsigned _instructionBudget) |