Skip to content

Remove SimpleDCE and add compiler testing #1008

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 4 commits into from
Closed

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Mar 29, 2020

The first commit removes most of the ir package and either moves the code to compiler/symbol.go or removes it altogether. After this, not much remains of the ir package and it should be removed eventually.

The second commit relies on the added flexibility provided by the first commit to add testing to the compiler package. It only contains one very basic test but it provides a framework for future tests to be added in a similar way.

Warning: this PR may have consequences. I found that the image/png package stopped compiling due to a bug in the compiler (it produces invalid IR), probably because a function that previously was removed with SimpleDCE is now included in the build. It also slows down the compiler significantly, I've measured +12% (driver smoke tests) to +53% (tinygo smoke tests) increase in compile time. However, this PR is one of the many changes necessary to allow packages to be compiled independently which should eventually speed up the compiler by compiling packages in parallel and caching already compiled packages.

Replaces #466.

@aykevl aykevl mentioned this pull request Mar 29, 2020
@aykevl aykevl force-pushed the refactor-ir-functions-2 branch 2 times, most recently from f85ff86 to 96b95f6 Compare March 29, 2020 18:50
@deadprogram
Copy link
Member

This PR now has merge conflicts that need to be resolved.

@aykevl aykevl force-pushed the refactor-ir-functions-2 branch from 96b95f6 to 1c16246 Compare April 7, 2020 14:10
@aykevl
Copy link
Member Author

aykevl commented Apr 7, 2020

Rebased. This PR should not be merged before the next release, it's too big and invasive and relies on followup changes (not yet made) to shrink compile time again.

@aykevl aykevl force-pushed the refactor-ir-functions-2 branch from 1c16246 to 18df8c6 Compare April 9, 2020 13:07
@aykevl
Copy link
Member Author

aykevl commented Apr 9, 2020

I found that the image/png package stopped compiling due to a bug in the compiler (it produces invalid IR), probably because a function that previously was removed with SimpleDCE is now included in the build.

This regression has now been fixed by #1040.

aykevl added 2 commits April 10, 2020 00:19
This makes viewing the IR easier because parameters have readable names.

This also makes it easier to write compiler tests (still a work in
progress), that work in LLVM 9 and LLVM 10, as LLVM 10 started printing
value names for unnamed parameters.
This is important because once we move to compiling packages
independently, SimpleDCE can't work anymore. Instead we'll have to
compile all parts of a package and cache that for later reuse.
@aykevl aykevl force-pushed the refactor-ir-functions-2 branch from 18df8c6 to 0531d26 Compare April 10, 2020 11:40
aykevl added 2 commits April 10, 2020 17:19
This commit adds a very small test case. More importantly, it adds a
framework for other tests to be added in the future.
The ir package has long lost its original purpose (which was doing some
analysis and optimization on the Go SSA directly). There is very little
of it left, which is best integrated directly in the compiler package to
avoid unnecessary abstraction.
@aykevl aykevl force-pushed the refactor-ir-functions-2 branch from 0531d26 to c9b1f0f Compare April 11, 2020 15:22
@aykevl aykevl marked this pull request as draft April 29, 2020 21:35
@niaow niaow added this to the v0.15 milestone Jun 27, 2020
aykevl added a commit that referenced this pull request Jan 16, 2021
These types are often known to the compiler already. Moving them into
the compiler is an important step for two related reasons:

  * It makes the compiler better testable. Together with
    #1008 it will make it
    possible to test the compiler without having to load the runtime
    package.
  * It makes it easier to compile packages independently as the type
    information of the runtime package doesn't need to be present.

I had to use hack to get this to work well: internal/task.Task is now an
opaque struct. This is necessary because there is a dependency from
*runtime.channel -> *runtime.channelBlockedList -> *internal/task.Task.
I don't want to include the definition of the internal/task.Task struct
in the compiler directly as that would make changing the internal/task
package a lot harder and the compiler doesn't need to know the layout of
that struct anyway.
@aykevl
Copy link
Member Author

aykevl commented May 5, 2021

This PR has been superseded by other (merged) PRs.

@aykevl aykevl closed this May 5, 2021
@aykevl aykevl deleted the refactor-ir-functions-2 branch May 5, 2021 12:32
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.

None yet

3 participants