[X86]add assert to confirm not-null ptr in getArithmeticReductionCost
authorWang, Xin10 <xin10.wang@intel.com>
Fri, 17 Mar 2023 06:16:58 +0000 (02:16 -0400)
committerxin10.wang <wangxin8@f90srv19.nh.intel.com>
Fri, 17 Mar 2023 06:17:49 +0000 (02:17 -0400)
commite3b4c1bc528bf6d6f8b52aa4e85779cc6fa32511
treebff8d9aae019ed2f612a55334ba060c28fab50cc
parentbf8f684efff34975b5f091f2cdcb81b52b53b79c
[X86]add assert to confirm not-null ptr in getArithmeticReductionCost

For the function getArithmeticReductionCost, it receive a ptr and dereferce it without check,
It is called many times in getTypeBasedIntrinsicInstrCost, the ptr passed to it is inited
from line 1709.

From the code, we can not ensure the ptr VecOpTy is inited when Tys is empty or Tys[VecTyIndex]
is not a VectorType, so that the getArithmeticReductionCost will do an undefined behavior.

I add assert to it, found the ptr passed to it in llvm tests are all not nullptr, but I think the check is
still meaningful for us.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D146118
llvm/include/llvm/CodeGen/BasicTTIImpl.h