@@ -189,6 +189,10 @@ void code_contractst::check_apply_loop_contracts(
189
189
insert_before_swap_and_advance (
190
190
goto_function.body , loop_head, snapshot_instructions);
191
191
};
192
+
193
+ // Perform write set instrumentation on the entire loop.
194
+ check_frame_conditions (
195
+ function_name, goto_function.body , loop_head, loop_end, loop_assigns);
192
196
}
193
197
194
198
havoc_assigns_targetst havoc_gen (modifies, ns);
@@ -251,7 +255,10 @@ void code_contractst::check_apply_loop_contracts(
251
255
252
256
// Assume invariant & decl the variant temporaries (just before loop guard).
253
257
// Use insert_before_swap to preserve jumps to loop head.
254
- insert_before_swap_and_advance (goto_function.body , loop_head, generated_code);
258
+ insert_before_swap_and_advance (
259
+ goto_function.body ,
260
+ loop_head,
261
+ add_pragma_disable_assigns_check (generated_code));
255
262
256
263
// Forward the loop_head iterator until the start of the body.
257
264
// This is necessary because complex C loop_head conditions could be
@@ -270,13 +277,6 @@ void code_contractst::check_apply_loop_contracts(
270
277
auto loop_body = loop_head;
271
278
loop_head--;
272
279
273
- // Perform write set instrumentation before adding anything else to loop body.
274
- if (assigns.is_not_nil ())
275
- {
276
- check_frame_conditions (
277
- function_name, goto_function.body , loop_body, loop_end, loop_assigns);
278
- }
279
-
280
280
// Generate: assignments to store the multidimensional decreases clause's
281
281
// value just before the loop body (but just after the loop guard)
282
282
if (!decreases_clause.is_nil ())
@@ -290,7 +290,8 @@ void code_contractst::check_apply_loop_contracts(
290
290
converter.goto_convert (old_decreases_assignment, generated_code, mode);
291
291
}
292
292
293
- goto_function.body .destructive_insert (loop_body, generated_code);
293
+ goto_function.body .destructive_insert (
294
+ loop_body, add_pragma_disable_assigns_check (generated_code));
294
295
}
295
296
296
297
// Generate: assert(invariant) just after the loop exits
@@ -340,7 +341,10 @@ void code_contractst::check_apply_loop_contracts(
340
341
}
341
342
}
342
343
343
- insert_before_swap_and_advance (goto_function.body , loop_end, generated_code);
344
+ insert_before_swap_and_advance (
345
+ goto_function.body ,
346
+ loop_end,
347
+ add_pragma_disable_assigns_check (generated_code));
344
348
345
349
// change the back edge into assume(false) or assume(guard)
346
350
loop_end->turn_into_assume ();
0 commit comments