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

Upgrade to LLVM 14 #12001

Merged
merged 62 commits into from
Jul 10, 2022
Merged

Upgrade to LLVM 14 #12001

merged 62 commits into from
Jul 10, 2022

Conversation

andrewrk
Copy link
Member

@andrewrk andrewrk commented Jul 5, 2022

Does not contain a workaround for llvm/llvm-project#55522, which means that using @Vector with bool will be regressed after merging this, until the upstream bug is fixed, probably in LLVM 15.0.0. The good news however is that the way stage2 lowers code in the LLVM backend makes the bug less likely to be triggered. In the future we will do better at staying on top of LLVM release candidates in order to report such issues and file them as release blockers.

Other than this, things seem to be working fine. I noticed that even in master branch, the zig test suite does not run assertion-clean against a debug build of LLVM 13. My next priority will be to remedy this, and then follow it up with running the full test suite again, this time with LLVM 14 debug mode, to check for assertions tripped.

Closes #11274

upstream commit 91632c8ac97fa3daffe4ff8f1391735b5d6805e6
upstream commit 91632c8ac97fa3daffe4ff8f1391735b5d6805e6
 * zig_clang is fully updated
 * zig_llvm is fully updated

Some initial work on codegen.cpp is in place for upgrading to LLVM's
new opaque pointers. However there is much more to be done.

A few of zig llvm bindings for deprecated functions have been updated;
more need to be updated.
LLVM 14 deprecated a bunch of C API functions in preparation for opaque
pointer changes. However, they did not actually implement opaque pointer
semantics, so the deprecations are largely masturbatory. I have nothing
against masturbation, I am just busy trying to get the self hosted
compiler done for 0.10.0, so we will come back to this later.
LLVM pointers are transitioning to no longer have types, however, inline
assembly inputs and outputs which accept pointers need to know the
element type. So, inline assembly must be upgraded to add
elementtype(<ty>) annotations.
Notable changes:

`_i386`, `_i486`, and `_i686` are renamed to `i386`, `i486`,
and `i686` respectively. `std.zig.fmtId` is enhanced to support
formatting `i386` as `@"i386"`.

Some CPU features which are actually CPU models have been
properly flattened, such as `apple_a12`, `apple_a13`, `apple_a7`,
`cortex_a78c`, `exynos_m4`, `neoverse_e1`, `neoverse_n1`,
`neoverse_n2`, `neoverse_v1`.

Some CPU features have been added and some have been removed, following
LLVM's lead.

CSky CPU features support is added.
integer types are valid ids; we need different logic inside the
update_cpu_features tool, not to change the fmtId function.
This file contains build configuration options which zig instead
provides via command line flags.
It appears that libcxx files now want to additionally include based
from the src/ directory.
This is the equivalent of d19290e
applied to stage2 instead of stage1.
LLVM 14 makes it so that a RHS of saturating shift left produces a
poison value if the value is greater than the number of bits of the LHS.
Zig now emits code that will check if this is the case and select a
saturated LHS value in such case, matching Zig semantics.
This follows LLVM14's lead on vector alignment, which computes byte
count based on the length premultiplied by bits.

This commit also disables behavior tests regressed by LLVM 14, only for
stage1. stage2 fortunately does not trip the regression.
stage2 already has this fixed; debug info is given size in bits rather
than ABI size (bytes) multiplied by 8.

closes #11587
LLVM 14 optimizes differently, so it's reasonable to have there be a
binary difference here.
@Jarred-Sumner
Copy link
Contributor

Does not contain a workaround for llvm/llvm-project#55522, which means that using @vector with bool will be regressed after merging this, until the upstream bug is fixed, probably in LLVM 15.0.0.

That issue is 😆

andrewrk added 17 commits July 6, 2022 20:12
The previous tarballs were stage3 which is not quite ready for primetime
yet.
This is intended to fix this error:

lld-link: error: undefined symbol: _GUID const& __mingw_uuidof<IEnumSetupInstances>()
>>> referenced by D:\a\1\s\src\windows_com.hpp:898
>>>               D:\a\1\s\zig-cache\o\a5030d467932f0ce2f6511feb7d6af12\windows_sdk.obj:(__IEnumSetupInstances_IID_getter())

Thank you to Martin Storsjö for suggesting the fix.
@andrewrk
Copy link
Member Author

Here is one performance data point, building Tetris from source:

[nix-shell:~/dev/tetris]$ hyperfine '/home/andy/Downloads/zig/build-release/stage1/bin/zig build -fno-stage1' '/home/andy/dev/zig/build-release/stage1/bin/zig build -fno-stage1' '/home/andy/Downloads/zig/build-release/stage1/bin/zig build' '/home/andy/dev/zig/build-release/stage1/bin/zig build' --warmup 2 -p 'rm -rf zig-cache zig-out'
Benchmark 1: /home/andy/Downloads/zig/build-release/stage1/bin/zig build -fno-stage1
  Time (mean ± σ):      2.758 s ±  0.032 s    [User: 2.829 s, System: 0.238 s]
  Range (min … max):    2.718 s …  2.797 s    10 runs
 
Benchmark 2: /home/andy/dev/zig/build-release/stage1/bin/zig build -fno-stage1
  Time (mean ± σ):      5.590 s ±  0.062 s    [User: 5.698 s, System: 0.250 s]
  Range (min … max):    5.494 s …  5.669 s    10 runs
 
Benchmark 3: /home/andy/Downloads/zig/build-release/stage1/bin/zig build
  Time (mean ± σ):      2.804 s ±  0.019 s    [User: 2.725 s, System: 0.386 s]
  Range (min … max):    2.770 s …  2.836 s    10 runs
 
Benchmark 4: /home/andy/dev/zig/build-release/stage1/bin/zig build
  Time (mean ± σ):      4.623 s ±  0.041 s    [User: 4.586 s, System: 0.392 s]
  Range (min … max):    4.542 s …  4.689 s    10 runs
 
Summary
  'LLVM13 stage2' ran
    1.02 ± 0.01 times faster than 'LLVM13 stage1'
    1.68 ± 0.02 times faster than 'LLVM14 stage1'
    2.03 ± 0.03 times faster than 'LLVM14 stage2'

@andrewrk andrewrk merged commit b88151e into master Jul 10, 2022
@andrewrk andrewrk deleted the llvm14 branch July 10, 2022 07:06
TUSF pushed a commit to TUSF/zig that referenced this pull request May 9, 2024
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.

Upgrade to LLVM 14
2 participants