[llvm] [TLI] Fix replace-with-veclib crash with invalid arguments (PR #77112)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 10 03:46:08 PST 2024
================
@@ -168,12 +170,36 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
if (!OptInfo)
return false;
+ // There is no guarantee that the vectorized instructions followed the VFABI
+ // specification when being created, this is why we need to add extra check to
+ // make sure that the operands of the vector function obtained via VFABI match
+ // the operands of the original vector instruction.
+ if (CI) {
+ for (auto VFParam : OptInfo->Shape.Parameters) {
+ if (VFParam.ParamKind == VFParamKind::GlobalPredicate)
+ continue;
+
+ // tryDemangleForVFABI must return valid ParamPos, otherwise it could be
+ // a bug in the VFABI parser.
+ assert(VFParam.ParamPos < OrigArgTypes.size() &&
+ "ParamPos has invalid range.");
+ Type *OrigTy = OrigArgTypes[VFParam.ParamPos];
----------------
labrinea wrote:
Do we need the SmallVector containing the argument types? Can we not simply do
```CI->getArgOperand(VFParam.ParamPos)->getType()``` here?
https://github.com/llvm/llvm-project/pull/77112
More information about the llvm-commits
mailing list