Handle the unexpected inputs for pass HardwareLoops
authorWang, Xin10 <xin10.wang@intel.com>
Thu, 30 Mar 2023 02:33:57 +0000 (10:33 +0800)
committerWang, Xin10 <xin10.wang@intel.com>
Thu, 30 Mar 2023 02:42:19 +0000 (10:42 +0800)
commit0bf75d85419e87d3cb0352f7ebc8ef252869e9f6
treeb7d0be42ad950439ff341902eb66cfc3b0e651d4
parentc5c6781428a70d1fffd00a256a237cbf5a3ccfd3
Handle the unexpected inputs for pass HardwareLoops

For a function TryConvertLoop in pass HardwareLoops, wrong input arguments will
lead to crash. There will be 3 cases.
In line 342, compiler want to get something from
HWLoopInfo.CountType, which depends on if argument Bitwidth is given, if not,
will crash.
In Function isHardwareLoopCandidate, it dereference CountType too.
In Function InsertLoopDec, it dereference LoopDecrement.
They all could lead to crash. This patch add condition to this pass, when we meet unexpected inputs then skip
the pass.

Reviewed By: samparker, fhahn

Differential Revision: https://reviews.llvm.org/D146277
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/test/Transforms/HardwareLoops/unexpected-inputs.ll [new file with mode: 0644]