From acbfe65bc7bde064a64bf1a116390d90df14c689 Mon Sep 17 00:00:00 2001
From: rarbore2 <rarbore2@illinois.edu>
Date: Mon, 25 Nov 2024 12:36:07 -0600
Subject: [PATCH] Fix GVN

---
 hercules_opt/src/gvn.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hercules_opt/src/gvn.rs b/hercules_opt/src/gvn.rs
index 032081a9..b8360dd9 100644
--- a/hercules_opt/src/gvn.rs
+++ b/hercules_opt/src/gvn.rs
@@ -17,6 +17,11 @@ pub fn gvn(editor: &mut FunctionEditor) {
     let mut value_numbers: HashMap<Node, NodeID> = HashMap::new();
 
     while let Some(work) = worklist.pop() {
+        // Deleted nodes (and technically the original start) should be skipped.
+        if editor.func().nodes[work.idx()].is_start() {
+            continue;
+        }
+
         // First, simplify the work node by unwrapping identity functions.
         let value = crawl_identities(work, editor);
 
-- 
GitLab