Skip to content

Commit ffc71c3

Browse files
authored
Merge pull request #1592 from Idclip/llvm15
Added basic support for LLVM 15 in OpenVDB AX
2 parents 19710c1 + 4a31d7f commit ffc71c3

File tree

8 files changed

+48
-14
lines changed

8 files changed

+48
-14
lines changed

.github/workflows/weekly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ jobs:
233233
matrix:
234234
config:
235235
- { cxx: 'clang++', build: 'Release', llvm: '14', dir: '@14' }
236-
# Can't support LLVM >= 15
237-
#- { cxx: 'clang++', build: 'Release', llvm: 'latest', dir: '' }
236+
- { cxx: 'clang++', build: 'Release', llvm: 'latest', dir: '' }
238237
fail-fast: false
239238
steps:
240239
- uses: actions/checkout@v2

openvdb_ax/openvdb_ax/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ else()
113113
set(LLVM_LIBS "${_llvm_libs}")
114114
endif()
115115

116-
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 15.0.0)
116+
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 16.0.0)
117117
# https://llvm.org/docs/OpaquePointers.html
118-
message(FATAL_ERROR "OpenVDB AX does not currently support LLVM versions >= 15 due to \
118+
message(FATAL_ERROR "OpenVDB AX does not currently support LLVM versions >= 16 due to \
119119
opaque pointer changes in LLVM. Found unsuitable LLVM version \"${LLVM_PACKAGE_VERSION}\"")
120120
endif()
121121

@@ -319,6 +319,11 @@ if(OPENVDB_AX_STATIC)
319319
)
320320

321321
target_link_libraries(openvdb_ax_static PUBLIC ${OPENVDB_AX_CORE_DEPENDENT_LIBS})
322+
323+
# @todo fix opaque pointer requirements
324+
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 15.0.0)
325+
target_compile_options(openvdb_ax_static PUBLIC "-Wno-error=deprecated-declarations")
326+
endif()
322327
endif()
323328

324329
# Configure shared build
@@ -351,6 +356,10 @@ if(OPENVDB_AX_SHARED)
351356
)
352357

353358
target_link_libraries(openvdb_ax_shared PUBLIC ${OPENVDB_AX_CORE_DEPENDENT_LIBS})
359+
# @todo fix opaque pointer requirements
360+
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 15.0.0)
361+
target_compile_options(openvdb_ax_shared PUBLIC "-Wno-error=deprecated-declarations")
362+
endif()
354363
endif()
355364

356365
install(FILES ax.h Exceptions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/)

openvdb_ax/openvdb_ax/compiler/Compiler.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,15 @@ initializeExecutionEngine(std::unique_ptr<llvm::Module> M, Logger& logger)
113113

114114
#ifndef USE_NEW_PASS_MANAGER
115115

116+
#if LLVM_VERSION_MAJOR < 15
116117
void addStandardLinkPasses(llvm::legacy::PassManagerBase& passes)
117118
{
118119
llvm::PassManagerBuilder builder;
119120
builder.VerifyInput = true;
120121
builder.Inliner = llvm::createFunctionInliningPass();
121122
builder.populateLTOPassManager(passes);
122123
}
124+
#endif
123125

124126
/// This routine adds optimization passes based on selected optimization level
125127
///
@@ -129,7 +131,6 @@ void addOptimizationPasses(llvm::legacy::PassManagerBase& passes,
129131
const unsigned optLevel,
130132
const unsigned sizeLevel,
131133
const bool disableInline = false,
132-
const bool disableUnitAtATime = false,
133134
const bool disableLoopUnrolling = false,
134135
const bool disableLoopVectorization = false,
135136
const bool disableSLPVectorization = false)
@@ -148,14 +149,6 @@ void addOptimizationPasses(llvm::legacy::PassManagerBase& passes,
148149
builder.Inliner = llvm::createAlwaysInlinerLegacyPass();
149150
}
150151

151-
#if LLVM_VERSION_MAJOR < 9
152-
// Enable IPO. This corresponds to gcc's -funit-at-a-time
153-
builder.DisableUnitAtATime = disableUnitAtATime;
154-
#else
155-
// unused from llvm 9
156-
(void)(disableUnitAtATime);
157-
#endif
158-
159152
// Disable loop unrolling in all relevant passes
160153
builder.DisableUnrollLoops =
161154
disableLoopUnrolling ? disableLoopUnrolling : optLevel == 0;
@@ -198,7 +191,9 @@ void LLVMoptimise(llvm::Module& module,
198191
else functionPasses.add(llvm::createTargetTransformInfoWrapperPass(llvm::TargetIRAnalysis()));
199192

200193

194+
#if LLVM_VERSION_MAJOR < 15
201195
addStandardLinkPasses(passes);
196+
#endif
202197
addOptimizationPasses(passes, functionPasses, TM, optLevel, sizeLevel);
203198

204199
functionPasses.doInitialization();
@@ -663,6 +658,11 @@ Compiler::Compiler(const CompilerOptions& options)
663658
, mFunctionRegistry()
664659
{
665660
mContext.reset(new llvm::LLVMContext);
661+
#if LLVM_VERSION_MAJOR >= 15
662+
// This will not work from LLVM 16. We'll need to fix this
663+
// https://llvm.org/docs/OpaquePointers.html
664+
mContext->setOpaquePointers(false);
665+
#endif
666666
mFunctionRegistry = codegen::createDefaultRegistry(&options.mFunctionOptions);
667667
}
668668

openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ void TestCodecs::testRegisteredCodecs()
6565
// enforced as part of the API but the majority of the setup code is internal.
6666

6767
llvm::LLVMContext C;
68+
#if LLVM_VERSION_MAJOR >= 15
69+
// This will not work from LLVM 16. We'll need to fix this
70+
// https://llvm.org/docs/OpaquePointers.html
71+
C.setOpaquePointers(false);
72+
#endif
6873

6974
// Get all unique registered codecs
7075
std::set<const Codec*> codecs;

openvdb_ax/openvdb_ax/test/backend/util.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ namespace unittest_util
2121
struct LLVMState
2222
{
2323
LLVMState(const std::string& name = "__test_module")
24-
: mCtx(new llvm::LLVMContext), mModule(new llvm::Module(name, *mCtx)) {}
24+
: mCtx(new llvm::LLVMContext), mModule(new llvm::Module(name, *mCtx)) {
25+
#if LLVM_VERSION_MAJOR >= 15
26+
// This will not work from LLVM 16. We'll need to fix this
27+
// https://llvm.org/docs/OpaquePointers.html
28+
mCtx->setOpaquePointers(false);
29+
#endif
30+
}
2531

2632
llvm::LLVMContext& context() { return *mCtx; }
2733
llvm::Module& module() { return *mModule; }

openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ TestVolumeExecutable::testConstructionDestruction()
4747
CPPUNIT_ASSERT(openvdb::ax::isInitialized());
4848

4949
std::shared_ptr<llvm::LLVMContext> C(new llvm::LLVMContext);
50+
#if LLVM_VERSION_MAJOR >= 15
51+
// This will not work from LLVM 16. We'll need to fix this
52+
// https://llvm.org/docs/OpaquePointers.html
53+
C->setOpaquePointers(false);
54+
#endif
55+
5056
std::unique_ptr<llvm::Module> M(new llvm::Module("test_module", *C));
5157
std::shared_ptr<const llvm::ExecutionEngine> E(llvm::EngineBuilder(std::move(M))
5258
.setEngineKind(llvm::EngineKind::JIT)

openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ void
368368
TestVDBFunctions::testValidContext()
369369
{
370370
std::shared_ptr<llvm::LLVMContext> C(new llvm::LLVMContext);
371+
#if LLVM_VERSION_MAJOR >= 15
372+
// This will not work from LLVM 16. We'll need to fix this
373+
// https://llvm.org/docs/OpaquePointers.html
374+
C->setOpaquePointers(false);
375+
#endif
376+
371377
openvdb::ax::Compiler compiler;
372378
openvdb::ax::FunctionOptions ops;
373379
ops.mLazyFunctions = false;

pendingchanges/vdb_ax.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
AX:
2+
- Improvements:
3+
Added support for LLVM 15
4+
25
- Bug Fix:
36
Fixed an incorrect option in the `vdb_ax` command line tool where the default
47
optimization level was set to NONE instead of O3 (issue introduced in 10.0.0).

0 commit comments

Comments
 (0)