[llvm] [TLI] Added a guard for empty vector function name. (PR #68100)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 06:25:45 PDT 2023


https://github.com/JolantaJensen created https://github.com/llvm/llvm-project/pull/68100

A guard for empty vector function name was removed in #66656. This patch adds the guard back.

>From feb323c60905492ae4708ac024ad717ef67b36db Mon Sep 17 00:00:00 2001
From: Jolanta Jensen <Jolanta.Jensen at arm.com>
Date: Tue, 3 Oct 2023 13:00:40 +0000
Subject: [PATCH] [TLI] Added a guard for empty vector function name.

A guard for empty vector function name was removed in #66656.
This patch adds the guard back.
---
 llvm/lib/Analysis/TargetLibraryInfo.cpp         | 1 +
 llvm/lib/Transforms/Utils/InjectTLIMappings.cpp | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 2b1c23710d00498..7b38583e9bc75f0 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -46,6 +46,7 @@ StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
 };
 
 std::string VecDesc::getVectorFunctionABIVariantString() const {
+  assert(!VectorFnName.empty() && "Vector function name must not be empty.");
   SmallString<256> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
   Out << VABIPrefix << "_" << ScalarFnName << "(" << VectorFnName << ")";
diff --git a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
index 04e67f713ac1167..0990c750af55f14 100644
--- a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -92,7 +92,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
 
   auto AddVariantDecl = [&](const ElementCount &VF, bool Predicate) {
     const VecDesc *VD = TLI.getVectorMappingInfo(ScalarName, VF, Predicate);
-    if (VD) {
+    if (VD && !VD->getVectorFnName().empty()) {
       std::string MangledName = VD->getVectorFunctionABIVariantString();
       if (!OriginalSetOfMappings.count(MangledName)) {
         Mappings.push_back(MangledName);



More information about the llvm-commits mailing list