[PATCH] D83122: Fix crash when getVFABIMappings is called with an indirect call instruction

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 07:30:08 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e58004fe187: Fix crash when getVFABIMappings is called with an indirect call instruction (authored by sanwou01).

Changed prior to commit:
  https://reviews.llvm.org/D83122?vs=275338&id=277424#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83122/new/

https://reviews.llvm.org/D83122

Files:
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/unittests/Analysis/VectorFunctionABITest.cpp


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83122.277424.patch
Type: text/x-patch
Size: 1631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200713/9101d567/attachment.bin>


More information about the llvm-commits mailing list