aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJack Koenig2017-12-20 13:27:45 -0800
committerGitHub2017-12-20 13:27:45 -0800
commitc12e3b22cc3487906a265fe02b28ad1ac05be9f2 (patch)
tree6b7debb18170eedf792020b5566a7c4c751735bb /src/main
parent4801d9cbc3cd957496daa00b099ead15f9f4e17d (diff)
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
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/firrtl/graph/DiGraph.scala3
1 files changed, 2 insertions, 1 deletions
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)
}