VectorType inherits getNumElements from SequentialType. For a fixed
length vector, this returns the number of vector lanes. Previously, for
scalable vectors, this has returned the n for <vscale x n x ty>.
VectorType has another function getElementCount that returns a pair of
(bool, uint64_t) where the bool is true if the vector is scalable, and
min is the same as the return value of getNumElements. This form is
preferred because it provides the caller a way of knowing if the vector
is scalable.
There exists a large amount of code that calls getNumElements and
iterates over the returned value. This code is correct for fixed length
vectors, but is always a bug for scalable vectors since the number of
vector lanes in a scalable vector is unknown at compile time. To
mitigate bugs that are caused by this situation, we are changing the
behavior of getNumElements to assert that if the SequentialType instance
is a vector, that the vector is not scalable. This should be a minimally
intrusive change since very little code has been written that uses
getNumElements correctly.
clang-format: please reformat the code