Skip to content

Commit 38e588d

Browse files
committed
Break down large visitor functions in instrumentation visitors
1 parent cc1798b commit 38e588d

File tree

2 files changed

+259
-227
lines changed

2 files changed

+259
-227
lines changed

kani-compiler/src/kani_middle/transform/check_uninit/delayed_ub/instrumentation_visitor.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,7 @@ impl<'a, 'tcx> InstrumentationVisitor<'a, 'tcx> {
154154
self.check_operand(cond);
155155
}
156156
TerminatorKind::Drop { place, .. } => {
157-
// According to the documentation, "After drop elaboration: Drop terminators are a
158-
// complete nop for types that have no drop glue. For other types, Drop terminators
159-
// behave exactly like a call to core::mem::drop_in_place with a pointer to the
160-
// given place." Since we check arguments when instrumenting function calls, perhaps
161-
// we need to check that one, too. For more info, see:
162-
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.TerminatorKind.html#variant.Drop
163-
self.check_place(place, PlaceOperation::Read);
157+
self.check_place(place, PlaceOperation::Deinit);
164158
}
165159
TerminatorKind::Call { func, args, destination, target: _, unwind: _ } => {
166160
self.check_operand(func);
@@ -221,7 +215,8 @@ impl<'a, 'tcx> InstrumentationVisitor<'a, 'tcx> {
221215
}
222216
Operand::Constant(_) => {
223217
// Those should be safe to skip, as they are either constants or statics. In the
224-
// latter case, we handle them in regular uninit visior
218+
// latter case, we handle them in regular uninit visitor, as accessing statics
219+
// requires dereferencing a raw pointer.
225220
}
226221
}
227222
}
@@ -237,23 +232,23 @@ impl<'a, 'tcx> InstrumentationVisitor<'a, 'tcx> {
237232
{
238233
match place_operation {
239234
PlaceOperation::Write => {
240-
// If we are mutating the place, initialize it.
235+
// Write to the place initializes it.
241236
self.push_target(MemoryInitOp::SetRef {
242237
operand: Operand::Copy(place.clone()),
243238
value: true,
244239
position: InsertPosition::After,
245240
})
246241
}
247242
PlaceOperation::Deinit => {
248-
// If we are mutating the place, initialize it.
243+
// Explicitly deinitialie the place.
249244
self.push_target(MemoryInitOp::SetRef {
250245
operand: Operand::Copy(place.clone()),
251246
value: false,
252247
position: InsertPosition::After,
253248
})
254249
}
255250
PlaceOperation::Read => {
256-
// Otherwise, check its initialization.
251+
// When reading from a place, check its initialization.
257252
self.push_target(MemoryInitOp::CheckRef {
258253
operand: Operand::Copy(place.clone()),
259254
});

0 commit comments

Comments
 (0)