TL;DR - this is a patch series that fixes over 100 function body
scan tests on X86 darwin.

@richard, @rainer:

I think that patch 1 is 'obvious' and patches 3 and 4 are darwin-
specific, so I am looking for approval for patch 2 (and comments
on the design, described below).

This has been tested on x86_64-linux, darwin; aarch64-linux and
sparc solaris.

OK for trunk?
relevant back-ports?

thanks
Iain

---- motivation

Making good, portable, scan-asm and function-body-scan tests is
quite hard.  When a target arch has several sub-ports and those
might have different ABIs and/or assembler syntax, it becomes
harder.

However, committing non-portable tests is a large burden on the
maintainers of sub-ports who first, in many cases, have to try
and figure out what parts of the assembler match are important
and then whether a fail means that the sub-port has an issue or
if it's just a matter of ABI or asm syntax.  The worst-case is
when a test-case looks like someone has just C&P the asm from one
platform.

Editing every test is a lot of churn and very time-consuming;
the ideal would be for a portable representation of the asm
to be checked; a second solution would be for committers to
take care to make the cases as portable as possible.

Issues come in the following categories;

  1. Simple and obvious (the most frequent for Darwin is that
     folks "forget" to cater for USER_LABEL_PREFIX).  Unfortunately,
     this is not something that is easy to fix automatically, since
     there are ambiguities in symbol spelling.  This category likely
     remains a "manual edit" of the test-cases.

 2. Tests are committed assuming that the target is ELF, this mostly
    affects the asm syntax.

 3. Tests are committed assuming that all targets support an ABI
    that allows statically exes.

 4. Tests are committed that are just not representable (the code-
    gen is fundamentally different for disparate ABIs).

For x86, I have already committed patches that skip the tests in the
4th category.  This series deals with cases 1...3.

---- implementation/design

As noted, case 1 remains "you have to edit the tests to prepend _?
to symbols".  Some tests in case 3 also need editing since the asm
for a PIC-only platform can differ significantly from statically-
linked.

The strategy for automating a substantial part of the remainder
is:

  - Allow the target to skip some lines of the input regex (for
    example, on Darwin we would skip .cfi_xxx since those insns
    are not used at present).

  - Allow the target to copy some lines from the regex without
    prepending a prefix; typically, this is used to ensure that
    lines starting with a compiler-local label (or an asm label)
    are copied verbatim, so that we do not end up trying to
    match white-space that is not present.
    
  - Allow the target to provide global replacements for regex
    content where the spelling of keywords or labels differs.

---- TODO:

 1. it would be nice to figure out some way to deal with the
     USER_LABEL_PREFIX issue.
     
 2. I wonder if we can make some cases more efficient by allowing
    more that one start key for the reg-exes, thus:
    
/* { dg-final { check-function-bodies {"**" "*E"} "" "" { target { ! 
*-*-darwin* } } {^\t?\.} } } */
/* { dg-final { check-function-bodies {"**" "*M"} "" "" { target *-*-darwin*  } 
{^\t?\.} } } */

/*
**foo:
**...
*E elf asm
** asm that's the same for both
*M mach-o asm
**...
*/

  3. I note that the 5th entry in the dg- command seems to be {^\t?\.} in
     the vast number of cases, perhaps this should be moved into the code?

---- comments?

========

Iain Sandoe (4):
  testsuite, X86: Add missing "check_function_bodies" calls.
  testsuite: Make function body scans more flexible to ABI and asm
    syntax.
  testsuite, c, x86, Darwin: Adjust func body scan tests for Darwin
    ABI/asm.
  testsuite, c++, x86, Darwin: Adjust func body scan tests for Darwin
    ABI/asm.

 gcc/testsuite/g++.target/i386/cf_check-4.C    |   2 +-
 .../g++.target/i386/memset-pr108585-1a.C      |   2 +-
 .../g++.target/i386/memset-pr108585-1b.C      |   2 +-
 .../gcc.target/i386/auto-init-padding-9.c     |   5 +-
 .../gcc.target/i386/builtin-fabs-2.c          |   1 +
 .../gcc.target/i386/builtin-memmove-13.c      |  13 ++-
 gcc/testsuite/gcc.target/i386/cf_check-11.c   |   2 +-
 .../gcc.target/i386/memcpy-pr120683-1.c       |  32 +++++-
 .../gcc.target/i386/memcpy-strategy-13.c      |   4 +-
 .../gcc.target/i386/memset-pr120683-10.c      |  18 ++-
 .../gcc.target/i386/memset-pr120683-20.c      |  26 ++++-
 .../gcc.target/i386/memset-pr120683-21.c      |  26 ++++-
 .../gcc.target/i386/memset-strategy-27.c      |   4 +-
 .../gcc.target/i386/memset-strategy-31.c      |   1 +
 .../gcc.target/i386/no-callee-saved-19a.c     |   5 +-
 .../gcc.target/i386/no-callee-saved-19b.c     |   1 +
 .../gcc.target/i386/no-callee-saved-19c.c     |   1 +
 .../gcc.target/i386/no-callee-saved-19d.c     |   1 +
 .../gcc.target/i386/no-callee-saved-19e.c     |   1 +
 gcc/testsuite/gcc.target/i386/opt-comi-1.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr111657-1.c    |  25 +++-
 gcc/testsuite/gcc.target/i386/pr116174.c      |   1 +
 gcc/testsuite/gcc.target/i386/pr119784a.c     |   3 +-
 gcc/testsuite/gcc.target/i386/pr119784b.c     |   1 +
 gcc/testsuite/gcc.target/i386/pr120840-1a.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120840-1b.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120840-1c.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120840-1d.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120881-2a.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120936-10.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120936-12.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr120936-3.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr120936-6.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr120936-7.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr120936-8.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr120941-1.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr121572-1a.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr121572-1b.c   |   1 +
 gcc/testsuite/gcc.target/i386/pr122343-1a.c   |  13 ++-
 gcc/testsuite/gcc.target/i386/pr122343-1b.c   |  14 ++-
 gcc/testsuite/gcc.target/i386/pr122343-2a.c   |  15 ++-
 gcc/testsuite/gcc.target/i386/pr122343-2b.c   |  16 ++-
 gcc/testsuite/gcc.target/i386/pr122343-3.c    |  13 ++-
 gcc/testsuite/gcc.target/i386/pr122343-4a.c   |  18 ++-
 gcc/testsuite/gcc.target/i386/pr122343-4b.c   |  21 +++-
 gcc/testsuite/gcc.target/i386/pr122343-5a.c   |  13 ++-
 gcc/testsuite/gcc.target/i386/pr122343-5b.c   |  16 ++-
 gcc/testsuite/gcc.target/i386/pr122343-6a.c   |  21 +++-
 gcc/testsuite/gcc.target/i386/pr122343-6b.c   |  23 +++-
 gcc/testsuite/gcc.target/i386/pr122343-7.c    |  16 ++-
 gcc/testsuite/gcc.target/i386/pr122675-1.c    |   2 +-
 gcc/testsuite/gcc.target/i386/pr125351.c      |   1 +
 gcc/testsuite/gcc.target/i386/pr125355-2.c    |   4 +-
 gcc/testsuite/gcc.target/i386/pr125355.c      |   2 +-
 gcc/testsuite/gcc.target/i386/pr81501-4a.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr81501-6a.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr81501-6b.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr81501-8a.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr81501-8b.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr81501-9a.c    |   1 +
 gcc/testsuite/gcc.target/i386/pr81501-9b.c    |   2 +-
 gcc/testsuite/gcc.target/i386/pr92080-17.c    |  16 ++-
 gcc/testsuite/gcc.target/i386/pr93492-1.c     |   1 +
 gcc/testsuite/gcc.target/i386/prefetchi-1.c   |   4 +-
 gcc/testsuite/gcc.target/i386/prefetchi-1b.c  |   4 +-
 .../gcc.target/i386/preserve-none-25.c        |   1 +
 .../gcc.target/i386/preserve-none-26.c        |   1 +
 .../gcc.target/i386/preserve-none-27.c        |   1 +
 .../gcc.target/i386/preserve-none-30a.c       |   1 +
 .../gcc.target/i386/preserve-none-30b.c       |   1 +
 gcc/testsuite/lib/scanasm.exp                 | 107 ++++++++++++++++--
 gcc/testsuite/lib/target-supports.exp         |   4 +
 72 files changed, 485 insertions(+), 64 deletions(-)

-- 
2.50.1 (Apple Git-155)

Reply via email to