[llvm-dev] [RFC][FileCheck] New option to negate check patterns

Thomas Preud'homme via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 31 02:25:08 PST 2020

Hi James,

I feel it might be confusing to have a CHECK becomes effectively a CHECK-NOT, especially if the RUN line is far from the CHECK line (which is often the case when a single RUN line drives several groups of CHECK directives (e.g. code generation tested for several functions for a specific feature, like PIC). You also loose control on where the NOT should be: it would have to be at the same location as the CHECK even though for the NOT case you might want to check it somewhere else.

How about having a concept of regex variables where you give a name to a given directive's pattern which you could reuse as another pattern. Something like (syntax TBD):

CHECK<NAME>: mov [[REG:r[0-9]+]], #42

Best regards,

From: James Henderson <jh7370.2008 at my.bristol.ac.uk>
Sent: 31 January 2020 09:14
To: llvm-dev <llvm-dev at lists.llvm.org>; Thomas Preud'homme <thomasp at graphcore.ai>; Paul Robinson <paul.robinson at sony.com>; George Rimar <grimar at accesssoftek.com>
Subject: [RFC][FileCheck] New option to negate check patterns

     [This message was sent from somebody outside of your organisation]

Hi all,

There have been a few cases recently where I've noticed two test cases in the same lit test that do the same thing except invert the CHECK, to show that something is NOT present. I'm talking about something like the following:

# RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=STRING
# RUN: llvm-sometool --no-print-string | FileCheck %s --check-prefix=NO-STRING
# STRING: This is the string
# NO-STRING-NOT: This is the string

In such cases, as can be seen, the CHECK line effectively has to be duplicated (either in an explicit check like in the above example, or via --implicit-check-not). Duplication is generally bad, especially in this sort of case, as it only takes a typo in the NOT pattern, or a careless developer/reviewer pair changing the output to cause the NOT pattern to no longer be useful.

I'd like to propose a new FileCheck option (e.g. --check-not-prefix/--check-not-prefixes) which allows implicitly converting a check prefix to a -NOT version of the same prefix. That would allow writing the above example as:

# RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=STRING
# RUN: llvm-sometool --no-print-string | FileCheck %s --check-not-prefix=STRING
# STRING: This is the string

If there was a typo or somebody changed the string output, this mechanism would ensure there is no chance of the pattern rotting.

Caveat: I don't know what would be the appropriate way of handling non-trivial checks, i.e. existing CHECK-NOT/CHECK-NEXT/CHECK-SAME etc. I'd appreciate any ideas on this.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200131/5be22620/attachment-0001.html>

More information about the llvm-dev mailing list