diff options
| author | Jack Koenig | 2017-05-25 20:04:02 -0700 |
|---|---|---|
| committer | GitHub | 2017-05-25 20:04:02 -0700 |
| commit | 99db604e59e8f052d7628f104eecb2641c6ab9b2 (patch) | |
| tree | 6847d858b782f5a241a6dfdc049b2e0084791bd6 /src | |
| parent | c7c578f34f4fbd3bb987593ffdccdfb6b356b9f7 (diff) | |
Fix performance bug in DCE (#596)
We walked the whole set of vertices for every dont touch
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/transforms/DeadCodeElimination.scala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main/scala/firrtl/transforms/DeadCodeElimination.scala b/src/main/scala/firrtl/transforms/DeadCodeElimination.scala index bf7ff7eb..91a5dd5a 100644 --- a/src/main/scala/firrtl/transforms/DeadCodeElimination.scala +++ b/src/main/scala/firrtl/transforms/DeadCodeElimination.scala @@ -247,14 +247,19 @@ class DeadCodeElimination extends Transform { val depGraph = { val dGraph = createDependencyGraph(moduleDeps, doTouchExtMods, c) - for (dontTouch <- dontTouches) { - dGraph.getVertices.find(_ == dontTouch) match { - case Some(node) => dGraph.addEdge(circuitSink, node) - case None => - val (root, tail) = Utils.splitRef(dontTouch.e1) - DontTouchAnnotation.errorNotFound(root.serialize, tail.serialize) + + val vertices = dGraph.getVertices + dontTouches.foreach { dontTouch => + // Ensure that they are actually found + if (vertices.contains(dontTouch)) { + dGraph.addEdge(circuitSink, dontTouch) + } else { + val (root, tail) = Utils.splitRef(dontTouch.e1) + DontTouchAnnotation.errorNotFound(root.serialize, tail.serialize) } } + + // Check for dont touches that are not found DiGraph(dGraph) } |
