From 9901314ff75dd0bf651b23d09c1d1f5f07d49ffd Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 19 Apr 2022 10:37:48 -0700 Subject: [PATCH] ARM vst mangling needs to be conditional on opaque ptrs The fixes from last week regarding mangling of arm vst intrinsics needs to be made conditional on whether the pointer is opaque or not; this will change based on whether `-D CLANG_ENABLE_OPAQUE_POINTERS=ON|OFF` is defined when LLVM is built, but should be sniffed via this API, according to my LLVM contact. --- src/CodeGen_ARM.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/CodeGen_ARM.cpp b/src/CodeGen_ARM.cpp index 29dd116f6920..25fddc417256 100644 --- a/src/CodeGen_ARM.cpp +++ b/src/CodeGen_ARM.cpp @@ -999,16 +999,21 @@ void CodeGen_ARM::visit(const Store *op) { // Declare the function std::ostringstream instr; vector arg_types; + llvm::Type *intrin_llvm_type = llvm_type_of(intrin_type); +#if LLVM_VERSION >= 150 + const bool is_opaque = llvm::PointerType::get(intrin_llvm_type, 0)->isOpaque(); +#else + const bool is_opaque = false; +#endif if (target.bits == 32) { - const char *type_annotation = (LLVM_VERSION < 150) ? ".p0i8" : ".p0"; instr << "llvm.arm.neon.vst" << num_vecs - << type_annotation + << (is_opaque ? ".p0" : ".p0i8") << ".v" << intrin_type.lanes() << (t.is_float() ? 'f' : 'i') << t.bits(); - arg_types = vector(num_vecs + 2, llvm_type_of(intrin_type)); + arg_types = vector(num_vecs + 2, intrin_llvm_type); arg_types.front() = i8_t->getPointerTo(); arg_types.back() = i32_t; } else { @@ -1019,11 +1024,10 @@ void CodeGen_ARM::visit(const Store *op) { << (t.is_float() ? 'f' : 'i') << t.bits() << ".p0"; - if (LLVM_VERSION < 150) { - instr << (t.is_float() ? 'f' : 'i') - << t.bits(); + if (!is_opaque) { + instr << (t.is_float() ? 'f' : 'i') << t.bits(); } - arg_types = vector(num_vecs + 1, llvm_type_of(intrin_type)); + arg_types = vector(num_vecs + 1, intrin_llvm_type); arg_types.back() = llvm_type_of(intrin_type.element_of())->getPointerTo(); } llvm::FunctionType *fn_type = FunctionType::get(llvm::Type::getVoidTy(*context), arg_types, false);