Adapt to LLVM 7+ Orc API changes.
authorAndres Freund <andres@anarazel.de>
Mon, 26 Mar 2018 22:55:16 +0000 (15:55 -0700)
committerAndres Freund <andres@anarazel.de>
Mon, 26 Mar 2018 23:04:53 +0000 (16:04 -0700)
This is mostly done to be able to validate features and fixes
submitted to LLVM. Given the size of these changes that seems
acceptable.

Author: Andres Freund

src/backend/jit/llvm/llvmjit.c

index 53ac8e4425b1e87e7b6b94719deb0e50d4ad9f12..bbb2360232fd35192ed245fc9a98d698d674e4ac 100644 (file)
@@ -527,13 +527,17 @@ llvm_compile_module(LLVMJitContext *context)
     * faster instruction selection mechanism is used.
     */
    INSTR_TIME_SET_CURRENT(starttime);
-#if LLVM_VERSION_MAJOR < 5
+#if LLVM_VERSION_MAJOR > 6
    {
-       orc_handle = LLVMOrcAddEagerlyCompiledIR(compile_orc, context->module,
-                                                llvm_resolve_symbol, NULL);
-       LLVMDisposeModule(context->module);
+       if (LLVMOrcAddEagerlyCompiledIR(compile_orc, &orc_handle, context->module,
+                                       llvm_resolve_symbol, NULL))
+       {
+           elog(ERROR, "failed to JIT module");
+       }
+
+       /* LLVMOrcAddEagerlyCompiledIR takes ownership of the module */
    }
-#else
+#elif LLVM_VERSION_MAJOR > 4
    {
        LLVMSharedModuleRef smod;
 
@@ -545,6 +549,12 @@ llvm_compile_module(LLVMJitContext *context)
        }
        LLVMOrcDisposeSharedModuleRef(smod);
    }
+#else                          /* LLVM 4.0 and 3.9 */
+   {
+       orc_handle = LLVMOrcAddEagerlyCompiledIR(compile_orc, context->module,
+                                                llvm_resolve_symbol, NULL);
+       LLVMDisposeModule(context->module);
+   }
 #endif
    INSTR_TIME_SET_CURRENT(endtime);
    INSTR_TIME_ACCUM_DIFF(context->base.emission_counter,