[SCCP] Use ValueLatticeElement instead of LatticeVal (NFCI)
authorFlorian Hahn <flo@fhahn.com>
Thu, 12 Mar 2020 11:26:07 +0000 (11:26 +0000)
committerFlorian Hahn <flo@fhahn.com>
Thu, 12 Mar 2020 12:03:06 +0000 (12:03 +0000)
commitf1ac5d2263f8419b865cc78ba1f5c8694970fb6b
treeefab8684e8a331b99b72734e50c0427f83f1f0b4
parentf31f22ef0f091bf8125a3d7f9d9db7fdbba6c18d
[SCCP] Use ValueLatticeElement instead of LatticeVal (NFCI)

This patch switches SCCP to use ValueLatticeElement for lattice values,
instead of the local LatticeVal, as first step to enable integer range support.

This patch does not make use of constant ranges for additional operations
and the only difference for now is that integer constants are represented by
single element ranges. To preserve the existing behavior, the following helpers
are used

* isConstant(LV): returns true when LV is either a constant or a constant range with a single element. This should return true in the same cases where LV.isConstant() returned true previously.
* getConstant(LV): returns a constant if LV is either a constant or a constant range with a single element. This should return a constant in the same cases as LV.getConstant() previously.
* getConstantInt(LV): same as getConstant, but additionally casted to ConstantInt.

Reviewers: davide, efriedma, mssimpso

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D60582
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/SCCP/ip-constant-ranges.ll
llvm/test/Transforms/SCCP/resolvedundefsin-tracked-fn.ll