Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.

Commit 58ac27b

Browse files
committed
havlak2
1 parent 35f62a4 commit 58ac27b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎havlak/havlak.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,17 @@ func listContainsNode(l []*UnionFindNode, u *UnionFindNode) bool {
237237

238238
// DFS - Depth-First-Search and node numbering.
239239
//
240-
func DFS(currentNode *BasicBlock, nodes []*UnionFindNode, number map[*BasicBlock]int, last []int, current int) int {
240+
func DFS(currentNode *BasicBlock, nodes []*UnionFindNode, number []int, last []int, current int) int {
241241
nodes[current].Init(currentNode, current)
242-
number[currentNode] = current
242+
number[currentNode.Name] = current
243243

244244
lastid := current
245245
for _, target := range currentNode.OutEdges {
246-
if number[target] == unvisited {
246+
if number[target.Name] == unvisited {
247247
lastid = DFS(target, nodes, number, last, lastid+1)
248248
}
249249
}
250-
last[number[currentNode]] = lastid
250+
last[number[currentNode.Name]] = lastid
251251
return lastid
252252
}
253253

@@ -268,7 +268,7 @@ func FindLoops(cfgraph *CFG, lsgraph *LSG) {
268268
nonBackPreds := make([]map[int]bool, size)
269269
backPreds := make([][]int, size)
270270

271-
number := make(map[*BasicBlock]int)
271+
number := make([]int, size)
272272
header := make([]int, size, size)
273273
types := make([]int, size, size)
274274
last := make([]int, size, size)
@@ -284,7 +284,7 @@ func FindLoops(cfgraph *CFG, lsgraph *LSG) {
284284
// - unreached BB's are marked as dead.
285285
//
286286
for i, bb := range cfgraph.Blocks {
287-
number[bb] = unvisited
287+
number[bb.Name] = unvisited
288288
nonBackPreds[i] = make(map[int]bool)
289289
}
290290

@@ -312,7 +312,7 @@ func FindLoops(cfgraph *CFG, lsgraph *LSG) {
312312

313313
if nodeW.NumPred() > 0 {
314314
for _, nodeV := range nodeW.InEdges {
315-
v := number[nodeV]
315+
v := number[nodeV.Name]
316316
if v == unvisited {
317317
continue // dead node
318318
}

0 commit comments

Comments
 (0)