From c12e3b22cc3487906a265fe02b28ad1ac05be9f2 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Wed, 20 Dec 2017 13:27:45 -0800 Subject: Fix bug in ConstProp where module dependency edges were dropped (#696) This resulted in parent modules sometimes being constant proppagated before a child module. If the child module has a constant driving one of its outputs, the parent module would thus not see the constant. This resulted in strange unstable constant propagation behavior where sometimes constant outputs would not propagate. Also add test illustrating why this occurs with uses of InstanceGraph--- src/main/scala/firrtl/graph/DiGraph.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/scala/firrtl/graph/DiGraph.scala b/src/main/scala/firrtl/graph/DiGraph.scala index 7e56919c..b869982d 100644 --- a/src/main/scala/firrtl/graph/DiGraph.scala +++ b/src/main/scala/firrtl/graph/DiGraph.scala @@ -302,7 +302,8 @@ class DiGraph[T] private[graph] (private[graph] val edges: LinkedHashMap[T, Link * @return a transformed DiGraph[Q] */ def transformNodes[Q](f: (T) => Q): DiGraph[Q] = { - val eprime = edges.map({ case (k, v) => (f(k), v.map(f(_))) }) + val eprime = edges.map({ case (k, _) => (f(k), new LinkedHashSet[Q]) }) + edges.foreach({ case (k, v) => eprime(f(k)) ++= v.map(f(_)) }) new DiGraph(eprime) } -- cgit v1.2.3