From c1d92f1aac673233b36139bc7c342bea0d4386ae Mon Sep 17 00:00:00 2001 From: Nick Avramoussis <4256455+Idclip@users.noreply.github.com> Date: Sat, 4 Mar 2023 17:00:52 +0000 Subject: [PATCH 1/2] Added basic support for LLVM 15 by toggling off opaque pointer support on all contexts Signed-off-by: Nick Avramoussis <4256455+Idclip@users.noreply.github.com> --- openvdb_ax/openvdb_ax/CMakeLists.txt | 13 +++++++++++-- openvdb_ax/openvdb_ax/compiler/Compiler.cc | 18 +++++++++--------- .../openvdb_ax/test/backend/TestCodecs.cc | 5 +++++ openvdb_ax/openvdb_ax/test/backend/util.h | 8 +++++++- .../test/compiler/TestVolumeExecutable.cc | 6 ++++++ .../test/integration/TestVDBFunctions.cc | 6 ++++++ pendingchanges/vdb_ax.txt | 3 +++ 7 files changed, 47 insertions(+), 12 deletions(-) diff --git a/openvdb_ax/openvdb_ax/CMakeLists.txt b/openvdb_ax/openvdb_ax/CMakeLists.txt index ef8c0c70c2..91cc7389ac 100644 --- a/openvdb_ax/openvdb_ax/CMakeLists.txt +++ b/openvdb_ax/openvdb_ax/CMakeLists.txt @@ -113,9 +113,9 @@ else() set(LLVM_LIBS "${_llvm_libs}") endif() -if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 15.0.0) +if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 16.0.0) # https://llvm.org/docs/OpaquePointers.html - message(FATAL_ERROR "OpenVDB AX does not currently support LLVM versions >= 15 due to \ + message(FATAL_ERROR "OpenVDB AX does not currently support LLVM versions >= 16 due to \ opaque pointer changes in LLVM. Found unsuitable LLVM version \"${LLVM_PACKAGE_VERSION}\"") endif() @@ -319,6 +319,11 @@ if(OPENVDB_AX_STATIC) ) target_link_libraries(openvdb_ax_static PUBLIC ${OPENVDB_AX_CORE_DEPENDENT_LIBS}) + + # @todo fix opaque pointer requirements + if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 15.0.0) + target_compile_options(openvdb_ax_static PUBLIC "-Wno-error=deprecated-declarations") + endif() endif() # Configure shared build @@ -351,6 +356,10 @@ if(OPENVDB_AX_SHARED) ) target_link_libraries(openvdb_ax_shared PUBLIC ${OPENVDB_AX_CORE_DEPENDENT_LIBS}) + # @todo fix opaque pointer requirements + if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 15.0.0) + target_compile_options(openvdb_ax_shared PUBLIC "-Wno-error=deprecated-declarations") + endif() endif() install(FILES ax.h Exceptions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/) diff --git a/openvdb_ax/openvdb_ax/compiler/Compiler.cc b/openvdb_ax/openvdb_ax/compiler/Compiler.cc index f44316fc3d..1f2d7b8470 100644 --- a/openvdb_ax/openvdb_ax/compiler/Compiler.cc +++ b/openvdb_ax/openvdb_ax/compiler/Compiler.cc @@ -113,6 +113,7 @@ initializeExecutionEngine(std::unique_ptr M, Logger& logger) #ifndef USE_NEW_PASS_MANAGER +#if LLVM_VERSION_MAJOR < 15 void addStandardLinkPasses(llvm::legacy::PassManagerBase& passes) { llvm::PassManagerBuilder builder; @@ -120,6 +121,7 @@ void addStandardLinkPasses(llvm::legacy::PassManagerBase& passes) builder.Inliner = llvm::createFunctionInliningPass(); builder.populateLTOPassManager(passes); } +#endif /// This routine adds optimization passes based on selected optimization level /// @@ -129,7 +131,6 @@ void addOptimizationPasses(llvm::legacy::PassManagerBase& passes, const unsigned optLevel, const unsigned sizeLevel, const bool disableInline = false, - const bool disableUnitAtATime = false, const bool disableLoopUnrolling = false, const bool disableLoopVectorization = false, const bool disableSLPVectorization = false) @@ -148,14 +149,6 @@ void addOptimizationPasses(llvm::legacy::PassManagerBase& passes, builder.Inliner = llvm::createAlwaysInlinerLegacyPass(); } -#if LLVM_VERSION_MAJOR < 9 - // Enable IPO. This corresponds to gcc's -funit-at-a-time - builder.DisableUnitAtATime = disableUnitAtATime; -#else - // unused from llvm 9 - (void)(disableUnitAtATime); -#endif - // Disable loop unrolling in all relevant passes builder.DisableUnrollLoops = disableLoopUnrolling ? disableLoopUnrolling : optLevel == 0; @@ -198,7 +191,9 @@ void LLVMoptimise(llvm::Module& module, else functionPasses.add(llvm::createTargetTransformInfoWrapperPass(llvm::TargetIRAnalysis())); +#if LLVM_VERSION_MAJOR < 15 addStandardLinkPasses(passes); +#endif addOptimizationPasses(passes, functionPasses, TM, optLevel, sizeLevel); functionPasses.doInitialization(); @@ -663,6 +658,11 @@ Compiler::Compiler(const CompilerOptions& options) , mFunctionRegistry() { mContext.reset(new llvm::LLVMContext); +#if LLVM_VERSION_MAJOR >= 15 + // This will not work from LLVM 16. We'll need to fix this + // https://llvm.org/docs/OpaquePointers.html + mContext->setOpaquePointers(false); +#endif mFunctionRegistry = codegen::createDefaultRegistry(&options.mFunctionOptions); } diff --git a/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc b/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc index f5306e1093..6ee11452ad 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc @@ -65,6 +65,11 @@ void TestCodecs::testRegisteredCodecs() // enforced as part of the API but the majority of the setup code is internal. llvm::LLVMContext C; +#if LLVM_VERSION_MAJOR >= 15 + // This will not work from LLVM 16. We'll need to fix this + // https://llvm.org/docs/OpaquePointers.html + C.setOpaquePointers(false); +#endif // Get all unique registered codecs std::set codecs; diff --git a/openvdb_ax/openvdb_ax/test/backend/util.h b/openvdb_ax/openvdb_ax/test/backend/util.h index 75c2b82ef0..e757cd3580 100644 --- a/openvdb_ax/openvdb_ax/test/backend/util.h +++ b/openvdb_ax/openvdb_ax/test/backend/util.h @@ -21,7 +21,13 @@ namespace unittest_util struct LLVMState { LLVMState(const std::string& name = "__test_module") - : mCtx(new llvm::LLVMContext), mModule(new llvm::Module(name, *mCtx)) {} + : mCtx(new llvm::LLVMContext), mModule(new llvm::Module(name, *mCtx)) { +#if LLVM_VERSION_MAJOR >= 15 + // This will not work from LLVM 16. We'll need to fix this + // https://llvm.org/docs/OpaquePointers.html + mCtx->setOpaquePointers(false); +#endif + } llvm::LLVMContext& context() { return *mCtx; } llvm::Module& module() { return *mModule; } diff --git a/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc b/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc index 4e390a6638..87faf11228 100644 --- a/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc +++ b/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc @@ -47,6 +47,12 @@ TestVolumeExecutable::testConstructionDestruction() CPPUNIT_ASSERT(openvdb::ax::isInitialized()); std::shared_ptr C(new llvm::LLVMContext); +#if LLVM_VERSION_MAJOR >= 15 + // This will not work from LLVM 16. We'll need to fix this + // https://llvm.org/docs/OpaquePointers.html + C->setOpaquePointers(false); +#endif + std::unique_ptr M(new llvm::Module("test_module", *C)); std::shared_ptr E(llvm::EngineBuilder(std::move(M)) .setEngineKind(llvm::EngineKind::JIT) diff --git a/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc b/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc index 27964ecfe0..723bb837fb 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc @@ -368,6 +368,12 @@ void TestVDBFunctions::testValidContext() { std::shared_ptr C(new llvm::LLVMContext); +#if LLVM_VERSION_MAJOR >= 15 + // This will not work from LLVM 16. We'll need to fix this + // https://llvm.org/docs/OpaquePointers.html + C->setOpaquePointers(false); +#endif + openvdb::ax::Compiler compiler; openvdb::ax::FunctionOptions ops; ops.mLazyFunctions = false; diff --git a/pendingchanges/vdb_ax.txt b/pendingchanges/vdb_ax.txt index f0236718ef..78ee6b7a74 100644 --- a/pendingchanges/vdb_ax.txt +++ b/pendingchanges/vdb_ax.txt @@ -1,4 +1,7 @@ AX: +- Improvements: + Added support for LLVM 15 + - Bug Fix: Fixed an incorrect option in the `vdb_ax` command line tool where the default optimization level was set to NONE instead of O3 (issue introduced in 10.0.0). From 4a31d7f821ef18c1492b112607b906ae9f6533f2 Mon Sep 17 00:00:00 2001 From: Nick Avramoussis <4256455+Idclip@users.noreply.github.com> Date: Sat, 4 Mar 2023 17:53:00 +0000 Subject: [PATCH 2/2] Added LLVM 15 CI Signed-off-by: Nick Avramoussis <4256455+Idclip@users.noreply.github.com> --- .github/workflows/weekly.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index c943a282df..ad3113249d 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -233,8 +233,7 @@ jobs: matrix: config: - { cxx: 'clang++', build: 'Release', llvm: '14', dir: '@14' } - # Can't support LLVM >= 15 - #- { cxx: 'clang++', build: 'Release', llvm: 'latest', dir: '' } + - { cxx: 'clang++', build: 'Release', llvm: 'latest', dir: '' } fail-fast: false steps: - uses: actions/checkout@v2