<div dir="ltr"><div>Thanks for the suggestions. I think the naming the whole line idea is okay, but it feels a bit clunky. Either we'd have to have a syntax that FileCheck would recognise without caring about the prefix (which seems to be against the ethos of FileCheck, and also makes it less flexible), or in the case I'm referring to, we'd have to have an extra line that does nothing other than define the pattern that can then be used later, and we'd still have some duplication (namely of the NOT check) i.e. something like:</div><div><br></div><div>RUN: tool --print-string | FileCheck %s --check-prefixes=COMMON,CHECK</div><div>RUN: tool --no-print-string | FileCheck %s --check-prefixes=COMMON,NO<br></div><div><br></div><div>COMMON-DEFINE-MYNAME: some string</div><div>CHECK: [[MYNAME]]</div><div>NO-NOT: [[MYNAME]]</div><div><br></div><div>Assuming we go with this modified proposal, I'd be tempted for something like the above as the syntax, namely "<prefix>-DEFINE-<name of new pattern>".</div><div><br></div><div>Perhaps a little less verbose, and more obvious could be the following:<br></div><div><br></div><div>CHECK-DEFINE: {{MYNAME:some string}}</div><div>or even</div><div>CHECK-DEFINE: {{VAR1:a literal}} {{VAR2:a.*pattern}}<br></div><div><br></div><div>Where "DEFINE" is a new kind of directive which says "don't actually match anything, but do define regex patterns as defined on the line, so that they can be used in subsequent checks". Patterns defined in this way would then be applied in the same way as {{.*}} style patterns, unlike other variables, which just match the earlier string they captured (ignoring Thomas's recent changes at least).<br></div><div><div></div>

</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 31 Jan 2020 at 14:32, Robinson, Paul <<a href="mailto:paul.robinson@sony.com">paul.robinson@sony.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div bgcolor="white" lang="EN-US">
<div class="gmail-m_3204856666405030696WordSection1">
<p class="MsoNormal">Seems to me there was a proposal (possibly years ago now) to allow defining named patterns, from someone who had (IIRC) implemented such a feature in a downstream project.  I don’t remember the details of their use-case, but apparently
 by itself it wasn’t compelling enough to get the encouragement to proceed.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">FileCheck directives are already easy to get wrong, and adding a command-line option to change their interpretation just seems like asking for trouble. But adding a way to define a pattern that is independent of the input text seems like
 it could be useful.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’d suggest that initially at least, the define-a-pattern directive would take only “immediate” text, no embedded regexes. That is, you could do<u></u><u></u></p>
<p class="MsoNormal">    DEFPAT[MYPATTERN]: Define a pattern here<u></u><u></u></p>
<p class="MsoNormal">but you couldn’t do<u></u><u></u></p>
<p class="MsoNormal">    DEFPAT[MYPATTERN]: Define {{some|any}} pattern here<u></u><u></u></p>
<p class="MsoNormal">although it might be reasonable to allow<u></u><u></u></p>
<p class="MsoNormal">    DEFPAT[PATTERN1]: some<u></u><u></u></p>
<p class="MsoNormal">    DEFPAT[PATTERN2]: Define [[PATTERN1]] pattern here<u></u><u></u></p>
<p class="MsoNormal">as the [[]] substitution can be done when the directive is read.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My $.02,<u></u><u></u></p>
<p class="MsoNormal">--paulr<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-color:currentcolor currentcolor currentcolor blue;border-style:none none none solid;border-width:medium medium medium 1.5pt;padding:0in 0in 0in 4pt">
<div>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> George Rimar <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>> <br>
<b>Sent:</b> Friday, January 31, 2020 5:52 AM<br>
<b>To:</b> Thomas Preud'homme <<a href="mailto:thomasp@graphcore.ai" target="_blank">thomasp@graphcore.ai</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>>; <a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a><br>
<b>Subject:</b> Re: [RFC][FileCheck] New option to negate check patterns<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p><span style="font-size:12pt;color:black">​Hi all,<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
<p><span style="font-size:12pt;color:black">> I feel it might be confusing to have a CHECK becomes effectively a CHECK-NOT,<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black">> especially if the RUN line is far from the CHECK line (which is often the case when<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black">> a single RUN line drives several groups of CHECK directives (e.g. code generation<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black">> tested for several functions for a specific feature, like PIC). You also loose control<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black">> on where the NOT should be: it would have to be at the same location as the<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black">> CHECK even though for the NOT case you might want to check it somewhere else.<u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
<p><span style="font-size:12pt;color:black">I think I agree with Thomas. <u></u><u></u></span></p>
<p><span style="font-size:12pt;color:black">+ the relationship with "</span><span style="font-size:12pt;color:rgb(33,33,33);background:white none repeat scroll 0% 0%">CHECK-NOT/CHECK-NEXT/CHECK-SAME" </span><span style="font-size:12pt;color:rgb(33,33,33)">might make things overcomplicated
 probably.</span><span style="font-size:12pt;color:black"><u></u><u></u></span></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">> How about having a concept of regex variables where you give a name<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">> to a given directive's pattern which you could reuse as another pattern. Something like (syntax TBD):<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">> CHECK<NAME>: mov [[REG:r[0-9]+]], #42<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">> CHECK-NOT: <NAME><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">I.e. without adding a new optinons for </span><span style="font-size:12pt;color:rgb(33,33,33);background:white none repeat scroll 0% 0%">FileCheck</span><span style="font-size:12pt;color:black">, something like the following?<u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white none repeat scroll 0% 0%"><span style="font-size:12pt;color:rgb(33,33,33)"># RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=CHECK1<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white none repeat scroll 0% 0%"><span style="font-size:12pt;color:rgb(33,33,33)"># RUN: llvm-sometool --no-print-string | FileCheck %s --check-prefix=<span style="background:white none repeat scroll 0% 0%">CHECK2</span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white none repeat scroll 0% 0%"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black;background:white none repeat scroll 0% 0%">CHECK1<NAME>: mov [[REG:r[0-9]+]], #42</span><span style="font-size:12pt;color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black;background:white none repeat scroll 0% 0%">CHECK2-NOT: <NAME></span><span style="font-size:12pt;color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">It might work probably.  We already have the ability to name parts of<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">the output checked:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">// CHECK:      Dynamic Relocations {<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">// CHECK-NEXT:   {{.*}} R_AARCH64_RELATIVE - [[BAR_ADDR:.*]]<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">// CHECK:      Symbols [<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">// CHECK-NEXT:     Value: [[BAR_ADDR]]<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">So adding a way for naming the whole line does not look<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black">an unreasonable/inconsistent extention to me I think.<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white none repeat scroll 0% 0%"><span style="font-size:12pt;color:black">Best regards,​<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white none repeat scroll 0% 0%"><span style="font-size:12pt;color:black">George | Developer | Access Softek, Inc​​​​​​​<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
</div>
<div class="MsoNormal" style="text-align:center" align="center"><span style="font-size:12pt;color:rgb(33,33,33)">
<hr width="98%" size="2" align="center">
</span></div>
<div id="gmail-m_3204856666405030696divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> James Henderson <<a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a>><br>
<b>Sent:</b> 31 January 2020 09:14<br>
<b>To:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Thomas Preud'homme <<a href="mailto:thomasp@graphcore.ai" target="_blank">thomasp@graphcore.ai</a>>; Paul Robinson <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>>; George Rimar <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>><br>
<b>Subject:</b> [RFC][FileCheck] New option to negate check patterns</span><span style="font-size:12pt;color:rgb(33,33,33)">
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"> <u></u><u></u></span></p>
</div>
</div>
<div>
<p><span style="font-size:12pt;color:rgb(33,33,33);background:rgb(255,235,156) none repeat scroll 0% 0%">     [This message was sent from somebody outside of your organisation]     </span><span style="font-size:12pt;color:rgb(33,33,33)"><u></u><u></u></span></p>
<p><span style="font-size:12pt;color:rgb(33,33,33)"> <u></u><u></u></span></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">Hi all,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">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:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=STRING<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># RUN: llvm-sometool --no-print-string | FileCheck %s --check-prefix=NO-STRING<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># STRING: This is the string<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># NO-STRING-NOT: This is the string<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">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.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">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:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=STRING<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># RUN: llvm-sometool --no-print-string | FileCheck %s --check-not-prefix=STRING<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"># STRING: This is the string<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">If there was a typo or somebody changed the string output, this mechanism would ensure there is no chance of the pattern rotting.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">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.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">Thoughts?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)">James<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-size:12pt;color:rgb(33,33,33)"><br>
<br>
</span><span style="font-size:7.5pt;color:rgb(33,33,33)">** We have updated our privacy policy, which contains important information about how we collect and process your personal data. To read the policy, please click
<a href="http://www.graphcore.ai/privacy" target="_blank">here</a> **<br>
<br>
This email and its attachments are intended solely for the addressed recipients and may contain confidential or legally privileged information.<br>
If you are not the intended recipient you must not copy, distribute or disseminate this email in any way; to do so may be unlawful.<br>
<br>
Any personal data/special category personal data herein are processed in accordance with UK data protection legislation.<br>
All associated feasible security measures are in place. Further details are available from the Privacy Notice on the website and/or from the Company.<br>
<br>
Graphcore Limited (registered in England and Wales with registration number 10185006) is registered at 107 Cheapside, London, UK, EC2V 6DN.<br>
This message was scanned for viruses upon transmission. However Graphcore accepts no liability for any such transmission.</span><span style="font-size:12pt;color:rgb(33,33,33)"><u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div>