Skip to content

Commit a47cd94

Browse files
author
kroening
committed
Don't mark as threaded all code following calls to functions that may
be called in a multi-threaded context (but itself does not add threads). git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@6334 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent b486d39 commit a47cd94

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

src/analyses/is_threaded.cpp

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,51 @@ Date: October 2012
88
99
\*******************************************************************/
1010

11-
#include "static_analysis.h"
11+
#include "ai.h"
1212
#include "is_threaded.h"
1313

14-
class is_threaded_domaint:public domain_baset
14+
class is_threaded_domaint:public ai_domain_baset
1515
{
16+
bool has_spawn;
1617
public:
1718
bool is_threaded;
1819

19-
inline is_threaded_domaint():is_threaded(false)
20+
inline is_threaded_domaint():has_spawn(false), is_threaded(false)
2021
{
2122
}
2223

23-
inline bool merge(const is_threaded_domaint &other, locationt to)
24+
inline bool merge(
25+
const is_threaded_domaint &src,
26+
locationt from,
27+
locationt to)
2428
{
25-
bool old=is_threaded;
26-
is_threaded=is_threaded || other.is_threaded;
27-
return old!=is_threaded;
29+
bool old_h_s=has_spawn;
30+
if(src.has_spawn &&
31+
(from->is_end_function() ||
32+
from->function==to->function))
33+
has_spawn=true;
34+
35+
bool old_i_t=is_threaded;
36+
if(has_spawn ||
37+
(src.is_threaded &&
38+
!from->is_end_function()))
39+
is_threaded=true;
40+
41+
return old_i_t!=is_threaded || old_h_s!=has_spawn;
2842
}
2943

3044
void transform(
31-
const namespacet &ns,
3245
locationt from,
33-
locationt to)
46+
locationt to,
47+
ai_baset &ai,
48+
const namespacet &ns)
3449
{
35-
if(from->is_start_thread())
50+
if(from->is_start_thread() ||
51+
to->is_end_thread())
52+
{
53+
has_spawn=true;
3654
is_threaded=true;
55+
}
3756
}
3857
};
3958

@@ -55,9 +74,9 @@ void is_threadedt::compute(const goto_functionst &goto_functions)
5574
symbol_tablet symbol_table;
5675
const namespacet ns(symbol_table);
5776

58-
static_analysist<is_threaded_domaint> is_threaded_analysis(ns);
77+
ait<is_threaded_domaint> is_threaded_analysis;
5978

60-
is_threaded_analysis(goto_functions);
79+
is_threaded_analysis(goto_functions, ns);
6180

6281
for(goto_functionst::function_mapt::const_iterator
6382
f_it=goto_functions.function_map.begin();

0 commit comments

Comments
 (0)