From e15c5db10c2bd00042d5e79674df65402f30bbbb Mon Sep 17 00:00:00 2001
From: Russel Arbore <russel.jma@gmail.com>
Date: Mon, 28 Oct 2024 13:30:41 -0500
Subject: [PATCH] Make manifest accessible from PM

---
 Cargo.lock                  |  1 +
 hercules_opt/src/pass.rs    | 11 ++++++++++-
 hercules_rt_proc/Cargo.toml |  1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Cargo.lock b/Cargo.lock
index 768b6a6f..a11c766c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -677,6 +677,7 @@ dependencies = [
  "anyhow",
  "hercules_cg",
  "hercules_ir",
+ "hercules_opt",
  "postcard",
  "serde",
 ]
diff --git a/hercules_opt/src/pass.rs b/hercules_opt/src/pass.rs
index c61177a0..719819ff 100644
--- a/hercules_opt/src/pass.rs
+++ b/hercules_opt/src/pass.rs
@@ -64,8 +64,11 @@ pub struct PassManager {
     pub antideps: Option<Vec<Vec<(NodeID, NodeID)>>>,
     pub bbs: Option<Vec<Vec<NodeID>>>,
 
-    // Current plan. Keep track of the last time the plan was updated.
+    // Current plan.
     pub plans: Option<Vec<Plan>>,
+
+    // Store the manifest of a compiled object.
+    pub manifests: Option<HashMap<String, Manifest>>,
 }
 
 impl PassManager {
@@ -85,6 +88,7 @@ impl PassManager {
             antideps: None,
             bbs: None,
             plans: None,
+            manifests: None,
         }
     }
 
@@ -565,6 +569,7 @@ impl PassManager {
                     .expect("PANIC: Unable to open output manifest file.");
                     file.write_all(&hman_contents)
                         .expect("PANIC: Unable to write output manifest file contents.");
+                    self.manifests = Some(smodule.manifests);
 
                     // Codegen doesn't require clearing analysis results.
                     continue;
@@ -605,4 +610,8 @@ impl PassManager {
     pub fn get_module(self) -> Module {
         self.module
     }
+
+    pub fn get_manifests(self) -> HashMap<String, Manifest> {
+        self.manifests.unwrap()
+    }
 }
diff --git a/hercules_rt_proc/Cargo.toml b/hercules_rt_proc/Cargo.toml
index c6e55af0..12420725 100644
--- a/hercules_rt_proc/Cargo.toml
+++ b/hercules_rt_proc/Cargo.toml
@@ -12,4 +12,5 @@ postcard = { version = "*", features = ["alloc"] }
 serde = { version = "*", features = ["derive"] }
 hercules_cg = { path = "../hercules_cg" }
 hercules_ir = { path = "../hercules_ir" }
+hercules_opt = { path = "../hercules_opt" }
 anyhow = "*"
\ No newline at end of file
-- 
GitLab