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

Support LLVM 16 #407

Merged
merged 21 commits into from
Apr 28, 2023
Merged

Support LLVM 16 #407

merged 21 commits into from
Apr 28, 2023

Conversation

FawazTirmizi
Copy link
Contributor

This PR updates the crate to support building and using LLVM 16. The LLVM changelog can be found here, and the llvm-sys MR is here. The commit messages contain a more detailed explanation of what was done in each patch, so I recommend reviewing commit-by-commit.

This closes #400.

This was tested by running the CI on the development fork. I also wrote a small test package to verify support::get_llvm_version(), but I don't believe it is feasible to test it using the test suite.

The following functions are now disabled if the `llvm16-0` feature flag
is set:

`PassRegistry`:
- `initialize_aggressive_inst_combiner()`
- `initialize_instrumentation()`
- `initialize_obj_carc_opts()`

`PassManager`:
- `add_aggressive_inst_combiner_pass()`
- `add_prune_eh_pass()`
This patch disables `FloatValue::const_neg()` for LLVM 16 and beyond.
Added feature flags to pointer type checks in
`Builder::build_atomicrmw()` and `Builder::build_cmpxchg()`.
This patch adds `llvm16-0` to feature gates in the call to
`LLVMDIBuilderCreateCompileUnit` in
`DebugInfoBuilder::create_compile_unit()`. It also adds the flag to the
arguments `sysroot` and `sdk` in the function declaration and to all of
the calls to it, as well as to `DebugInfoBuilder::new()`.

Furthermore, it adds the following enum values to
`flags::DwarfSourceLanguage`:
- `Kotlin`
- `Zig`
- `Crystal`
- `CPlusPlus17`
- `CPlusPlus20`
- `C17`
- `Fortran18`
- `Ada2005`
- `Ada2012`
This patch adds the `FIRST_CUSTOM_METADATA_KIND_ID` value for LLVM 16.
This patch adds `llvm16-0` to the feature gate for `callable_value`.
This patch adds `llvm16-0` to the feature flag set that adds the
`sysroot` and `sdk` arguments to `Module::create_debug_info_builder()`
and passes them in to `debug_info::DebugInfoBuilder::new()`.
This patch adds `llvm16-0` to feature gates in `AnyTypeEnum` and
`BasicTypeEnum`. It also adds and gates the new `LLVMTargetExtTypeKind`
to both of these enums.
This patch exposes `LLVMGetVersion`, a function added in LLVM 16, as
`get_llvm_version()`, which returns a `(u32, u32, u32)` of the major,
minor, and patch version numbers, respectively.
This example is broken for LLVM 15 and is for LLVM 16 too. So continue
to disable it.
This patch just adds the `llvm16-0` feature to the feature gates on the
`sysroot` and `sdk` arguments for calls to
`module::Module::create_debug_info_builder()`
This patch just modifies some feature gates to properly handle LLVM 16
This patch disables tests for the passes that have been removed in LLVM
16 as well as updates some already-existing gates to account for LLVM
16.
This patch disables a series of assertions in `test_floats()` that rely
on the `FloatValue::const_neg()` function that has been removed in an
earlier patch.

It also updates various feature gates to account for LLVM 16.
@TheDan64
Copy link
Owner

Sorry for the delay, I should be able to finish reviewing this soon

Copy link
Owner

@TheDan64 TheDan64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@TheDan64 TheDan64 merged commit 13c6c3b into TheDan64:master Apr 28, 2023
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.

LLVM 16 Support
2 participants