From 42af62e86dfa533bae1f25aafa00e561468c8d08 Mon Sep 17 00:00:00 2001 From: Quinton Miller Date: Sun, 12 Mar 2023 12:30:52 +0800 Subject: [PATCH] Support LLVM 16 --- src/llvm/ext/llvm_ext.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/llvm/ext/llvm_ext.cc b/src/llvm/ext/llvm_ext.cc index 0f38b389f802..b7f33c55db0b 100644 --- a/src/llvm/ext/llvm_ext.cc +++ b/src/llvm/ext/llvm_ext.cc @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -26,11 +25,22 @@ using namespace llvm; #define LLVM_VERSION_LE(major, minor) \ (LLVM_VERSION_MAJOR < (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR <= (minor)) +// TODO: remove after #13177 +#if LLVM_VERSION_GE(16, 0) +#include +#else +#include +#endif + #include #include #include #include +#if LLVM_VERSION_GE(16, 0) +#define makeArrayRef ArrayRef +#endif + typedef DIBuilder *DIBuilderRef; #define DIArray DINodeArray template T *unwrapDIptr(LLVMMetadataRef v) { @@ -238,7 +248,11 @@ LLVMMetadataRef LLVMExtDIBuilderCreatePointerType( uint64_t SizeInBits, uint64_t AlignInBits, const char *Name) { DIDerivedType *T = Dref->createPointerType(unwrapDI(PointeeType), SizeInBits, AlignInBits, +#if LLVM_VERSION_GE(16, 0) + std::nullopt, +#else None, +#endif Name); return wrap(T); } @@ -457,7 +471,7 @@ LLVMBool LLVMExtCreateMCJITCompilerForModule( .setOptLevel((CodeGenOpt::Level)options.OptLevel) .setTargetOptions(targetOptions); bool JIT; - if (Optional CM = unwrap(options.CodeModel, JIT)) + if (auto CM = unwrap(options.CodeModel, JIT)) builder.setCodeModel(*CM); if (options.MCJMM) builder.setMCJITMemoryManager(