Skip to content

Commit 811e371

Browse files
committed
debug: examine how multiple Instances can share the same DefId
cc #42
1 parent df0c91c commit 811e371

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/functions/mod.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use indexmap::IndexSet;
1+
use indexmap::{IndexMap, IndexSet};
22
use kani::{CallGraph, KANI_TOOL_ATTRS, collect_reachable_items};
33
use rustc_middle::ty::TyCtxt;
44
use stable_mir::{
5-
CrateDef,
5+
CrateDef, DefId,
66
crate_def::Attribute,
77
mir::mono::{Instance, MonoItem},
88
};
@@ -76,6 +76,25 @@ impl Function {
7676
let mut callees = IndexSet::new();
7777
callgraph.recursive_callees(item, &mut callees);
7878

79+
{
80+
// https://github.com/os-checker/distributed-verification/issues/42
81+
let mut map = IndexMap::<DefId, Vec<Instance>>::new();
82+
for &callee in callees.iter() {
83+
map.entry(callee.def.def_id())
84+
.and_modify(|v| v.push(callee))
85+
.or_insert_with(|| vec![callee]);
86+
}
87+
for (idx, (defid, v)) in map.iter().enumerate() {
88+
if defid.name() == "verify::f::kani_register_contract" {
89+
dbg!(v);
90+
}
91+
let v: Vec<_> = v.iter().map(|i| i.name()).collect();
92+
let len = v.len();
93+
println!("[{idx} -> {len}] [{defid:?}] {v:?}");
94+
}
95+
println!("\n\n\n");
96+
}
97+
7998
// Multiple instances may share the same defid (or rather SourceCode), so deduplicate them.
8099
let mut callees: Vec<_> = callees.into_iter().collect();
81100
callees.sort_by(cache::cmp_callees);

0 commit comments

Comments
 (0)