Skip to content
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

all: use the new LLVM pass manager #3918

Merged
merged 1 commit into from
Oct 4, 2023
Merged

all: use the new LLVM pass manager #3918

merged 1 commit into from
Oct 4, 2023

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Sep 19, 2023

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.

WIP because this needs tinygo-org/go-llvm#50.

@aykevl aykevl marked this pull request as ready for review September 20, 2023 20:48
@github-actions
Copy link

github-actions bot commented Sep 20, 2023

Size difference with the dev branch:

Binary size difference
 before   after   diff
  10728   10096   -632  -5.89%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go
  10392    9784   -608  -5.85%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go
  77416   77152   -264  -0.34%  tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go
   7084    6932   -152  -2.15%  tinygo build -size short -o ./build/test.hex -target=hifive1b ./examples/ssd1351/main.go
   9448    9336   -112  -1.19%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go
  14624   14516   -108  -0.74%  tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go
  11716   11612   -104  -0.89%  tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go
   5712    5612   -100  -1.75%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go
   5756    5656   -100  -1.74%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go
  14012   13912   -100  -0.71%  tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go
   5326    5228    -98  -1.84%  tinygo build -size short -o ./build/test.bin -target=m5stamp-c3          ./examples/ws2812
   8532    8444    -88  -1.03%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go
  12420   12352    -68  -0.55%  tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go
  11336   11268    -68  -0.60%  tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go
  13044   12976    -68  -0.52%  tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go
   6868    6800    -68  -0.99%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go
   8788    8720    -68  -0.77%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go
   6832    6764    -68  -1.00%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go
   6292    6232    -60  -0.95%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go
  17212   17156    -56  -0.33%  tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go
   8776    8724    -52  -0.59%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go
   8424    8372    -52  -0.62%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go
  10616   10564    -52  -0.49%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go
  10884   10832    -52  -0.48%  tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic
  10960   10908    -52  -0.47%  tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll
  12572   12520    -52  -0.41%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go
   9868    9816    -52  -0.53%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go
   6976    6924    -52  -0.75%  tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812
  13224   13172    -52  -0.39%  tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go
   7452    7400    -52  -0.70%  tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/
   8744    8692    -52  -0.59%  tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go
   7892    7840    -52  -0.66%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go
  32296   32248    -48  -0.15%  tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go
  16660   16612    -48  -0.29%  tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go
   8472    8428    -44  -0.52%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go
  12092   12052    -40  -0.33%  tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
   7344    7304    -40  -0.54%  tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go
   9608    9576    -32  -0.33%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go
   8196    8168    -28  -0.34%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go
   5704    5676    -28  -0.49%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go
   6288    6260    -28  -0.45%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go
  27860   27836    -24  -0.09%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go
  25104   25080    -24  -0.10%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/espat/esphub/main.go
   6392    6376    -16  -0.25%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go
  10328   10312    -16  -0.15%  tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone
   1565    1549    -16  -1.02%  tinygo build -size short -o ./build/test.hex -target=arduino   ./examples/ws2812
  11204   11188    -16  -0.14%  tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go
  11220   11204    -16  -0.14%  tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go
   9232    9216    -16  -0.17%  tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go
   7052    7040    -12  -0.17%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go
  36620   36608    -12  -0.03%  tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/
  10164   10152    -12  -0.12%  tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/
  26132   26124     -8  -0.03%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go
  22944   22936     -8  -0.03%  tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go
   6464    6456     -8  -0.12%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/i2c_128x32/main.go
   6460    6452     -8  -0.12%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go
   6012    6004     -8  -0.13%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go
  12084   12076     -8  -0.07%  tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go
   8924    8916     -8  -0.09%  tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go
  15740   15732     -8  -0.05%  tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go
   4708    4704     -4  -0.08%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go
  10180   10176     -4  -0.04%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go
  10608   10604     -4  -0.04%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go
   6084    6080     -4  -0.07%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go
   5104    5100     -4  -0.08%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go
 137500  137496     -4  -0.00%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/wifinina/tcpclient/main.go
   2681    2681      0   0.00%  tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo
   7944    7944      0   0.00%  tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go
   9404    9404      0   0.00%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go
    880     880      0   0.00%  tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812
   9280    9280      0   0.00%  tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go
   9800    9800      0   0.00%  tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go
  10048   10052      4   0.04%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
  10076   10080      4   0.04%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
  12144   12148      4   0.03%  tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go
  14560   14564      4   0.03%  tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/
  10308   10312      4   0.04%  tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go
  13260   13268      8   0.06%  tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx
  29044   29052      8   0.03%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
  12460   12468      8   0.06%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go
   8116    8128     12   0.15%  tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
   8980    8996     16   0.18%  tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go
   5940    5960     20   0.34%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/spi_128x64/main.go
   7608    7632     24   0.32%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go
  22952   22984     32   0.14%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go
  15772   15804     32   0.20%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go
   9700    9736     36   0.37%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go
   8308    8344     36   0.43%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go
  16904   16940     36   0.21%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
  13812   13848     36   0.26%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go
 263524  263564     40   0.02%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow
   8316    8356     40   0.48%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go
  10952   10996     44   0.40%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go
  82532   82580     48   0.06%  tinygo build -size short -o ./build/test.hex -target=wioterminal ./examples/rtl8720dn/webclient/
  24876   24932     56   0.23%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/espat/espconsole/main.go
  24860   24932     72   0.29%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/espat/espstation/main.go
  71924   71996     72   0.10%  tinygo build -size short -o ./build/test.hex -target=wioterminal ./examples/rtl8720dn/webserver/
  22008   22100     92   0.42%  tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
  81220   81312     92   0.11%  tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/
  68424   68544    120   0.18%  tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go
  64480   64616    136   0.21%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go
  66772   66920    148   0.22%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go
  68684   68844    160   0.23%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi
  63260   63444    184   0.29%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go
  67956   68148    192   0.28%  tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go
 137600  137792    192   0.14%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/wifinina/webclient/main.go
  98452   98644    192   0.20%  tinygo build -size short -o ./build/test.hex -target=wioterminal ./examples/rtl8720dn/mqttsub/
  65856   66056    200   0.30%  tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go
  61168   61368    200   0.33%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go
  74988   75196    208   0.28%  tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go
  70928   71136    208   0.29%  tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/
  61648   61872    224   0.36%  tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go
  60532   60756    224   0.37%  tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/
  56368   56608    240   0.43%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go
  56424   56664    240   0.43%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go
  56340   56580    240   0.43%  tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go
  63288   63544    256   0.40%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go
  70800   71056    256   0.36%  tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/
  60688   60960    272   0.45%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go
  64636   64916    280   0.43%  tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi
  72008   72288    280   0.39%  tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/
 137184  137504    320   0.23%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/wifinina/ntpclient/main.go
  70440   70768    328   0.47%  tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/
 137176  137512    336   0.24%  tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/wifinina/udpstation/main.go
  68964   69332    368   0.53%  tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/main.go
  25876   26260    384   1.48%  tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go
  69540   70492    952   1.37%  tinygo build -size short -o ./build/test.hex -target=pinetime     ./examples/bma42x/main.go
3822944 3826946   4002  -0.00%   sum

@aykevl aykevl force-pushed the newpm branch 2 times, most recently from 3da1b40 to d337bee Compare September 21, 2023 00:29
@aykevl
Copy link
Member Author

aykevl commented Sep 21, 2023

Huh, why does the unicode/utf8 test fail with this patch?? Perhaps we're uncovering a separate bug here.

EDIT: see #3923

@aykevl aykevl force-pushed the newpm branch 4 times, most recently from a7934f9 to b8ad396 Compare September 23, 2023 13:50
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.
@aykevl
Copy link
Member Author

aykevl commented Sep 23, 2023

Rebased after #3923 was merged.

@QuLogic QuLogic linked an issue Sep 23, 2023 that may be closed by this pull request
@deadprogram
Copy link
Member

Looking good, now merging. Thanks @aykevl

@deadprogram deadprogram merged commit 3b1913a into dev Oct 4, 2023
22 checks passed
@deadprogram deadprogram deleted the newpm branch October 4, 2023 11:05
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.

Legacy passes removed in LLVM17
2 participants