From 02e4288bf0e333f6087479e2f1dee942f28d218f Mon Sep 17 00:00:00 2001 From: Russel Arbore <russel.jma@gmail.com> Date: Sat, 15 Feb 2025 11:36:01 -0600 Subject: [PATCH] another fix... --- hercules_ir/src/fork_join_analysis.rs | 14 +++++++++----- hercules_opt/src/editor.rs | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hercules_ir/src/fork_join_analysis.rs b/hercules_ir/src/fork_join_analysis.rs index 88d700aa..3e89ae90 100644 --- a/hercules_ir/src/fork_join_analysis.rs +++ b/hercules_ir/src/fork_join_analysis.rs @@ -177,7 +177,7 @@ pub fn nodes_in_fork_joins( let mut set = HashSet::new(); set.insert(*fork); - // Iterate uses of fork. + // Iterate uses of the fork. while let Some(item) = worklist.pop() { for u in def_use.get_users(item) { let terminate = *u == *join @@ -189,11 +189,15 @@ pub fn nodes_in_fork_joins( worklist.push(*u); } set.insert(*u); + } + } + assert!(set.contains(join)); - // Nodes in reduce cycles might not depend on the thread ID. - if terminate && let Some(cycle) = reduce_cycles.get(u) { - set.extend(cycle); - } + // Add all the nodes in the reduce cycle. Some of these nodes may not + // use thread IDs of the fork, so do this explicitly. + for u in def_use.get_users(*join) { + if let Some(cycle) = reduce_cycles.get(u) { + set.extend(cycle); } } diff --git a/hercules_opt/src/editor.rs b/hercules_opt/src/editor.rs index 8c339d72..16e5c326 100644 --- a/hercules_opt/src/editor.rs +++ b/hercules_opt/src/editor.rs @@ -292,7 +292,11 @@ impl<'a: 'b, 'b> FunctionEditor<'a> { // gravestone. for id in deleted_nodeids.iter() { // Check that there are no users of deleted nodes. - assert!(editor.mut_def_use[id.idx()].is_empty()); + assert!( + editor.mut_def_use[id.idx()].is_empty(), + "PANIC: Attempted to delete node {:?}, but there are still users of this node ({:?}).", + id, editor.mut_def_use[id.idx()] + ); editor.function.nodes[id.idx()] = Node::Start; } -- GitLab