34
34
#include <llvm-c/Transforms/IPO.h>
35
35
#include <llvm-c/Transforms/PassManagerBuilder.h>
36
36
#include <llvm-c/Transforms/Scalar.h>
37
- #if LLVM_VERSION_MAJOR > 6
38
37
#include <llvm-c/Transforms/Utils.h>
39
38
#endif
40
- #endif
41
39
42
40
#include "jit/llvmjit.h"
43
41
#include "jit/llvmjit_emit.h"
@@ -381,10 +379,7 @@ llvm_expand_funcname(struct LLVMJitContext *context, const char *basename)
381
379
void *
382
380
llvm_get_function (LLVMJitContext * context , const char * funcname )
383
381
{
384
- #if LLVM_VERSION_MAJOR > 11 || \
385
- defined(HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN ) && HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
386
382
ListCell * lc ;
387
- #endif
388
383
389
384
llvm_assert_in_fatal_section ();
390
385
@@ -432,7 +427,7 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
432
427
if (addr )
433
428
return (void * ) (uintptr_t ) addr ;
434
429
}
435
- #elif defined( HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN ) && HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
430
+ #else
436
431
foreach (lc , context -> handles )
437
432
{
438
433
LLVMOrcTargetAddress addr ;
@@ -444,28 +439,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
444
439
if (addr )
445
440
return (void * ) (uintptr_t ) addr ;
446
441
}
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
- }
469
442
#endif
470
443
471
444
elog (ERROR , "failed to JIT: %s" , funcname );
@@ -553,12 +526,8 @@ llvm_copy_attributes_at_index(LLVMValueRef v_from, LLVMValueRef v_to, uint32 ind
553
526
int num_attributes ;
554
527
LLVMAttributeRef * attrs ;
555
528
556
- num_attributes = LLVMGetAttributeCountAtIndexPG (v_from , index );
529
+ num_attributes = LLVMGetAttributeCountAtIndex (v_from , index );
557
530
558
- /*
559
- * Not just for efficiency: LLVM <= 3.9 crashes when
560
- * LLVMGetAttributesAtIndex() is called for an index with 0 attributes.
561
- */
562
531
if (num_attributes == 0 )
563
532
return ;
564
533
@@ -852,7 +821,7 @@ llvm_compile_module(LLVMJitContext *context)
852
821
853
822
/* LLVMOrcLLJITAddLLVMIRModuleWithRT takes ownership of the module */
854
823
}
855
- #elif LLVM_VERSION_MAJOR > 6
824
+ #else
856
825
{
857
826
handle -> stack = compile_orc ;
858
827
if (LLVMOrcAddEagerlyCompiledIR (compile_orc , & handle -> orc_handle , context -> module ,
@@ -861,26 +830,6 @@ llvm_compile_module(LLVMJitContext *context)
861
830
862
831
/* LLVMOrcAddEagerlyCompiledIR takes ownership of the module */
863
832
}
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
- }
884
833
#endif
885
834
886
835
INSTR_TIME_SET_CURRENT (endtime );
0 commit comments