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

Maciej Gabka via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 05:16:34 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;
----------------
mgabka wrote:

do you need this variable, I think it is safer to use  VFParam.ParamPos, as that is what holds the argument position in function declaration.

Moreover, I think that nothing in the API guarantees that the Shape.Parameters keeps the parameters in the same order as OrigArgTypes, this is why you need to use VFParam.ParamPos to make sure that this is the right, matching operand pair.
With OrigArgTypes it is different story, as you are creating it yourself here.

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


More information about the llvm-commits mailing list