From 3099c8fa67511fb160a52ccc73723a7576931760 Mon Sep 17 00:00:00 2001
From: rarbore2 <rarbore2@illinois.edu>
Date: Tue, 26 Nov 2024 12:48:13 -0600
Subject: [PATCH] Explicitly panic when there are no entry functions

---
 hercules_opt/src/pass.rs | 2 ++
 juno_samples/cava.jn     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/hercules_opt/src/pass.rs b/hercules_opt/src/pass.rs
index 82adfeb5..2aa25a34 100644
--- a/hercules_opt/src/pass.rs
+++ b/hercules_opt/src/pass.rs
@@ -700,6 +700,8 @@ impl PassManager {
 
                     self.fix_deleted_functions(&new_idx);
                     self.clear_analyses();
+
+                    assert!(self.module.functions.len() > 0, "PANIC: There are no entry functions in the Hercules module being compiled, and they all got deleted by DeleteUncalled. Please mark at least one function as an entry!");
                 }
                 Pass::Verify => {
                     let (
diff --git a/juno_samples/cava.jn b/juno_samples/cava.jn
index ee46e476..977e2e02 100644
--- a/juno_samples/cava.jn
+++ b/juno_samples/cava.jn
@@ -205,6 +205,7 @@ fn tone_map<row : usize, col:usize>
   return result;
 }
 
+#[entry]
 fn cava<r, c : usize>(input : u8[CHAN, r, c], TsTw : f32[CHAN, CHAN],
                       ctrl_pts : f32[CTRL_PTS, CHAN],
                       weights : f32[CTRL_PTS, CHAN],
-- 
GitLab