Hello all,
As part of my senior thesis, we wrote a verifier to take ARM generated from LLVM's backend and validate that the generation was semantically correct using Alive2. Writing backend optimizations is hard to get right, and we caught
quite a few bugs in LLVM's GlobalISel ARM backend through lots of fuzzing and verifying translation.
I've been wanting to extend this tool validate different forms of translation in Go, and asking around on the Gopher slack, there seems to be some initial interest from some well-known gophers who have contributed to the compiler.
There are two areas where I see this as helpful:
1. Verifying correctness of source to source rewrite rules for generic SSA rewrites.
2. Verifying correctness of ARM (soon to be other backends) code generation.
Doing either of these will allow for more fearless optimization work, and the ability to verify that rewrites are valid. Many of the folks over at LLVM who contribute have found great value in being able to test if their optimizations are correct without much thought.
To do this however, I would need access to the compile/internal/ssa package, and its ability to apply rewrite rules to a program. With that I would lift the unoptimized and optimized programs into Alive IR to verify the rewrite rule's correctness.
There is the the
golang.org/x/tools/go/ssa package, but this only provides me an interface to turn an the program into an in-memory SSA data structure, but cannot apply any of the rewrite rules.
I was hoping to get a feel for sentiment on providing the generic (maybe even platform specific?) rewrite rules and passes as apart of the public
golang.org/x/tools/go/ssa API (maybe in a sub-package called "rewrite"), or some other public facing API. Doing so would provide more advanced analysis capabilities for correctness work, makes hacking on optimizations easier, and could provide more tooling outside the ssa-html tool for visualization and understanding of optimizations.
Alternatively, the project could depend on the internal ssa package, accepting that it is internal and could break at any time, and that the Go team doesn't owe the project any consistency. I'm willing to do this, but was hoping to get some feedback before I get too deep into anything.
I'm happy to write up a more formal proposal or talk with anyone involved to help hash out details.
Thanks,
Ryan