diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-20 14:17:31 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-20 14:17:31 -0600 |
commit | 543cff69f2e2d5c96140149f994299791005a420 (patch) | |
tree | 21aa80ff11ff6f4befb0e2fd3f959b8632c63e39 | |
parent | b320d02e1dbfa255ac0c919e37f89aa0108edaa5 (diff) |
Incorporate function parameters in Reachability
-rw-r--r-- | vaporize/library/CFGNode.java | 11 | ||||
-rw-r--r-- | vaporize/library/CFGSimp.java | 11 | ||||
-rw-r--r-- | vaporize/library/ControlFlowGraph.java | 5 |
3 files changed, 23 insertions, 4 deletions
diff --git a/vaporize/library/CFGNode.java b/vaporize/library/CFGNode.java index 9d627a0..aefcd28 100644 --- a/vaporize/library/CFGNode.java +++ b/vaporize/library/CFGNode.java @@ -59,6 +59,13 @@ class CFGNode { this.reaching.add(add); } + protected void addLive(String add) { + MinimalLogger.info(String.format("Use %s at %s", + add, + this.line)); + this.liveness.add(add); + } + protected Node getInstruction() { return this.instruction; } @@ -75,6 +82,10 @@ class CFGNode { return this.reaching; } + protected HashSet<String> getLiveness() { + return this.liveness; + } + protected int getLine() { return this.line; } diff --git a/vaporize/library/CFGSimp.java b/vaporize/library/CFGSimp.java index 4456d39..6aaf0d1 100644 --- a/vaporize/library/CFGSimp.java +++ b/vaporize/library/CFGSimp.java @@ -27,9 +27,6 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE for (VFunction f : this.vp.functions) { ControlFlowGraph cfg = new ControlFlowGraph(); this.dot_format = ""; - // first visit may not find edges; cfg.addEdges will handle - this.curr = new CFGNode(f.body[0]); - cfg.setStart(curr); MinimalLogger.info(String.format("CFGSimp is collecting nodes for %s", this.kettle.parseFuncName(f))); @@ -49,6 +46,14 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE MinimalLogger.info(String.format("CFGSimp is collecting edges for %s", this.kettle.parseFuncName(f))); + + // inital setup + // first visit may not find edges; cfg.addEdges will handle + this.curr = new CFGNode(f.body[0]); + cfg.setStart(curr); + // cascades downwards --- cfg.addEdges + for (VVarRef.Local l : f.params) + this.curr.addReaching(l.ident.toString()); for (VInstr s : f.body) s.accept(cfg, this); diff --git a/vaporize/library/ControlFlowGraph.java b/vaporize/library/ControlFlowGraph.java index 1e24dd6..5d589fb 100644 --- a/vaporize/library/ControlFlowGraph.java +++ b/vaporize/library/ControlFlowGraph.java @@ -73,13 +73,16 @@ public class ControlFlowGraph { source.addDest(dest); dest.addSource(source); - dest.getReaching().addAll(source.getReaching()); ret += ";"; } else { MinimalLogger.info(String.format("Skipping duplicate edge for %d", source.getInstruction().sourcePos.line)); } + MinimalLogger.info(String.format("Spilling variables: %s", + source.getReaching().toString())); + dest.getReaching().addAll(source.getReaching()); + return ret; } |