Skip to content
Snippets Groups Projects
Commit 1aad2842 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'delete-uncalled-fix' into 'main'

Fix delete uncalled bugs

See merge request !173
parents f394bf1e eda921ae
No related branches found
No related tags found
1 merge request!173Fix delete uncalled bugs
Pipeline #201624 passed
......@@ -50,6 +50,11 @@ pub fn delete_uncalled(
// that all nodes in all functions will be mutable, so panic if any
// edit fails.
for editor in editors.iter_mut() {
// Don't make edits to dead functions as they may include calls to dead functions
if new_idx[editor.func_id().idx()].is_none() {
continue;
}
let callsites: Vec<_> = editor
.node_ids()
.filter(|id| editor.func().nodes[id.idx()].is_call())
......
......@@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::collections::HashSet;
use std::hash::Hash;
#[derive(Debug)]
pub struct Env<K, V> {
table: HashMap<K, Vec<V>>,
scope: Vec<HashSet<K>>,
......@@ -98,6 +99,11 @@ impl<K: Eq + Hash + Copy, V> Env<K, V> {
let mut new_scopes: HashMap<K, Vec<usize>> = HashMap::new();
for (k, vs) in std::mem::take(&mut self.table) {
if vs.is_empty() {
assert!(!scopes.contains_key(&k));
continue;
}
let scope_list = scopes.remove(&k).unwrap();
assert!(scope_list.len() == vs.len());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment