[test-suite] Use forward-parsing when searching for numbers.

Authored by Meinersbur on Mar 31 2021, 8:51 AM.


[test-suite] Use forward-parsing when searching for numbers.

Avoid trying to backtrack from a character change to the beginning of a floating point comparison in order to parse it. This a unnecessarily error-prone and has other problems such as those fixed in D36768. This patch replaces this by search for the beginning of any number, then always scanning forward to find the end of the number like a parser does.

This patch in particular fixes a problem when comparing the program output of 628.pop2 from to the reference output from SPEC2017. The relevant excepts from the outputs are:

65.000 (program output)
65.0 5 (reference output)

The first character difference is between 0 (program output) and (whitespace from reference). For the program output, the backtrack solution rewinds to 65.000. With the reference output, it has already advanced to 5 (due to the -i ignore whitespace flag; SPEC reference outputs have normalized whitespace). This case is explicitly handled without the -i flag, but backtracking through whitespace would make the algorithm even more complicated and there are other problems such as that it backs-up through any number of exponent characters (e, E, d, D).

Also fixes potential stack overflow when parsing numbers larger than 200 characters and allows identical values with different formatting (0 and 0.0) even with no absolute/relative tolerances defined.

Reviewed By: naromero77

Differential Revision: https://reviews.llvm.org/D99619