Skip to content

Commit

Permalink
go/ir: rebuild fake exits after optimizing blocks
Browse files Browse the repository at this point in the history
Block optimization can remove blocks, which means we need to recompute
fake exits to be able to build a post-dominator tree.

Before this change, building the IR form of the following program
caused a panic:

	package pkg

	import (
		"syscall"
	)

	func fn() {
		if true {
			syscall.Exit(1)
		} else {
			_ = 0
		}
		var err error
		if err != nil {
			return
		}
		for {
		}
	}

Closes gh-882
  • Loading branch information
dominikh committed Dec 8, 2020
1 parent bde4814 commit 0767310
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions go/ir/func.go
Expand Up @@ -557,6 +557,7 @@ func (f *Function) finishBody() {
f.Locals = f.Locals[:j]

optimizeBlocks(f)
buildFakeExits(f)
buildReferrers(f)
buildDomTree(f)
buildPostDomTree(f)
Expand Down

0 comments on commit 0767310

Please sign in to comment.