aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform/transform.go
AgeCommit message (Collapse)Author
2023-10-04all: use the new LLVM pass managerAyke van Laethem
The old LLVM pass manager is deprecated and should not be used anymore. Moreover, the pass manager builder (which we used to set up a pass pipeline) is actually removed from LLVM entirely in LLVM 17: https://reviews.llvm.org/D145387 https://reviews.llvm.org/D145835 The new pass manager does change the binary size in many cases: both growing and shrinking it. However, on average the binary size remains more or less the same. This is needed as a preparation for LLVM 17.
2021-11-10compiler: add "target-cpu" and "target-features" attributesAyke van Laethem
This matches Clang, and with that, it adds support for inlining between Go and C because LLVM only allows inlining if the "target-cpu" and "target-features" string attributes match. For example, take a look at the following code: // int add(int a, int b) { // return a + b; // } import "C" func main() { println(C.add(3, 5)) } The 'add' function is not inlined into the main function before this commit, but after it, it can be inlined and trivially be optimized to `println(8)`.
2021-11-03compiler: add minsize attribute for -OzAyke van Laethem
This matches the behavior of Clang, which uses optsize for -Os and adds minsize for -Oz. The code size change is all over the map, but using a hacked together size comparison tool I've found that there is a slight reduction in binary size overall (-1.6% with the tinygo smoke tests and -0.8% for the drivers smoke test).
2021-11-03compiler: refactor when the optsize attribute is setAyke van Laethem
This commit has a few related changes: * It sets the optsize attribute immediately in the compiler instead of adding it to each function afterwards in a loop. This seems to me like the more appropriate way to do it. * It centralizes setting the optsize attribute in the transform package, to make later changes easier. * It sets the optsize in a few more places: to runtime.initAll and to WebAssembly i64 wrappers. This commit does not affect the binary size of any of the smoke tests, so should be risk-free.
2019-09-15all: refactor heap-to-stack transform into the transform packageAyke van Laethem
Also add unit tests. This is the first of several transformation (optimization/lowering) passes that I'd like to move to the new transform package. This separates the compiler from the optimizer. Also, it finally adds unit tests for the compiler, not just end-to-end compilation tests. This should improve robustness and should make it easier to change these transformation passes in the future. While the heap-to-stack transform is relatively simple, other passes are much more complex. Adding unit tests not only helps robustness over time, but also doubles as documentation as to what these transformation passes do exactly.