This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by Meinersbur on Mar 30 2021, 1:47 PM.

Details

Summary

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.

Diff Detail

Repository
rT test-suite

Event Timeline

Meinersbur requested review of this revision.Mar 30 2021, 1:47 PM
Meinersbur created this revision.
Meinersbur edited the summary of this revision. (Show Details)Mar 30 2021, 1:54 PM
Meinersbur edited the summary of this revision. (Show Details)Mar 30 2021, 1:59 PM

Ran the entire test suite with GCC 10.2.0. For the record, there was one failure:

********************
Failing Tests (1):
    test-suite :: MultiSource/Benchmarks/Trimaran/enc-pc1/enc-pc1.test
  Expected Passes    : 254
  Unexpected Failures: 1

But after investigation, there was not related to this patch. The results from GCC are incorrect.

naromero77 accepted this revision.Mar 30 2021, 2:36 PM
This revision is now accepted and ready to land.Mar 30 2021, 2:36 PM

Confirming that all tests are passing with clang/clang++.

  • Fix copy&paste File1End
Meinersbur retitled this revision from [test-suite] Don't try to backtrack to beginning of number. to [test-suite] Use forward-parsing when searching for numbers..Mar 31 2021, 7:42 AM
Meinersbur edited the summary of this revision. (Show Details)
  • Special handling of 0.0 tolerances like original
Meinersbur edited the summary of this revision. (Show Details)Mar 31 2021, 8:49 AM
Meinersbur added a subscriber: llvm-commits.