@@ -154,15 +154,58 @@ optionalt<loop_idt> cegis_verifiert::get_cause_loop_id(
154
154
from.has_value () && to.has_value () &&
155
155
dependence_graph.is_flow_dependent (from.value (), to.value ()))
156
156
{
157
- result =
158
- loop_idt (step.function_id , step.pc ->original_loop_number .value ());
157
+ result = loop_idt (step.function_id , original_loop_number_map[step.pc ]);
159
158
return result;
160
159
}
161
160
}
162
161
}
163
162
return result;
164
163
}
165
164
165
+ bool cegis_verifiert::is_instruction_in_transfomed_loop (
166
+ const loop_idt &loop_id,
167
+ const goto_functiont &function,
168
+ unsigned location_number_of_target)
169
+ {
170
+ // The loop body after transformation are instructions from
171
+ // loop havocing instructions
172
+ // to
173
+ // loop end of transformed code.
174
+ unsigned location_number_of_havocing = 0 ;
175
+
176
+ for (goto_programt::const_targett it = function.body .instructions .begin ();
177
+ it != function.body .instructions .end ();
178
+ ++it)
179
+ {
180
+ // Record the location number of the begin of a transformed loop.
181
+ if (
182
+ is_loop_havoc (*it) && original_loop_number_map[it] == loop_id.loop_number )
183
+ {
184
+ location_number_of_havocing = it->location_number ;
185
+ }
186
+
187
+ // Reach the end of a transformed loop.
188
+ if (
189
+ is_transformed_loop_end (it) &&
190
+ original_loop_number_map[it] == loop_id.loop_number )
191
+ {
192
+ INVARIANT (
193
+ location_number_of_havocing != 0 ,
194
+ " We must have entered the transformed loop before reaching the end" );
195
+
196
+ // Check if `location_number_of_target` is between the begin and the end
197
+ // of the transformed loop.
198
+ if ((location_number_of_havocing < location_number_of_target &&
199
+ location_number_of_target < it->location_number ))
200
+ {
201
+ return true ;
202
+ }
203
+ }
204
+ }
205
+
206
+ return false ;
207
+ }
208
+
166
209
cext cegis_verifiert::build_cex (
167
210
const goto_tracet &goto_trace,
168
211
const source_locationt &loop_entry_loc)
@@ -391,6 +434,7 @@ optionalt<cext> cegis_verifiert::verify()
391
434
// Apply loop contracts we annotated.
392
435
code_contractst cont (goto_model, log );
393
436
cont.apply_loop_contracts ();
437
+ original_loop_number_map = cont.get_original_loop_number_map ();
394
438
395
439
// Get the checker same as CBMC api without any flag.
396
440
// TODO: replace the checker with CBMC api once it is implemented.
0 commit comments