Skip to content

Commit e6d7ae7

Browse files
authored
[mono][llvm] Remove support for llvm versions before 14.x. (#88346)
1 parent 1be2db9 commit e6d7ae7

File tree

6 files changed

+4
-77
lines changed

6 files changed

+4
-77
lines changed

src/mono/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,7 @@ if(LLVM_PREFIX)
599599

600600
# llvm-config --libs analysis core bitwriter mcjit orcjit
601601
set(MONO_llvm_core_libs "LLVMOrcJIT" "LLVMPasses" "LLVMCoroutines" "LLVMipo" "LLVMInstrumentation" "LLVMVectorize" "LLVMScalarOpts" "LLVMLinker" "LLVMIRReader" "LLVMAsmParser" "LLVMInstCombine" "LLVMFrontendOpenMP" "LLVMAggressiveInstCombine" "LLVMTransformUtils" "LLVMJITLink" "LLVMMCJIT" "LLVMExecutionEngine" "LLVMTarget" "LLVMRuntimeDyld" "LLVMBitWriter" "LLVMAnalysis" "LLVMProfileData" "LLVMObject" "LLVMTextAPI" "LLVMMCParser" "LLVMMC" "LLVMDebugInfoCodeView" "LLVMBitReader" "LLVMCore" "LLVMRemarks" "LLVMBitstreamReader" "LLVMBinaryFormat" "LLVMSupport" "LLVMDemangle")
602-
if(${llvm_api_version} LESS 1200)
603-
set(MONO_llvm_core_libs ${MONO_llvm_core_libs} "LLVMOrcError" "LLVMDebugInfoMSF")
604-
elseif(${llvm_api_version} LESS 1600)
602+
if(${llvm_api_version} LESS 1600)
605603
set(MONO_llvm_core_libs ${MONO_llvm_core_libs} "LLVMObjCARCOpts" "LLVMMCDisassembler" "LLVMOrcTargetProcess" "LLVMOrcShared" "LLVMDebugInfoDWARF")
606604
else()
607605
set(MONO_llvm_core_libs ${MONO_llvm_core_libs} "LLVMIRPrinter" "LLVMCodeGen" "LLVMObjCARCOpts" "LLVMMCDisassembler" "LLVMWindowsDriver" "LLVMOption" "LLVMOrcTargetProcess" "LLVMOrcShared" "LLVMSymbolize" "LLVMDebugInfoPDB" "LLVMDebugInfoMSF" "LLVMDebugInfoDWARF" "LLVMTargetParser")

src/mono/mono/mini/aot-compiler.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10762,7 +10762,7 @@ emit_llvm_file (MonoAotCompile *acfg)
1076210762
if (acfg->aot_opts.no_opt)
1076310763
return TRUE;
1076410764

10765-
#if (defined(TARGET_X86) || defined(TARGET_AMD64)) && LLVM_API_VERSION >= 1400
10765+
#if (defined(TARGET_X86) || defined(TARGET_AMD64))
1076610766
if (acfg->aot_opts.llvm_cpu_attr && strstr (acfg->aot_opts.llvm_cpu_attr, "sse4.2"))
1076710767
/*
1076810768
* LLVM 14 added a 'crc32' mattr which needs to be explicitly enabled to
@@ -10808,11 +10808,9 @@ emit_llvm_file (MonoAotCompile *acfg)
1080810808
opts = g_strdup_printf ("%sdefault<O2>,", opts);
1080910809
}
1081010810
opts = g_strdup_printf ("%splace-safepoints\" -spp-all-backedges", opts);
10811-
#elif LLVM_API_VERSION >= 1300
10811+
#else
1081210812
/* The safepoints pass requires the old pass manager */
1081310813
opts = g_strdup ("-disable-tail-calls -place-safepoints -spp-all-backedges -enable-new-pm=0");
10814-
#else
10815-
opts = g_strdup ("-disable-tail-calls -place-safepoints -spp-all-backedges");
1081610814
#endif
1081710815
}
1081810816

src/mono/mono/mini/llvm-intrinsics.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ INTRINS_OVR_TAG(SIMD_TRUNC, trunc, Generic, Scalar | V64 | V128 | R4 | R8)
108108
INTRINS_OVR_TAG(SIMD_ROUND, round, Generic, Scalar | V64 | V128 | R4 | R8)
109109
INTRINS_OVR_TAG(SIMD_NEAREST, nearbyint, Generic, V64 | V128 | R4 | R8)
110110
INTRINS(EH_TYPEID_FOR, eh_typeid_for, Generic)
111-
#if LLVM_API_VERSION >= 1400
112111
INTRINS_OVR_TAG(ROUNDEVEN, roundeven, Generic, Scalar | V64 | V128 | R4 | R8)
113-
#endif
114112

115113
#if defined(TARGET_AMD64) || defined(TARGET_X86)
116114
INTRINS(SSE_PMOVMSKB, x86_sse2_pmovmskb_128, X86)
@@ -447,14 +445,6 @@ INTRINS_OVR_TAG(AARCH64_ADV_SIMD_FRSQRTE, aarch64_neon_frsqrte, Arm64, Scalar |
447445
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_FRSQRTS, aarch64_neon_frsqrts, Arm64, Scalar | V64 | V128 | R4 | R8)
448446
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_FRECPS, aarch64_neon_frecps, Arm64, Scalar | V64 | V128 | R4 | R8)
449447

450-
#if LLVM_API_VERSION < 1400
451-
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_RBIT, aarch64_neon_rbit, Arm64, V64 | V128 | I1)
452-
#endif
453-
454-
#if LLVM_API_VERSION < 1400
455-
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_FRINTN, aarch64_neon_frintn, Arm64, Scalar | V64 | V128 | R4 | R8)
456-
#endif
457-
458448
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_SUQADD, aarch64_neon_suqadd, Arm64, Scalar | V64 | V128 | I1 | I2 | I4 | I8)
459449
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_USQADD, aarch64_neon_usqadd, Arm64, Scalar | V64 | V128 | I1 | I2 | I4 | I8)
460450
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_UQADD, aarch64_neon_uqadd, Arm64, Scalar | V64 | V128 | I1 | I2 | I4 | I8)

src/mono/mono/mini/mini-llvm-cpp.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,7 @@ mono_llvm_build_cmpxchg (LLVMBuilderRef builder, LLVMValueRef ptr, LLVMValueRef
192192
{
193193
AtomicCmpXchgInst *ins;
194194

195-
#if LLVM_API_VERSION >= 1300
196195
ins = unwrap(builder)->CreateAtomicCmpXchg (unwrap(ptr), unwrap (cmp), unwrap (val), MaybeAlign (), SequentiallyConsistent, SequentiallyConsistent);
197-
#else
198-
ins = unwrap(builder)->CreateAtomicCmpXchg (unwrap(ptr), unwrap (cmp), unwrap (val), SequentiallyConsistent, SequentiallyConsistent);
199-
#endif
200196
return wrap (ins);
201197
}
202198

@@ -224,11 +220,7 @@ mono_llvm_build_atomic_rmw (LLVMBuilderRef builder, AtomicRMWOp op, LLVMValueRef
224220
break;
225221
}
226222

227-
#if LLVM_API_VERSION >= 1300
228223
ins = unwrap (builder)->CreateAtomicRMW (aop, unwrap (ptr), unwrap (val), MaybeAlign (), SequentiallyConsistent);
229-
#else
230-
ins = unwrap (builder)->CreateAtomicRMW (aop, unwrap (ptr), unwrap (val), SequentiallyConsistent);
231-
#endif
232224
return wrap (ins);
233225
}
234226

@@ -338,11 +330,7 @@ add_ret_attr (LLVMValueRef wrapped_calli, Attribute::AttrKind Kind)
338330
{
339331
Instruction *calli = unwrap<Instruction> (wrapped_calli);
340332

341-
#if LLVM_API_VERSION >= 1400
342333
dyn_cast<CallBase>(calli)->addRetAttr (Kind);
343-
#else
344-
dyn_cast<CallBase>(calli)->addAttribute (AttributeList::ReturnIndex, Kind);
345-
#endif
346334
}
347335

348336
void
@@ -455,11 +443,7 @@ mono_llvm_set_alignment_ret (LLVMValueRef call, int alignment)
455443
Instruction *ins = unwrap<Instruction> (call);
456444
auto &ctx = ins->getContext ();
457445

458-
#if LLVM_API_VERSION >= 1400
459446
dyn_cast<CallBase>(ins)->addRetAttr (Attribute::getWithAlignment(ctx, to_align (alignment)));
460-
#else
461-
dyn_cast<CallBase>(ins)->addAttribute (AttributeList::ReturnIndex, Attribute::getWithAlignment(ctx, to_align (alignment)));
462-
#endif
463447
}
464448

465449
static Attribute::AttrKind
@@ -518,11 +502,7 @@ mono_llvm_add_param_attr_with_type (LLVMValueRef param, AttrKind kind, LLVMTypeR
518502

519503
switch (kind) {
520504
case LLVM_ATTR_STRUCT_RET:
521-
#if LLVM_API_VERSION >= 1400
522505
func->addParamAttr (n, Attribute::getWithStructRetType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
523-
#else
524-
func->addParamAttr (n, convert_attr (kind));
525-
#endif
526506
break;
527507
default:
528508
g_assert_not_reached ();
@@ -540,17 +520,12 @@ mono_llvm_add_param_byval_attr (LLVMValueRef param, LLVMTypeRef type)
540520
void
541521
mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind)
542522
{
543-
#if LLVM_API_VERSION >= 1400
544523
unwrap<CallBase> (val)->addParamAttr (index - 1, convert_attr (kind));
545-
#else
546-
unwrap<CallBase> (val)->addAttribute (index, convert_attr (kind));
547-
#endif
548524
}
549525

550526
void
551527
mono_llvm_add_instr_attr_with_type (LLVMValueRef val, int index, AttrKind kind, LLVMTypeRef type)
552528
{
553-
#if LLVM_API_VERSION >= 1400
554529
Attribute attr;
555530

556531
switch (kind) {
@@ -561,19 +536,12 @@ mono_llvm_add_instr_attr_with_type (LLVMValueRef val, int index, AttrKind kind,
561536
default:
562537
g_assert_not_reached ();
563538
}
564-
#else
565-
unwrap<CallBase> (val)->addAttribute (index, convert_attr (kind));
566-
#endif
567539
}
568540

569541
void
570542
mono_llvm_add_instr_byval_attr (LLVMValueRef val, int index, LLVMTypeRef type)
571543
{
572-
#if LLVM_API_VERSION >= 1400
573544
unwrap<CallBase> (val)->addParamAttr (index - 1, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
574-
#else
575-
unwrap<CallBase> (val)->addAttribute (index, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
576-
#endif
577545
}
578546

579547
void*
@@ -797,27 +765,17 @@ mono_llvm_inline_asm (LLVMBuilderRef builder, LLVMTypeRef type,
797765
{
798766
const auto asmstr_len = strlen (asmstr);
799767
const auto constraints_len = strlen (constraints);
800-
#if LLVM_API_VERSION >= 1300
801768
const auto asmval = LLVMGetInlineAsm (type,
802769
const_cast<char *>(asmstr), asmstr_len,
803770
const_cast<char *>(constraints), constraints_len,
804771
(flags & LLVM_ASM_SIDE_EFFECT) != 0, (flags & LLVM_ASM_ALIGN_STACK) != 0,
805772
LLVMInlineAsmDialectATT, TRUE);
806-
#else
807-
const auto asmval = LLVMGetInlineAsm (type,
808-
const_cast<char *>(asmstr), asmstr_len,
809-
const_cast<char *>(constraints), constraints_len,
810-
(flags & LLVM_ASM_SIDE_EFFECT) != 0, (flags & LLVM_ASM_ALIGN_STACK) != 0,
811-
LLVMInlineAsmDialectATT);
812-
#endif
813773
return LLVMBuildCall2 (builder, type, asmval, args, num_args, name);
814774
}
815775

816-
#if LLVM_API_VERSION >= 1400
817776
LLVMTypeRef
818777
mono_llvm_get_ptr_type (void)
819778
{
820779
PointerType *t = PointerType::get (*unwrap (LLVMGetGlobalContext ()), 0);
821780
return wrap (t);
822781
}
823-
#endif

src/mono/mono/mini/mini-llvm.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#define TARGET_WIN32_MSVC
5050
#endif
5151

52-
#if LLVM_API_VERSION < 1100
52+
#if LLVM_API_VERSION < 1400
5353
#error "The version of the mono llvm repository is too old."
5454
#endif
5555

@@ -7866,11 +7866,7 @@ MONO_RESTORE_WARNING
78667866

78677867
indexes [0] = const_int32 (0);
78687868
indexes [1] = const_int32 (0);
7869-
#if LLVM_API_VERSION >= 1400
78707869
LLVMSetInitializer (ref_var, LLVMConstGEP2 (name_var_type, name_var, indexes, 2));
7871-
#else
7872-
LLVMSetInitializer (ref_var, LLVMConstGEP (name_var, indexes, 2));
7873-
#endif
78747870
LLVMSetLinkage (ref_var, LLVMPrivateLinkage);
78757871
LLVMSetExternallyInitialized (ref_var, TRUE);
78767872
LLVMSetSection (ref_var, "__DATA, __objc_selrefs, literal_pointers, no_dead_strip");
@@ -13505,11 +13501,7 @@ add_types (MonoLLVMModule *module)
1350513501
void
1350613502
mono_llvm_init (gboolean enable_jit)
1350713503
{
13508-
#if LLVM_API_VERSION >= 1400
1350913504
ptr_t = mono_llvm_get_ptr_type ();
13510-
#else
13511-
ptr_t = NULL;
13512-
#endif
1351313505

1351413506
intrin_types [0][0] = i1_t = LLVMInt8Type ();
1351513507
intrin_types [0][1] = i2_t = LLVMInt16Type ();

src/mono/mono/mini/simd-intrinsics.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,20 +3737,11 @@ static SimdIntrinsic advsimd_methods [] = {
37373737
{SN_ReverseElement16, OP_ARM64_REVN, 16},
37383738
{SN_ReverseElement32, OP_ARM64_REVN, 32},
37393739
{SN_ReverseElement8, OP_ARM64_REVN, 8},
3740-
#if LLVM_API_VERSION >= 1400
37413740
{SN_ReverseElementBits, OP_XOP_OVR_X_X, INTRINS_BITREVERSE},
3742-
#else
3743-
{SN_ReverseElementBits, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_RBIT},
3744-
#endif
37453741
{SN_RoundAwayFromZero, OP_XOP_OVR_X_X, INTRINS_SIMD_ROUND},
37463742
{SN_RoundAwayFromZeroScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_SIMD_ROUND},
3747-
#if LLVM_API_VERSION >= 1400
37483743
{SN_RoundToNearest, OP_XOP_OVR_X_X, INTRINS_ROUNDEVEN},
37493744
{SN_RoundToNearestScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_ROUNDEVEN},
3750-
#else
3751-
{SN_RoundToNearest, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_FRINTN},
3752-
{SN_RoundToNearestScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_AARCH64_ADV_SIMD_FRINTN},
3753-
#endif
37543745
{SN_RoundToNegativeInfinity, OP_XOP_OVR_X_X, INTRINS_SIMD_FLOOR},
37553746
{SN_RoundToNegativeInfinityScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_SIMD_FLOOR},
37563747
{SN_RoundToPositiveInfinity, OP_XOP_OVR_X_X, INTRINS_SIMD_CEIL},

0 commit comments

Comments
 (0)