llvmlite icon indicating copy to clipboard operation
llvmlite copied to clipboard

Update llvmlite to be compatible with llvm-17

Open modiking opened this issue 10 months ago • 16 comments

~/llvm-project# git log
commit 6009708b4367171ccdbf4b5905cb6a803753fe18 (HEAD -> release/17.x, tag: llvmorg-17.0.6, upstream/release/17.x)
~/llvm-project/build-rel-static# cmake \
   -G Ninja \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_ASM_COMPILER=clang \
   -DCMAKE_ASM_COMPILER_ID=Clang \
   -DLLVM_TARGETS_TO_BUILD="X86" \
   -DLLVM_ENABLE_LLD=ON\
   -DLLVM_ENABLE_PROJECTS="clang;lld" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
   -DCMAKE_INSTALL_PREFIX=$1 \
   -DBUILD_SHARED_LIBS=false \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DLLVM_OPTIMIZED_TABLEGEN=true \
    ../llvm
~/llvm-project/build-rel-static# ninja
...
~/migration/llvmlite# git log
commit 4907a4eee128ae5d95eddbd0ce4aeaa83bab4787 (HEAD -> modiking/llvm17, origin/modiking/llvm17)
~/migration/llvmlite# LLVM_CONFIG=/home/modimo/llvm-project/build-rel-static/bin/llvm-config python3.9 setup.py build
~/migration/llvmlite# LD_LIBRARY_PATH=/home/modimo/llvm-project/build-rel-static/lib python3.9 runtests.py 
..s................................................................s.............................................................x.sss...........s.....................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 375 tests in 9.153s

OK (skipped=6, expected failures=1)

TODO:

  1. I haven't hooked up all the boilerplate for every pass. With New Pass Manager (NPM) certain passes become specific to Module/Function/Loop and need adaptors to pass to the FunctionPassManager/ModulePassManager. We can do this with Macros in the code or I can generate separate methods for FPM/MPM. Alternatively, MPM is a superset of FPM so if there's interest we can consolidate everything into just MPM for simplicity.
  2. I haven't tested with SVML patches in LLVM nor with SVML in general. I don't expect too much work beyond rebasing the LLVM patch however. Would appreciate any guidance on how to do this
  3. Currently I don't have a conda package for LLVM. Would appreciate any help on getting that set up

High-level details:

  1. The llvm-c APIs have not been updated from NPM. AFAICT the "c" APIs are ad-hoc maintained by whoever uses them. We can definitely bring up that boilerplate but currently the setup is using the C++ APIs
  2. NPM has additional state for analysis managers it needs to carry. It also must be initialized by the pass builder before using. I've kept the high level python APIs as close as before but we can certainly re-evaluate how we want to expose these to keep things simpler
  3. Opaque pointers means types can no longer be queried on pointers. Instead I've updated the general type query to use global_value_type which looks at the value rather than the pointer

modiking avatar Apr 24 '24 17:04 modiking