1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Fix crash when getVFABIMappings is called with an indirect call instruction

Differential Revision: https://reviews.llvm.org/D83122
This commit is contained in:
Sanne Wouda 2020-06-25 16:08:13 +01:00
parent cf9e8f01e5
commit 7ed97c8065
2 changed files with 29 additions and 0 deletions

View File

@ -224,6 +224,9 @@ class VFDatabase {
/// 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;

View File

@ -618,3 +618,29 @@ TEST_F(VFABIParserTest, ZeroIsInvalidVLEN) {
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);
}