Skip to content

Commit 7e6d48c

Browse files
committed
fix monomorphization issue
1 parent 7c01c3d commit 7e6d48c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub enum MonoItemCollectionMode {
204204

205205
pub struct UsageMap<'tcx> {
206206
// Maps every mono item to the mono items used by it.
207-
used_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
207+
pub used_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
208208

209209
// Maps every mono item to the mono items that use it.
210210
user_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,30 +1154,47 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Au
11541154
if !target_attrs.apply_autodiff() {
11551155
return None;
11561156
}
1157-
println!("target_id: {:?}", target_id);
1157+
//println!("target_id: {:?}", target_id);
11581158

11591159
let target_symbol =
11601160
symbol_name_for_instance_in_crate(tcx, instance.clone(), LOCAL_CRATE);
11611161
//let range = usage_map.used_map.get(&item).unwrap();
11621162
//TODO: check if last and next line are correct after rebasing
11631163

1164-
let source = usage_map.get_user_items(*item)
1164+
println!("target_symbol: {:?}", target_symbol);
1165+
println!("target_attrs: {:?}", target_attrs);
1166+
println!("target_id: {:?}", target_id);
1167+
//print item
1168+
println!("item: {:?}", item);
1169+
let source = usage_map.used_map.get(&item).unwrap()
11651170
.into_iter()
11661171
.filter_map(|item| match *item {
11671172
MonoItem::Fn(ref instance_s) => {
11681173
let source_id = instance_s.def_id();
1174+
println!("source_id_inner: {:?}", source_id);
1175+
println!("instance_s: {:?}", instance_s);
11691176

11701177
if tcx.autodiff_attrs(source_id).is_active() {
1178+
println!("source_id is active");
11711179
return Some(instance_s);
11721180
}
1181+
//target_symbol: "_ZN14rosenbrock_rev12d_rosenbrock17h3352c4f00c3082daE"
1182+
//target_attrs: AutoDiffAttrs { mode: Reverse, ret_activity: Active, input_activity: [Duplicated] }
1183+
//target_id: DefId(0:8 ~ rosenbrock_rev[2708]::d_rosenbrock)
1184+
//item: Fn(Instance { def: Item(DefId(0:8 ~ rosenbrock_rev[2708]::d_rosenbrock)), args: [] })
1185+
//source_id_inner: DefId(0:4 ~ rosenbrock_rev[2708]::main)
1186+
//instance_s: Instance { def: Item(DefId(0:4 ~ rosenbrock_rev[2708]::main)), args: [] }
1187+
11731188

11741189
None
11751190
}
11761191
_ => None,
11771192
})
11781193
.next();
1194+
println!("source: {:?}", source);
11791195

11801196
source.map(|inst| {
1197+
println!("source_id: {:?}", inst.def_id());
11811198
let (inputs, output) = fnc_typetrees(inst.ty(tcx, ParamEnv::empty()), tcx);
11821199
let symb = symbol_name_for_instance_in_crate(tcx, inst.clone(), LOCAL_CRATE);
11831200

0 commit comments

Comments
 (0)