Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][llvm] Remove support for llvm versions before 14.x. #88346

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,7 @@ if(LLVM_PREFIX)

# llvm-config --libs analysis core bitwriter mcjit orcjit
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")
if(${llvm_api_version} LESS 1200)
set(MONO_llvm_core_libs ${MONO_llvm_core_libs} "LLVMOrcError" "LLVMDebugInfoMSF")
elseif(${llvm_api_version} LESS 1600)
if(${llvm_api_version} LESS 1600)
set(MONO_llvm_core_libs ${MONO_llvm_core_libs} "LLVMObjCARCOpts" "LLVMMCDisassembler" "LLVMOrcTargetProcess" "LLVMOrcShared" "LLVMDebugInfoDWARF")
else()
set(MONO_llvm_core_libs ${MONO_llvm_core_libs} "LLVMIRPrinter" "LLVMCodeGen" "LLVMObjCARCOpts" "LLVMMCDisassembler" "LLVMWindowsDriver" "LLVMOption" "LLVMOrcTargetProcess" "LLVMOrcShared" "LLVMSymbolize" "LLVMDebugInfoPDB" "LLVMDebugInfoMSF" "LLVMDebugInfoDWARF" "LLVMTargetParser")
Expand Down
6 changes: 2 additions & 4 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -10762,7 +10762,7 @@ emit_llvm_file (MonoAotCompile *acfg)
if (acfg->aot_opts.no_opt)
return TRUE;

#if (defined(TARGET_X86) || defined(TARGET_AMD64)) && LLVM_API_VERSION >= 1400
#if (defined(TARGET_X86) || defined(TARGET_AMD64))
if (acfg->aot_opts.llvm_cpu_attr && strstr (acfg->aot_opts.llvm_cpu_attr, "sse4.2"))
/*
* LLVM 14 added a 'crc32' mattr which needs to be explicitly enabled to
Expand Down Expand Up @@ -10808,11 +10808,9 @@ emit_llvm_file (MonoAotCompile *acfg)
opts = g_strdup_printf ("%sdefault<O2>,", opts);
}
opts = g_strdup_printf ("%splace-safepoints\" -spp-all-backedges", opts);
#elif LLVM_API_VERSION >= 1300
#else
/* The safepoints pass requires the old pass manager */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we upstream a port of the safe point pass to the new pass manager? I think @jandupej did it, right? Did that make it into 16.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the pre 16.x case, the 16.x case is handled above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lambdageek Yes, that pass should be available in 16.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we upgrade this to use the new pass manager and remove the comment?

opts = g_strdup ("-disable-tail-calls -place-safepoints -spp-all-backedges -enable-new-pm=0");
#else
opts = g_strdup ("-disable-tail-calls -place-safepoints -spp-all-backedges");
#endif
}

Expand Down
10 changes: 0 additions & 10 deletions src/mono/mono/mini/llvm-intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ INTRINS_OVR_TAG(SIMD_TRUNC, trunc, Generic, Scalar | V64 | V128 | R4 | R8)
INTRINS_OVR_TAG(SIMD_ROUND, round, Generic, Scalar | V64 | V128 | R4 | R8)
INTRINS_OVR_TAG(SIMD_NEAREST, nearbyint, Generic, V64 | V128 | R4 | R8)
INTRINS(EH_TYPEID_FOR, eh_typeid_for, Generic)
#if LLVM_API_VERSION >= 1400
INTRINS_OVR_TAG(ROUNDEVEN, roundeven, Generic, Scalar | V64 | V128 | R4 | R8)
#endif

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

#if LLVM_API_VERSION < 1400
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_RBIT, aarch64_neon_rbit, Arm64, V64 | V128 | I1)
#endif

#if LLVM_API_VERSION < 1400
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_FRINTN, aarch64_neon_frintn, Arm64, Scalar | V64 | V128 | R4 | R8)
#endif

INTRINS_OVR_TAG(AARCH64_ADV_SIMD_SUQADD, aarch64_neon_suqadd, Arm64, Scalar | V64 | V128 | I1 | I2 | I4 | I8)
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_USQADD, aarch64_neon_usqadd, Arm64, Scalar | V64 | V128 | I1 | I2 | I4 | I8)
INTRINS_OVR_TAG(AARCH64_ADV_SIMD_UQADD, aarch64_neon_uqadd, Arm64, Scalar | V64 | V128 | I1 | I2 | I4 | I8)
Expand Down
42 changes: 0 additions & 42 deletions src/mono/mono/mini/mini-llvm-cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ mono_llvm_build_cmpxchg (LLVMBuilderRef builder, LLVMValueRef ptr, LLVMValueRef
{
AtomicCmpXchgInst *ins;

#if LLVM_API_VERSION >= 1300
ins = unwrap(builder)->CreateAtomicCmpXchg (unwrap(ptr), unwrap (cmp), unwrap (val), MaybeAlign (), SequentiallyConsistent, SequentiallyConsistent);
#else
ins = unwrap(builder)->CreateAtomicCmpXchg (unwrap(ptr), unwrap (cmp), unwrap (val), SequentiallyConsistent, SequentiallyConsistent);
#endif
return wrap (ins);
}

Expand Down Expand Up @@ -224,11 +220,7 @@ mono_llvm_build_atomic_rmw (LLVMBuilderRef builder, AtomicRMWOp op, LLVMValueRef
break;
}

#if LLVM_API_VERSION >= 1300
ins = unwrap (builder)->CreateAtomicRMW (aop, unwrap (ptr), unwrap (val), MaybeAlign (), SequentiallyConsistent);
#else
ins = unwrap (builder)->CreateAtomicRMW (aop, unwrap (ptr), unwrap (val), SequentiallyConsistent);
#endif
return wrap (ins);
}

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

#if LLVM_API_VERSION >= 1400
dyn_cast<CallBase>(calli)->addRetAttr (Kind);
#else
dyn_cast<CallBase>(calli)->addAttribute (AttributeList::ReturnIndex, Kind);
#endif
}

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

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

static Attribute::AttrKind
Expand Down Expand Up @@ -518,11 +502,7 @@ mono_llvm_add_param_attr_with_type (LLVMValueRef param, AttrKind kind, LLVMTypeR

switch (kind) {
case LLVM_ATTR_STRUCT_RET:
#if LLVM_API_VERSION >= 1400
func->addParamAttr (n, Attribute::getWithStructRetType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
#else
func->addParamAttr (n, convert_attr (kind));
#endif
break;
default:
g_assert_not_reached ();
Expand All @@ -540,17 +520,12 @@ mono_llvm_add_param_byval_attr (LLVMValueRef param, LLVMTypeRef type)
void
mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind)
{
#if LLVM_API_VERSION >= 1400
unwrap<CallBase> (val)->addParamAttr (index - 1, convert_attr (kind));
#else
unwrap<CallBase> (val)->addAttribute (index, convert_attr (kind));
#endif
}

void
mono_llvm_add_instr_attr_with_type (LLVMValueRef val, int index, AttrKind kind, LLVMTypeRef type)
{
#if LLVM_API_VERSION >= 1400
Attribute attr;

switch (kind) {
Expand All @@ -561,19 +536,12 @@ mono_llvm_add_instr_attr_with_type (LLVMValueRef val, int index, AttrKind kind,
default:
g_assert_not_reached ();
}
#else
unwrap<CallBase> (val)->addAttribute (index, convert_attr (kind));
#endif
}

void
mono_llvm_add_instr_byval_attr (LLVMValueRef val, int index, LLVMTypeRef type)
{
#if LLVM_API_VERSION >= 1400
unwrap<CallBase> (val)->addParamAttr (index - 1, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
#else
unwrap<CallBase> (val)->addAttribute (index, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
#endif
}

void*
Expand Down Expand Up @@ -797,27 +765,17 @@ mono_llvm_inline_asm (LLVMBuilderRef builder, LLVMTypeRef type,
{
const auto asmstr_len = strlen (asmstr);
const auto constraints_len = strlen (constraints);
#if LLVM_API_VERSION >= 1300
const auto asmval = LLVMGetInlineAsm (type,
const_cast<char *>(asmstr), asmstr_len,
const_cast<char *>(constraints), constraints_len,
(flags & LLVM_ASM_SIDE_EFFECT) != 0, (flags & LLVM_ASM_ALIGN_STACK) != 0,
LLVMInlineAsmDialectATT, TRUE);
#else
const auto asmval = LLVMGetInlineAsm (type,
const_cast<char *>(asmstr), asmstr_len,
const_cast<char *>(constraints), constraints_len,
(flags & LLVM_ASM_SIDE_EFFECT) != 0, (flags & LLVM_ASM_ALIGN_STACK) != 0,
LLVMInlineAsmDialectATT);
#endif
return LLVMBuildCall2 (builder, type, asmval, args, num_args, name);
}

#if LLVM_API_VERSION >= 1400
LLVMTypeRef
mono_llvm_get_ptr_type (void)
{
PointerType *t = PointerType::get (*unwrap (LLVMGetGlobalContext ()), 0);
return wrap (t);
}
#endif
10 changes: 1 addition & 9 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#define TARGET_WIN32_MSVC
#endif

#if LLVM_API_VERSION < 1100
#if LLVM_API_VERSION < 1400
#error "The version of the mono llvm repository is too old."
#endif

Expand Down Expand Up @@ -7866,11 +7866,7 @@ MONO_RESTORE_WARNING

indexes [0] = const_int32 (0);
indexes [1] = const_int32 (0);
#if LLVM_API_VERSION >= 1400
LLVMSetInitializer (ref_var, LLVMConstGEP2 (name_var_type, name_var, indexes, 2));
#else
LLVMSetInitializer (ref_var, LLVMConstGEP (name_var, indexes, 2));
#endif
LLVMSetLinkage (ref_var, LLVMPrivateLinkage);
LLVMSetExternallyInitialized (ref_var, TRUE);
LLVMSetSection (ref_var, "__DATA, __objc_selrefs, literal_pointers, no_dead_strip");
Expand Down Expand Up @@ -13505,11 +13501,7 @@ add_types (MonoLLVMModule *module)
void
mono_llvm_init (gboolean enable_jit)
{
#if LLVM_API_VERSION >= 1400
ptr_t = mono_llvm_get_ptr_type ();
#else
ptr_t = NULL;
#endif

intrin_types [0][0] = i1_t = LLVMInt8Type ();
intrin_types [0][1] = i2_t = LLVMInt16Type ();
Expand Down
9 changes: 0 additions & 9 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -3737,20 +3737,11 @@ static SimdIntrinsic advsimd_methods [] = {
{SN_ReverseElement16, OP_ARM64_REVN, 16},
{SN_ReverseElement32, OP_ARM64_REVN, 32},
{SN_ReverseElement8, OP_ARM64_REVN, 8},
#if LLVM_API_VERSION >= 1400
{SN_ReverseElementBits, OP_XOP_OVR_X_X, INTRINS_BITREVERSE},
#else
{SN_ReverseElementBits, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_RBIT},
#endif
{SN_RoundAwayFromZero, OP_XOP_OVR_X_X, INTRINS_SIMD_ROUND},
{SN_RoundAwayFromZeroScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_SIMD_ROUND},
#if LLVM_API_VERSION >= 1400
{SN_RoundToNearest, OP_XOP_OVR_X_X, INTRINS_ROUNDEVEN},
{SN_RoundToNearestScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_ROUNDEVEN},
#else
{SN_RoundToNearest, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_FRINTN},
{SN_RoundToNearestScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_AARCH64_ADV_SIMD_FRINTN},
#endif
{SN_RoundToNegativeInfinity, OP_XOP_OVR_X_X, INTRINS_SIMD_FLOOR},
{SN_RoundToNegativeInfinityScalar, OP_XOP_OVR_SCALAR_X_X, INTRINS_SIMD_FLOOR},
{SN_RoundToPositiveInfinity, OP_XOP_OVR_X_X, INTRINS_SIMD_CEIL},
Expand Down