From 0b1183da1b4d448cdbf22bfb75da28a3c38bbc69 Mon Sep 17 00:00:00 2001 From: Averardo Date: Thu, 28 Nov 2024 21:06:08 -0500 Subject: [PATCH 1/2] Fix crashes for graphs with nodes unreachable from the root --- isla-lib/src/ir/ssa.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/isla-lib/src/ir/ssa.rs b/isla-lib/src/ir/ssa.rs index 6f620e3..ed665fb 100644 --- a/isla-lib/src/ir/ssa.rs +++ b/isla-lib/src/ir/ssa.rs @@ -779,10 +779,10 @@ impl DominanceFrontiers { if let Some(first) = predecessors.next() { if let Some(second) = predecessors.next() { for p in [first, second].iter().copied().chain(predecessors) { - let mut runner = p; - while runner != doms.immediate_dominator(b).unwrap() { - frontiers[runner.index()].insert(b); - runner = doms.immediate_dominator(runner).unwrap() + let mut runner = Some(p); + while runner.is_some() && runner != doms.immediate_dominator(b) { + frontiers[runner.unwrap().index()].insert(b); + runner = doms.immediate_dominator(runner.unwrap()); } } } From 53f5f9ca09fc31562706085ec38db0b07681e2e2 Mon Sep 17 00:00:00 2001 From: Averardo Date: Thu, 28 Nov 2024 21:36:00 -0500 Subject: [PATCH 2/2] Fix crashes for functions that never write to RETURN e.g., a function that throws an exception and exits with arbitrary --- isla-lib/src/ir/ssa.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/isla-lib/src/ir/ssa.rs b/isla-lib/src/ir/ssa.rs index ed665fb..277ab6b 100644 --- a/isla-lib/src/ir/ssa.rs +++ b/isla-lib/src/ir/ssa.rs @@ -946,15 +946,17 @@ impl CFG { } for a in all_vars { - let mut worklist: Vec = defsites.get_mut(a).unwrap().drain().collect(); - - while let Some(n) = worklist.pop() { - for y in frontiers.get(n) { - if !needs_phi.entry(*a).or_default().contains(y) { - let num_preds = self.graph.edges_directed(*y, Direction::Incoming).count(); - self.graph.node_weight_mut(*y).unwrap().insert_phi(*a, num_preds); - needs_phi.entry(*a).or_default().insert(*y); - worklist.push(*y) + if let Some(defsite) = defsites.get_mut(a) { + let mut worklist: Vec = defsite.drain().collect(); + + while let Some(n) = worklist.pop() { + for y in frontiers.get(n) { + if !needs_phi.entry(*a).or_default().contains(y) { + let num_preds = self.graph.edges_directed(*y, Direction::Incoming).count(); + self.graph.node_weight_mut(*y).unwrap().insert_phi(*a, num_preds); + needs_phi.entry(*a).or_default().insert(*y); + worklist.push(*y) + } } } }