diff --git a/llvm/include/llvm/Analysis/VectorUtils.h b/llvm/include/llvm/Analysis/VectorUtils.h --- a/llvm/include/llvm/Analysis/VectorUtils.h +++ b/llvm/include/llvm/Analysis/VectorUtils.h @@ -224,6 +224,9 @@ /// a vector Function ABI. static void getVFABIMappings(const CallInst &CI, SmallVectorImpl &Mappings) { + if (CI.isIndirectCall()) + return; + const StringRef ScalarName = CI.getCalledFunction()->getName(); SmallVector ListOfStrings; diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp --- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp +++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp @@ -618,3 +618,29 @@ EXPECT_FALSE(invokeParser("_ZGVsM0v_sin")); EXPECT_FALSE(invokeParser("_ZGVsN0v_sin")); } + +static std::unique_ptr parseIR(LLVMContext &C, const char *IR) { + SMDiagnostic Err; + std::unique_ptr Mod = parseAssemblyString(IR, Err, C); + if (!Mod) + Err.print("VectorFunctionABITests", errs()); + return Mod; +} + +TEST(VFABIGetMappingsTest, IndirectCallInst) { + LLVMContext C; + std::unique_ptr M = parseIR(C, R"IR( +define void @call(void () * %f) { +entry: + call void %f() + ret void +} +)IR"); + auto F = dyn_cast_or_null(M->getNamedValue("call")); + ASSERT_TRUE(F); + auto CI = dyn_cast(&F->front().front()); + ASSERT_TRUE(CI); + ASSERT_TRUE(CI->isIndirectCall()); + auto Mappings = VFDatabase::getMappings(*CI); + EXPECT_EQ(Mappings.size(), (unsigned)0); +}