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.
This commit is contained in:
Anna Thomas 2020-05-13 11:45:39 -04:00
parent 064e9907ba
commit 0ab3ba230e
1 changed files with 8 additions and 6 deletions

View File

@ -180,7 +180,10 @@ VFParamKind getVFParamKindFromString(const StringRef Token);
static constexpr char const *MappingsAttrName = "vector-function-abi-variant";
/// Populates a set of strings representing the Vector Function ABI variants
/// associated to the CallInst CI.
/// associated to the CallInst CI. If the CI does not contain the
/// vector-function-abi-variant attribute, we return without populating
/// VariantMappings, i.e. callers of getVectorVariantNames need not check for
/// the presence of the attribute (see InjectTLIMappings).
void getVectorVariantNames(const CallInst &CI,
SmallVectorImpl<std::string> &VariantMappings);
} // end namespace VFABI
@ -203,14 +206,13 @@ class VFDatabase {
static void getVFABIMappings(const CallInst &CI,
SmallVectorImpl<VFInfo> &Mappings) {
const StringRef ScalarName = CI.getCalledFunction()->getName();
const StringRef S =
CI.getAttribute(AttributeList::FunctionIndex, VFABI::MappingsAttrName)
.getValueAsString();
if (S.empty())
return;
SmallVector<std::string, 8> ListOfStrings;
// The check for the vector-function-abi-variant attribute is done when
// retrieving the vector variant names here.
VFABI::getVectorVariantNames(CI, ListOfStrings);
if (ListOfStrings.empty())
return;
for (const auto &MangledName : ListOfStrings) {
const Optional<VFInfo> Shape =
VFABI::tryDemangleForVFABI(MangledName, *(CI.getModule()));