[llvm] [TLI] Fix replace-with-veclib crash with invalid arguments (PR #77112)

Paschalis Mpeis via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 01:39:38 PST 2024


================
@@ -174,6 +176,24 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
 
   Function *TLIFunc = getTLIFunction(I.getModule(), VectorFTy,
                                      VD->getVectorFnName(), FuncToReplace);
+
+  // For calls, bail out when their arguments do not match with the TLI mapping.
+  if (CI) {
+    int IdxNonPred = 0;
+    for (auto [OrigTy, VFParam] :
+         zip(OrigArgTypes, OptInfo->Shape.Parameters)) {
+      if (VFParam.ParamKind == VFParamKind::GlobalPredicate)
----------------
paschalis-mpeis wrote:

True, but I was trying to keep it location (and num of occurrences) agnostic where I can.
Something similar was originally suggested to me during the review of [createFunctionType](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/VectorUtils.cpp#L1490).

https://github.com/llvm/llvm-project/pull/77112


More information about the llvm-commits mailing list