Skip to content

Commit

Permalink
ensure that instruction graph is always connected
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullinAM committed Jan 9, 2024
1 parent 8b1ea08 commit 4b5b199
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,18 @@ class InstructionGraph(
}
}.filter { it.hasBody }
}
var connectedExits = false
for (candidate in resolvedMethods) {
queue += Triple(vertex, candidate.body.entry, 0)
queue.addAll(candidate.body.catchEntries.map { Triple(null, it, 0) })

candidate.body.flatten().filterIsInstance<ReturnInst>().forEach {
connectedExits = true
val returnVertex = nodes.getOrPut(it) { Vertex(it) }
queue += Triple(returnVertex, block, index + 1)
}
}
if (resolvedMethods.isEmpty()) {
if (!connectedExits) {
queue += Triple(vertex, block, index + 1)
}
}
Expand Down

0 comments on commit 4b5b199

Please sign in to comment.