Skip to content

Commit

Permalink
Add LLVM 18 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmth committed May 4, 2024
1 parent 48aed08 commit 58fc65a
Show file tree
Hide file tree
Showing 18 changed files with 104 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
env:
LLVM_INSTALL_PATH: ~/llvm
LLVM_VERSION: "14"
LLVM_LIB_NAME: "libLLVM-14.so"
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -44,7 +45,7 @@ jobs:
path: |
${{ env.LLVM_INSTALL_PATH }}/bin/llvm-config
${{ env.LLVM_INSTALL_PATH }}/bin/opt
${{ env.LLVM_INSTALL_PATH }}/lib/libLLVM-${{ env.LLVM_VERSION }}.so
${{ env.LLVM_INSTALL_PATH }}/lib/${{ env.LLVM_LIB_NAME }}
${{ env.LLVM_INSTALL_PATH }}/lib/libLLVM.so
${{ env.LLVM_INSTALL_PATH }}/include
key: ${{ runner.os }}-llvm-${{ env.LLVM_VERSION }}-opt
Expand All @@ -58,7 +59,7 @@ jobs:
clang-tidy \
llvm-plugin/cpp/*.{cc,hh} \
--warnings-as-errors='*,-llvm-header-guard' \
-- -I"$HOME/llvm/include" -std=c++17 -DLLVM${{ env.LLVM_VERSION }}_0
-- -I"$HOME/llvm/include" -std=c++17 -DLLVM_VERSION_MAJOR=${{ env.LLVM_VERSION }}
- name: Clippy Lint
run: |
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ jobs:
strategy:
matrix:
llvm-version:
- ["10", "10-0", "v10.0.1-rust-1.46/llvm-10.0.1-rust-1.46-linux.tar.gz"]
- ["11", "11-0", "v11.0.1-rust-1.51/llvm-lld-11.0.1-rust-1.51-linux.tar.gz"]
- ["12", "12-0", "v12.0.1-rust-1.55/llvm-lld-12.0.1-rust-1.55-linux.tar.gz"]
- ["13", "13-0", "v13.0.0-rust-1.59/llvm-lld-13.0.0-rust-1.59-linux.tar.gz"]
- ["14", "14-0", "v14.0.6-rust-1.64/llvm-lld-14.0.6-rust-1.64-linux.tar.gz"]
- ["15", "15-0", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-linux.tar.gz"]
- ["16", "16-0", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-linux.tar.gz"]
- ["17", "17-0", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-linux.tar.gz"]
- ["10", "10-0", "v10.0.1-rust-1.46/llvm-10.0.1-rust-1.46-linux.tar.gz", "libLLVM-10.so"]
- ["11", "11-0", "v11.0.1-rust-1.51/llvm-lld-11.0.1-rust-1.51-linux.tar.gz", "libLLVM-11.so"]
- ["12", "12-0", "v12.0.1-rust-1.55/llvm-lld-12.0.1-rust-1.55-linux.tar.gz", "libLLVM-12.so"]
- ["13", "13-0", "v13.0.0-rust-1.59/llvm-lld-13.0.0-rust-1.59-linux.tar.gz", "libLLVM-13.so"]
- ["14", "14-0", "v14.0.6-rust-1.64/llvm-lld-14.0.6-rust-1.64-linux.tar.gz", "libLLVM-14.so"]
- ["15", "15-0", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-linux.tar.gz", "libLLVM-15.so"]
- ["16", "16-0", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-linux.tar.gz", "libLLVM-16.so"]
- ["17", "17-0", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-linux.tar.gz", "libLLVM-17.so"]
- ["18", "18-0", "v18.1.2-rust-1.78/llvm-lld-18.1.2-rust-1.78-linux.tar.gz", "libLLVM.so.18.1"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -39,7 +40,7 @@ jobs:
path: |
${{ env.LLVM_INSTALL_PATH }}/bin/llvm-config
${{ env.LLVM_INSTALL_PATH }}/bin/opt
${{ env.LLVM_INSTALL_PATH }}/lib/libLLVM-${{ matrix.llvm-version[0] }}.so
${{ env.LLVM_INSTALL_PATH }}/lib/${{ matrix.llvm-version[3] }}
${{ env.LLVM_INSTALL_PATH }}/lib/libLLVM.so
${{ env.LLVM_INSTALL_PATH }}/include
key: ${{ runner.os }}-llvm-${{ matrix.llvm-version[0] }}-opt
Expand Down Expand Up @@ -105,13 +106,14 @@ jobs:
strategy:
matrix:
llvm-version:
- ["11", "11-0", "1.51", "v11.0.1-rust-1.51/llvm-lld-11.0.1-rust-1.51-linux.tar.gz"]
- ["12", "12-0", "1.55", "v12.0.1-rust-1.55/llvm-lld-12.0.1-rust-1.55-linux.tar.gz"]
- ["13", "13-0", "1.59", "v13.0.0-rust-1.59/llvm-lld-13.0.0-rust-1.59-linux.tar.gz"]
- ["14", "14-0", "1.64", "v14.0.6-rust-1.64/llvm-lld-14.0.6-rust-1.64-linux.tar.gz"]
- ["15", "15-0", "1.65", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-linux.tar.gz"]
- ["16", "16-0", "1.71", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-linux.tar.gz"]
- ["17", "17-0", "1.75", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-linux.tar.gz"]
- ["11", "11-0", "1.51", "v11.0.1-rust-1.51/llvm-lld-11.0.1-rust-1.51-linux.tar.gz", "libLLVM-11.so"]
- ["12", "12-0", "1.55", "v12.0.1-rust-1.55/llvm-lld-12.0.1-rust-1.55-linux.tar.gz", "libLLVM-12.so"]
- ["13", "13-0", "1.59", "v13.0.0-rust-1.59/llvm-lld-13.0.0-rust-1.59-linux.tar.gz", "libLLVM-13.so"]
- ["14", "14-0", "1.64", "v14.0.6-rust-1.64/llvm-lld-14.0.6-rust-1.64-linux.tar.gz", "libLLVM-14.so"]
- ["15", "15-0", "1.65", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-linux.tar.gz", "libLLVM-15.so"]
- ["16", "16-0", "1.71", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-linux.tar.gz", "libLLVM-16.so"]
- ["17", "17-0", "1.75", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-linux.tar.gz", "libLLVM-17.so"]
- ["18", "18-0", "1.78", "v18.1.2-rust-1.78/llvm-lld-18.1.2-rust-1.78-linux.tar.gz", "libLLVM.so.18.1"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -129,7 +131,7 @@ jobs:
${{ env.LLVM_INSTALL_PATH }}/bin/llvm-config
${{ env.LLVM_INSTALL_PATH }}/bin/lld
${{ env.LLVM_INSTALL_PATH }}/bin/ld.lld
${{ env.LLVM_INSTALL_PATH }}/lib/libLLVM-${{ matrix.llvm-version[0] }}.so
${{ env.LLVM_INSTALL_PATH }}/lib/${{ matrix.llvm-version[4] }}
${{ env.LLVM_INSTALL_PATH }}/lib/libLLVM.so
${{ env.LLVM_INSTALL_PATH }}/include
key: ${{ runner.os }}-llvm-${{ matrix.llvm-version[0] }}-lld
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ env:
jobs:
macos-tests:
name: "LLVM ${{ matrix.llvm-version[0] }} MacOS"
runs-on: macos-latest
runs-on: ${{ matrix.llvm-version[3] }}
env:
LLVM_INSTALL_PATH: ~/llvm
PLUGINS_PATH: tests/plugins/target/debug
strategy:
matrix:
llvm-version:
- ["11", "11-0", "v11.0.1-rust-1.51/llvm-11.0.1-rust-1.51-macos.tar.gz"]
- ["12", "12-0", "v12.0.1-rust-1.55/llvm-lld-12.0.1-rust-1.55-macos.tar.gz"]
- ["13", "13-0", "v13.0.0-rust-1.59/llvm-lld-13.0.0-rust-1.59-macos.tar.gz"]
- ["14", "14-0", "v14.0.6-rust-1.64/llvm-lld-14.0.6-rust-1.64-macos.tar.gz"]
- ["15", "15-0", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-macos.tar.gz"]
- ["16", "16-0", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-macos.tar.gz"]
- ["17", "17-0", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-macos.tar.gz"]
- ["11", "11-0", "v11.0.1-rust-1.51/llvm-11.0.1-rust-1.51-macos.tar.gz", "macos-13"]
- ["12", "12-0", "v12.0.1-rust-1.55/llvm-lld-12.0.1-rust-1.55-macos.tar.gz", "macos-13"]
- ["13", "13-0", "v13.0.0-rust-1.59/llvm-lld-13.0.0-rust-1.59-macos.tar.gz", "macos-13"]
- ["14", "14-0", "v14.0.6-rust-1.64/llvm-lld-14.0.6-rust-1.64-macos.tar.gz", "macos-13"]
- ["15", "15-0", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-macos.tar.gz", "macos-13"]
- ["16", "16-0", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-macos.tar.gz", "macos-13"]
- ["17", "17-0", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-macos.tar.gz", "macos-13"]
- ["18", "18-0", "v18.1.2-rust-1.78/llvm-lld-18.1.2-rust-1.78-macos.tar.gz", "macos-latest"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- ["15", "15-0", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-windows.7z"]
- ["16", "16-0", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-windows.7z"]
- ["17", "17-0", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-windows.7z"]
- ["18", "18-0", "v18.1.2-rust-1.78/llvm-lld-18.1.2-rust-1.78-windows.7z"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -110,6 +111,7 @@ jobs:
- ["15", "15-0", "1.65", "v15.0.0-rust-1.65/llvm-lld-15.0.0-rust-1.65-windows.7z"]
- ["16", "16-0", "1.71", "v16.0.2-rust-1.71/llvm-lld-16.0.2-rust-1.71-windows.7z"]
- ["17", "17-0", "1.75", "v17.0.6-rust-1.75/llvm-lld-17.0.6-rust-1.75-windows.7z"]
- ["18", "18-0", "1.78", "v18.1.2-rust-1.78/llvm-lld-18.1.2-rust-1.78-windows.7z"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Supported versions:
| 15.0.x | llvm15-0 | **✓** | **✓** | **✓** |
| 16.0.x | llvm16-0 | **✓** | **✓** | **✓** |
| 17.0.x | llvm17-0 | **✓** | **✓** | **✓** |
| 18.0.x | llvm18-0 | **✓** | **✓** | **✓** |

## Getting Started

Expand Down
42 changes: 36 additions & 6 deletions examples/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ fn create_decode_fn<'a>(module: &mut Module<'a>) -> FunctionValue<'a> {
"",
)
.unwrap();
#[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
#[cfg(not(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
)))]
let var10 = unsafe {
builder.build_gep(
phi1.as_basic_value().into_pointer_value(),
Expand All @@ -160,7 +165,12 @@ fn create_decode_fn<'a>(module: &mut Module<'a>) -> FunctionValue<'a> {
)
}
.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
#[cfg(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
let var10 = unsafe {
builder.build_gep(
cx.i8_type(),
Expand All @@ -170,9 +180,19 @@ fn create_decode_fn<'a>(module: &mut Module<'a>) -> FunctionValue<'a> {
)
}
.unwrap();
#[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
#[cfg(not(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
)))]
let var11 = builder.build_load(phi1.as_basic_value().into_pointer_value(), "");
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
#[cfg(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
let var11 = builder
.build_load(cx.i8_type(), phi1.as_basic_value().into_pointer_value(), "")
.unwrap();
Expand Down Expand Up @@ -229,11 +249,21 @@ fn create_decode_stub<'a>(
(s, len)
}
GlobalString::Struct(gs, id, len) => {
#[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
#[cfg(not(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
)))]
let s = builder
.build_struct_gep(gs.as_pointer_value(), id, "")
.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
#[cfg(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
let s = {
let i8_ty_ptr = cx.i8_type().ptr_type(AddressSpace::default());
let struct_ty = cx.struct_type(&[i8_ty_ptr.into()], false);
Expand Down
5 changes: 3 additions & 2 deletions llvm-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ llvm14-0 = ["inkwell/llvm14-0-no-llvm-linking"]
llvm15-0 = ["inkwell/llvm15-0-no-llvm-linking"]
llvm16-0 = ["inkwell/llvm16-0-no-llvm-linking"]
llvm17-0 = ["inkwell/llvm17-0-no-llvm-linking"]
llvm18-0 = ["inkwell/llvm18-0-no-llvm-linking"]

target-x86 = ["inkwell/target-x86"]
target-arm = ["inkwell/target-arm"]
Expand All @@ -52,8 +53,8 @@ target-riscv = ["inkwell/target-riscv"]
target-all = ["inkwell/target-all"]

[dependencies]
inkwell = "0.4"
inkwell_internals = "0.9.0"
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master" }
inkwell_internals = { git = "https://github.com/TheDan64/inkwell", branch = "master" }
llvm-plugin-macros = { path = "../llvm-plugin-macros", version = "0.2", optional = true }

[build-dependencies]
Expand Down
5 changes: 2 additions & 3 deletions llvm-plugin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ fn main() {
build.flag_if_supported("-fno-rtti");
}

build.define("LLVM_VERSION_MAJOR", major.to_string().as_str());
build.define("LLVM_VERSION_MINOR", minor.to_string().as_str());

build.warnings(false);
build.compile("llvm-plugin-cpp");

Expand Down Expand Up @@ -216,6 +213,8 @@ mod llvm_sys {
(16, 0)
} else if cfg!(feature = "llvm17-0") {
(17, 0)
} else if cfg!(feature = "llvm18-0") {
(18, 0)
} else {
panic!("Missing llvm* feature")
}
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin1-lld/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin6/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
10 changes: 9 additions & 1 deletion tests/plugins/plugin6/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn plugin_registrar(builder: &mut PassBuilder) {
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
builder.add_pipeline_start_ep_callback(|manager, opt| {
assert!(matches!(opt, OptimizationLevel::O3));
Expand All @@ -42,6 +43,7 @@ fn plugin_registrar(builder: &mut PassBuilder) {
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
builder.add_pipeline_early_simplification_ep_callback(|manager, opt| {
assert!(matches!(opt, OptimizationLevel::O3));
Expand All @@ -56,13 +58,19 @@ fn plugin_registrar(builder: &mut PassBuilder) {
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
builder.add_optimizer_last_ep_callback(|manager, opt| {
assert!(matches!(opt, OptimizationLevel::O3));
manager.add_pass(OptimizerLastPass);
});

#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
#[cfg(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
builder.add_optimizer_early_ep_callback(|manager, opt| {
assert!(matches!(opt, OptimizationLevel::O3));
manager.add_pass(OptimizerEarlyPass);
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/plugin7/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm14-0 = ["llvm-plugin/llvm14-0"]
llvm15-0 = ["llvm-plugin/llvm15-0"]
llvm16-0 = ["llvm-plugin/llvm16-0"]
llvm17-0 = ["llvm-plugin/llvm17-0"]
llvm18-0 = ["llvm-plugin/llvm18-0"]

target-x86 = ["llvm-plugin/target-x86"]
target-arm = ["llvm-plugin/target-arm"]
Expand Down
14 changes: 12 additions & 2 deletions tests/plugins/plugin7/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ use llvm_plugin::{LlvmModulePass, ModuleAnalysisManager, PassBuilder, PreservedA

#[llvm_plugin::plugin(name = "llvm_plugin", version = "0.1")]
fn plugin_registrar(builder: &mut PassBuilder) {
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
#[cfg(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
builder.add_full_lto_early_ep_callback(|manager, opt| {
assert!(matches!(opt, llvm_plugin::OptimizationLevel::O3));
manager.add_pass(FullLtoEarlyPass);
});

#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
#[cfg(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0",
))]
builder.add_full_lto_last_ep_callback(|manager, opt| {
assert!(matches!(opt, llvm_plugin::OptimizationLevel::O3));
manager.add_pass(FullLtoLastPass);
Expand Down

0 comments on commit 58fc65a

Please sign in to comment.