Skip to content

Commit 0084739

Browse files
committed
goto-instrument/wmm: do not lookup non-existent symbols in the namespace
Making up function names on the spot resulted in failing namespace lookups. Avoid those lookups altogether and pass in a known symbol. The made-up name should instead be constructed via the suffix parameter, which supports exactly this use case.
1 parent c35696b commit 0084739

File tree

13 files changed

+37
-63
lines changed

13 files changed

+37
-63
lines changed

regression/goto-instrument-wmm-core/ppc_aclwdrr005_POWER_ALL/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
aclwdrr005.c
33
POWER ALL
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwdrr005_POWER_OPC/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
aclwdrr005.c
33
POWER OPC
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwdrr015_POWER_ALL/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwdrr015.c
33
POWER ALL
44
^EXIT=10$

regression/goto-instrument-wmm-core/ppc_aclwdrr015_POWER_OPC/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwdrr015.c
33
POWER OPC
44
^EXIT=10$

regression/goto-instrument-wmm-core/ppc_aclwsrr000_RMO_ALL/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwsrr000.c
33
RMO ALL
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwsrr000_RMO_OPC/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwsrr000.c
33
RMO OPC
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwsrr002_POWER_ALL/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwsrr002.c
33
POWER ALL
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwsrr002_POWER_OPC/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwsrr002.c
33
POWER OPC
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwsrr002_RMO_ALL/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwsrr002.c
33
RMO ALL
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_aclwsrr002_RMO_OPC/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
aclwsrr002.c
33
RMO OPC
44
^EXIT=0$

regression/goto-instrument-wmm-core/ppc_safe004_POWER_OPC/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
THOROUGH
22
safe004.c
33
POWER OPC
44
^EXIT=0$

src/goto-instrument/wmm/shared_buffers.cpp

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,25 @@ const shared_bufferst::varst &shared_bufferst::operator()(
4141

4242
vars.type=symbol.type;
4343

44-
vars.w_buff0=add(object, symbol.base_name, "$w_buff0", symbol.type);
45-
vars.w_buff1=add(object, symbol.base_name, "$w_buff1", symbol.type);
44+
vars.w_buff0 = add(symbol, "$w_buff0", symbol.type);
45+
vars.w_buff1 = add(symbol, "$w_buff1", symbol.type);
4646

47-
vars.w_buff0_used=add(object, symbol.base_name, "$w_buff0_used",
48-
bool_typet());
49-
vars.w_buff1_used=add(object, symbol.base_name, "$w_buff1_used",
50-
bool_typet());
47+
vars.w_buff0_used = add(symbol, "$w_buff0_used", bool_typet());
48+
vars.w_buff1_used = add(symbol, "$w_buff1_used", bool_typet());
5149

52-
vars.mem_tmp=add(object, symbol.base_name, "$mem_tmp", symbol.type);
53-
vars.flush_delayed=add(object, symbol.base_name, "$flush_delayed",
54-
bool_typet());
50+
vars.mem_tmp = add(symbol, "$mem_tmp", symbol.type);
51+
vars.flush_delayed = add(symbol, "$flush_delayed", bool_typet());
5552

56-
vars.read_delayed=
57-
add(object, symbol.base_name, "$read_delayed", bool_typet());
58-
vars.read_delayed_var=
59-
add(
60-
object,
61-
symbol.base_name,
62-
"$read_delayed_var",
63-
pointer_type(symbol.type));
53+
vars.read_delayed = add(symbol, "$read_delayed", bool_typet());
54+
vars.read_delayed_var =
55+
add(symbol, "$read_delayed_var", pointer_type(symbol.type));
6456

6557
for(unsigned cnt=0; cnt<nb_threads; cnt++)
6658
{
67-
vars.r_buff0_thds.push_back(
68-
shared_bufferst::add(
69-
object,
70-
symbol.base_name,
71-
"$r_buff0_thd"+std::to_string(cnt),
72-
bool_typet()));
73-
vars.r_buff1_thds.push_back(
74-
shared_bufferst::add(
75-
object,
76-
symbol.base_name,
77-
"$r_buff1_thd"+std::to_string(cnt),
78-
bool_typet()));
59+
vars.r_buff0_thds.push_back(shared_bufferst::add(
60+
symbol, "$r_buff0_thd" + std::to_string(cnt), bool_typet()));
61+
vars.r_buff1_thds.push_back(shared_bufferst::add(
62+
symbol, "$r_buff1_thd" + std::to_string(cnt), bool_typet()));
7963
}
8064

8165
return vars;
@@ -85,8 +69,7 @@ const shared_bufferst::varst &shared_bufferst::operator()(
8569
/// \par parameters: var, suffix, type of the var, added as an instrumentation
8670
/// \return identifier of the new var
8771
irep_idt shared_bufferst::add(
88-
const irep_idt &object,
89-
const irep_idt &base_name,
72+
const symbolt &object,
9073
const std::string &suffix,
9174
const typet &type,
9275
bool instrument)
@@ -95,10 +78,10 @@ irep_idt shared_bufferst::add(
9578

9679
symbolt &new_symbol = get_fresh_aux_symbol(
9780
type,
98-
id2string(object) + suffix,
99-
id2string(base_name) + suffix,
100-
ns.lookup(object).location,
101-
ns.lookup(object).mode,
81+
id2string(object.name) + suffix,
82+
id2string(object.base_name) + suffix,
83+
object.location,
84+
object.mode,
10285
symbol_table);
10386
new_symbol.is_static_lifetime=true;
10487
new_symbol.value.make_nil();

src/goto-instrument/wmm/shared_buffers.h

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,8 @@ class shared_bufferst
159159
irep_idt choice(const irep_idt &function_id, const std::string &suffix)
160160
{
161161
const auto maybe_symbol = symbol_table.lookup(function_id);
162-
const std::string function_base_name =
163-
maybe_symbol
164-
? id2string(maybe_symbol->base_name)
165-
: "main";
166-
return add(function_base_name+"_weak_choice",
167-
function_base_name+"_weak_choice", suffix, bool_typet());
162+
CHECK_RETURN(maybe_symbol);
163+
return add(*maybe_symbol, "_weak_choice" + suffix, bool_typet());
168164
}
169165

170166
bool is_buffered(
@@ -244,29 +240,24 @@ class shared_bufferst
244240
messaget &message;
245241

246242
irep_idt add(
247-
const irep_idt &object,
248-
const irep_idt &base_name,
243+
const symbolt &object,
249244
const std::string &suffix,
250245
const typet &type,
251246
bool added_as_instrumentation);
252247

253-
irep_idt add(
254-
const irep_idt &object,
255-
const irep_idt &base_name,
256-
const std::string &suffix,
257-
const typet &type)
248+
irep_idt
249+
add(const symbolt &object, const std::string &suffix, const typet &type)
258250
{
259-
return add(object, base_name, suffix, type, true);
251+
return add(object, suffix, type, true);
260252
}
261253

262254
/* inserting a non-instrumenting, fresh variable */
263255
irep_idt add_fresh_var(
264-
const irep_idt &object,
265-
const irep_idt &base_name,
256+
const symbolt &object,
266257
const std::string &suffix,
267258
const typet &type)
268259
{
269-
return add(object, base_name, suffix, type, false);
260+
return add(object, suffix, type, false);
270261
}
271262

272263
void add_initialization(goto_programt &goto_program);

0 commit comments

Comments
 (0)