Skip to content

Commit 0ab3ba2

Browse files
committed
NFC: Avoid redundant checks for vector-function-abi-variant attribute
Updated the comments on the code as well to reflect what the preconditions on VFABI::getVectorVariantNames are.
1 parent 064e990 commit 0ab3ba2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ VFParamKind getVFParamKindFromString(const StringRef Token);
180180
static constexpr char const *MappingsAttrName = "vector-function-abi-variant";
181181

182182
/// Populates a set of strings representing the Vector Function ABI variants
183-
/// associated to the CallInst CI.
183+
/// associated to the CallInst CI. If the CI does not contain the
184+
/// vector-function-abi-variant attribute, we return without populating
185+
/// VariantMappings, i.e. callers of getVectorVariantNames need not check for
186+
/// the presence of the attribute (see InjectTLIMappings).
184187
void getVectorVariantNames(const CallInst &CI,
185188
SmallVectorImpl<std::string> &VariantMappings);
186189
} // end namespace VFABI
@@ -203,14 +206,13 @@ class VFDatabase {
203206
static void getVFABIMappings(const CallInst &CI,
204207
SmallVectorImpl<VFInfo> &Mappings) {
205208
const StringRef ScalarName = CI.getCalledFunction()->getName();
206-
const StringRef S =
207-
CI.getAttribute(AttributeList::FunctionIndex, VFABI::MappingsAttrName)
208-
.getValueAsString();
209-
if (S.empty())
210-
return;
211209

212210
SmallVector<std::string, 8> ListOfStrings;
211+
// The check for the vector-function-abi-variant attribute is done when
212+
// retrieving the vector variant names here.
213213
VFABI::getVectorVariantNames(CI, ListOfStrings);
214+
if (ListOfStrings.empty())
215+
return;
214216
for (const auto &MangledName : ListOfStrings) {
215217
const Optional<VFInfo> Shape =
216218
VFABI::tryDemangleForVFABI(MangledName, *(CI.getModule()));

0 commit comments

Comments
 (0)