In https://reviews.llvm.org/D151611, a check was added to the tensor verifier to
emit an error on negative tensor dimensions. This check allowed for dynamic
dimensions, hence negative dimensions were still able to get through the verifier.
This is a problem in situations such as #60558, where the dynamic dimension is
converted to a static (and possibly negative) dimension by another pass in the
compiler. This patch fixes that by doing another check during the
StaticTensorGenerate conversion, and return a failure if the dimension is
negative.
As a side-note, I have to admit that I do not know why returning a failure in
StaticTensorGenerate gives a nice "tensor dimensions must be non-negative"
error. I suspect that the verifier runs again when return failure() is called,
but I am not sure.
Fixes #60558.