Skip to content

Commit 11d826f

Browse files
authored
Merge pull request diffblue#449 from diffblue/smowton/fix/csvsa-sort-working-set
CSVSA: sort the working set to prioritise earlier and deeper instructions
2 parents c66d094 + c26679f commit 11d826f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/pointer-analysis/context_sensitive_value_set_analysis.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,17 @@ csvsa_load_and_analyze_functions(
641641
return driver;
642642
}
643643

644+
bool context_sensitive_value_set_analysis_drivert
645+
::compare_working_set_entriest::operator()(
646+
const working_set_entryt &a, const working_set_entryt &b)
647+
{
648+
// In the same context, investigate earlier instructions first.
649+
// Of differing contexts, investigate the one created later first (this
650+
// favours investigating a callee before continuing to look at its caller).
651+
if(a.first == b.first)
652+
return a.second->location_number < b.second->location_number;
653+
else
654+
return a.first > b.first;
655+
}
656+
644657
const goto_functionst csvsa_function_contextt::empty_goto_functions;

src/pointer-analysis/context_sensitive_value_set_analysis.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,23 @@ class context_sensitive_value_set_analysis_drivert : public messaget
7676
/// pointed at the usual goto_modelt or similar in future.
7777
const get_goto_programt get_goto_program;
7878

79+
typedef std::pair<context_indext, locationt> working_set_entryt;
80+
81+
/// Compares two working set entries, ordering those with higher context
82+
/// numbers first (favouring callees over callers) and then lower location
83+
/// numbers (favouring complete exploration of a loop, for example, before
84+
/// its successors, assuming programs generally flow forwards)
85+
struct compare_working_set_entriest
86+
{
87+
bool operator()(const working_set_entryt &a, const working_set_entryt &b);
88+
};
89+
7990
/// Working set, containing <context-pointer, instruction> pairs (constrast
8091
/// the normal value-set analysis working set, which only contains
8192
/// instructions). Pointers are non-owning, and are never held beyond the
8293
/// lifespan of `context_graph` (which owns the contexts).
83-
std::set<std::pair<context_indext, locationt>> working_set;
94+
std::set<std::pair<context_indext, locationt>, compare_working_set_entriest>
95+
working_set;
8496

8597
/// Graph of analysis contexts, each concerning a particular use context of a
8698
/// particular function (e.g. "function f when called from main line 5")

0 commit comments

Comments
 (0)