[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:42:04 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;
----------------
paschalis-mpeis 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.

Agreed, will remove variable and adjust.

> .. nothing in the API guarantees that the Shape.Parameters keeps the parameters in the same order as OrigArgTypes,  ..

Is the suggestion here to loop over`Shape.Parameters`, and use `VFParam.ParamPos` to retrieve the relevant `OrigArgTypes` ?


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


More information about the llvm-commits mailing list