3434#include <llvm-c/Transforms/IPO.h>
3535#include <llvm-c/Transforms/PassManagerBuilder.h>
3636#include <llvm-c/Transforms/Scalar.h>
37- #if LLVM_VERSION_MAJOR > 6
3837#include <llvm-c/Transforms/Utils.h>
3938#endif
40- #endif
4139
4240#include "jit/llvmjit.h"
4341#include "jit/llvmjit_emit.h"
@@ -381,10 +379,7 @@ llvm_expand_funcname(struct LLVMJitContext *context, const char *basename)
381379void *
382380llvm_get_function (LLVMJitContext * context , const char * funcname )
383381{
384- #if LLVM_VERSION_MAJOR > 11 || \
385- defined(HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN ) && HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
386382 ListCell * lc ;
387- #endif
388383
389384 llvm_assert_in_fatal_section ();
390385
@@ -432,7 +427,7 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
432427 if (addr )
433428 return (void * ) (uintptr_t ) addr ;
434429 }
435- #elif defined( HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN ) && HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
430+ #else
436431 foreach (lc , context -> handles )
437432 {
438433 LLVMOrcTargetAddress addr ;
@@ -444,28 +439,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
444439 if (addr )
445440 return (void * ) (uintptr_t ) addr ;
446441 }
447- #elif LLVM_VERSION_MAJOR < 5
448- {
449- LLVMOrcTargetAddress addr ;
450-
451- if ((addr = LLVMOrcGetSymbolAddress (llvm_opt0_orc , funcname )))
452- return (void * ) (uintptr_t ) addr ;
453- if ((addr = LLVMOrcGetSymbolAddress (llvm_opt3_orc , funcname )))
454- return (void * ) (uintptr_t ) addr ;
455- }
456- #else
457- {
458- LLVMOrcTargetAddress addr ;
459-
460- if (LLVMOrcGetSymbolAddress (llvm_opt0_orc , & addr , funcname ))
461- elog (ERROR , "failed to look up symbol \"%s\"" , funcname );
462- if (addr )
463- return (void * ) (uintptr_t ) addr ;
464- if (LLVMOrcGetSymbolAddress (llvm_opt3_orc , & addr , funcname ))
465- elog (ERROR , "failed to look up symbol \"%s\"" , funcname );
466- if (addr )
467- return (void * ) (uintptr_t ) addr ;
468- }
469442#endif
470443
471444 elog (ERROR , "failed to JIT: %s" , funcname );
@@ -553,12 +526,8 @@ llvm_copy_attributes_at_index(LLVMValueRef v_from, LLVMValueRef v_to, uint32 ind
553526 int num_attributes ;
554527 LLVMAttributeRef * attrs ;
555528
556- num_attributes = LLVMGetAttributeCountAtIndexPG (v_from , index );
529+ num_attributes = LLVMGetAttributeCountAtIndex (v_from , index );
557530
558- /*
559- * Not just for efficiency: LLVM <= 3.9 crashes when
560- * LLVMGetAttributesAtIndex() is called for an index with 0 attributes.
561- */
562531 if (num_attributes == 0 )
563532 return ;
564533
@@ -852,7 +821,7 @@ llvm_compile_module(LLVMJitContext *context)
852821
853822 /* LLVMOrcLLJITAddLLVMIRModuleWithRT takes ownership of the module */
854823 }
855- #elif LLVM_VERSION_MAJOR > 6
824+ #else
856825 {
857826 handle -> stack = compile_orc ;
858827 if (LLVMOrcAddEagerlyCompiledIR (compile_orc , & handle -> orc_handle , context -> module ,
@@ -861,26 +830,6 @@ llvm_compile_module(LLVMJitContext *context)
861830
862831 /* LLVMOrcAddEagerlyCompiledIR takes ownership of the module */
863832 }
864- #elif LLVM_VERSION_MAJOR > 4
865- {
866- LLVMSharedModuleRef smod ;
867-
868- smod = LLVMOrcMakeSharedModule (context -> module );
869- handle -> stack = compile_orc ;
870- if (LLVMOrcAddEagerlyCompiledIR (compile_orc , & handle -> orc_handle , smod ,
871- llvm_resolve_symbol , NULL ))
872- elog (ERROR , "failed to JIT module" );
873-
874- LLVMOrcDisposeSharedModuleRef (smod );
875- }
876- #else /* LLVM 4.0 and 3.9 */
877- {
878- handle -> stack = compile_orc ;
879- handle -> orc_handle = LLVMOrcAddEagerlyCompiledIR (compile_orc , context -> module ,
880- llvm_resolve_symbol , NULL );
881-
882- LLVMDisposeModule (context -> module );
883- }
884833#endif
885834
886835 INSTR_TIME_SET_CURRENT (endtime );
0 commit comments