Skip to content

Avoid DCE at Go SSA level #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Avoid DCE at Go SSA level #466

wants to merge 1 commit into from

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Jul 30, 2019

Large change that:

  1. Adds support for calling indirect functions, like the following (as used in the time package):
    func foo(fn func()) {
        go fn()
    }
  2. Compiles all code, instead of just the part that seems to be used.

This is in preparation of fixing #285. Not ready for merging, as it's not complete (some packages that previously compiled break with this change) and I want to review/improve it myself a bit, and add real commit messages.

This change will increase compile times, but should decrease massively once #285 is ready and package builds can be cached.

@aykevl aykevl force-pushed the refactor-ir-functions branch 4 times, most recently from 7da9ea9 to 5531979 Compare August 10, 2019 09:30
@aykevl
Copy link
Member Author

aykevl commented Aug 10, 2019

Progress! After rebasing to incorporate the changes in #486, the amount of successful checks goes from 1 to 3 (of 4). And I know what goes wrong in the 4th one (test-llvm8-go111).

@aykevl
Copy link
Member Author

aykevl commented Aug 10, 2019

The main limitation now is that code like the following causes a compiler error:

package main

type asdf struct {
	next []asdf
}

func main() {
	foo(new(asdf))
}

func foo(x *asdf) {
}

(The issue here is the struct that contains a slice of itself).
This issue is present in the strings package, which worked before and should definitely not regress with this PR.

@aykevl aykevl force-pushed the refactor-ir-functions branch 3 times, most recently from fd84d53 to 4eec52f Compare August 17, 2019 16:14
Previously, all functions were processed first by the ir package which
scanned them all for reachability. Only the reachable functions were
compiled to LLVM IR.

This change removes this dead code elimination pass, and in fact
refactors most of that infrastructure. This cleans up the compiler and
should open the door for caching the compilation and optimization of
packages.
@aykevl
Copy link
Member Author

aykevl commented Mar 29, 2020

Replaced by #1008.

@aykevl aykevl closed this Mar 29, 2020
@aykevl aykevl deleted the refactor-ir-functions branch March 29, 2020 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant