<div dir="ltr"><div>I keep forgetting about CHECK-LABEL, thanks! In many cases, the name lines are unique, so this would probably work, although with sections, for example, they don't have to be (but in 99% of tests they can be). I think in the limited cases where CHECK-LABEL isn't possible, we can use one of the uglier syntaxes.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 6 Nov 2019 at 13:54, Thomas Preud'homme <<a href="mailto:thomasp@graphcore.ai">thomasp@graphcore.ai</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 dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Aren't the name lines unique? If they are you could use the good old CHECK-LABEL:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div><span style="font-family:monospace"># CHECK-LABEL: Name: foo</span></div>
<div><span style="font-family:monospace"># CHECK: Section: .foo (1)</span></div>
</div>
<div id="gmail-m_6428129753020083302appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_6428129753020083302divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> George Rimar <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>><br>
<b>Sent:</b> 06 November 2019 13:01<br>
<b>To:</b> <a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a> <<a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a>><br>
<b>Cc:</b> Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>>; 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>><br>
<b>Subject:</b> Re: FileCheck idiom difficulties</font>
<div> </div>
</div>

<div dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p><span style="color:rgb(33,33,33);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)">> One idea I had was for a new directive something like "CHECK-IMMEDIATE" which</span></p>
<p><span style="color:rgb(33,33,33);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)">> is implicitly the same as the final approach I suggested above, but maybe adding a new</span></p>
<p><span style="color:rgb(33,33,33);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)">> directive to achieve this isn't the right approach?</span><br>
</p>
<p><br>
</p>
<p><span style="color:rgb(33,33,33);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)">"CHECK-IMMEDIATE"</span>​ (or "CHECK-CONTINUE"/better name) sound like a clean and fine approach to me.<br>
</p>
<p>​I'd go with it probably.<br>
</p>
<p><br>
</p>
<div id="gmail-m_6428129753020083302x_Signature">
<div name="x_divtagdefaultwrapper">
<div><font size="2">
<div>Best regards,<br>
George | Developer | <span style="background-color:rgb(255,255,255);color:rgb(33,33,33);font-family:Calibri,sans-serif;font-size:13.3333px">Access Softek, Inc</span></div>
</font></div>
</div>
</div>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block;width:98%">
<div id="gmail-m_6428129753020083302x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>От:</b> James Henderson <<a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a>><br>
<b>Отправлено:</b> 6 ноября 2019 г. 15:17<br>
<b>Кому:</b> llvm-dev; George Rimar; Fāng-ruì Sòng; Paul Robinson; <a href="mailto:thomasp@graphcore.ai" target="_blank">thomasp@graphcore.ai</a><br>
<b>Тема:</b> FileCheck idiom difficulties</font>
<div> </div>
</div>
<div>
<div style="font-size:9pt;font-family:"Calibri",sans-serif">
<h3 style="background-color:rgb(255,255,255);font-size:10pt;border:1px dotted rgb(0,51,51);padding:0.8em">
<span style="color:rgb(255,102,0)">CAUTION:<strong> </strong></span>This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.  If you suspect potential phishing or spam
 email, report it to <a href="mailto:ReportSpam@accesssoftek.com" target="_blank">ReportSpam@accesssoftek.com</a></h3>
</div>
<div>
<div dir="ltr"> 
<div>Hi all,</div>
<div><br>
</div>
<div>Many of our lit tests use FileCheck and a tool like llvm-readobj to check properties of a section header/symbol/etc. A typical (pseudoised for brevity) output to match against might be something like the following:</div>
<div><br>
</div>
<div><span style="font-family:monospace">Symbols [</span></div>
<div><span style="font-family:monospace">  Symbol {</span></div>
<div><span style="font-family:monospace">    Name: foo</span></div>
<div><span style="font-family:monospace">    Value: 0</span></div>
<div><span style="font-family:monospace">    Type: Function</span></div>
<div><span style="font-family:monospace">    Section: .foo (1)<br>
</span></div>
<div><span style="font-family:monospace">  }</span></div>
<div><span style="font-family:monospace">  Symbol {</span></div>
<div><span style="font-family:monospace">    Name: bar</span></div>
<div><span style="font-family:monospace">    Value: 1</span></div>
<div><span style="font-family:monospace">    Type: Object</span></div>
<div><span style="font-family:monospace">    Section: .foo (1)<br>
</span></div>
<div><span style="font-family:monospace">  }<br>
</span></div>
<div><span style="font-family:monospace">]</span></div>
<div><br>
</div>
<div>and your lit test might want to check the properties of the foo symbol like so:</div>
<div><br>
</div>
<div><font face="monospace"># CHECK:      Name: foo</font></div>
<div><span style="font-family:monospace"># CHECK-NEXT: Value: 0</span></div>
<div><span style="font-family:monospace"># CHECK-NEXT: Type: Function</span></div>
<div><span style="font-family:monospace"># CHECK-NEXT: Section: .foo (1) </span></div>
<div><span style="font-family:monospace"><br>
</span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif">This is fine. But what if you only care about the section of a symbol, and not the value or type etc? You could do the following:</font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><br>
</font></span></div>
<div><span style="font-family:monospace"># CHECK: Name: foo</span></div>
<div><span style="font-family:monospace"># CHECK: Section: .foo (1)<br>
</span></div>
<div><br>
</div>
<div>Hopefully some of you will already notice the problem with this approach: if foo was in, say, the .baz section, the test will spuriously pass, because the Section line will match the Section line for .bar. One alternative to this is to explicitly match
 each field in between, using CHECK-NEXT:</div>
<div><span style="font-family:monospace"><br>
</span></div>
<div><span style="font-family:monospace"># CHECK:      Name: foo</span></div>
<div><span style="font-family:monospace"># CHECK-NEXT: Value:</span></div>
<div><span style="font-family:monospace"># CHECK-NEXT: Type:</span></div>
<div><span style="font-family:monospace"># CHECK-NEXT: Section: .foo (1) </span></div>
<div><br>
</div>
<div>This works, but somewhat hides what is really being tested by adding extra noise to the checks. In reality, there are actually other fields too that need to be listed, meaning the "interesting" parts of the test are even more hidden.</div>
<div><br>
</div>
<div>I recently started using yet another approach:</div>
<div><br>
</div>
<div><span style="font-family:monospace"># CHECK: Name: foo</span></div>
<div><span style="font-family:monospace"># CHECK: Section:</span></div>
<div><span style="font-family:monospace"># CHECK-SAME:     .foo (1)<br>
</span></div>
<div><span style="font-family:monospace"><br>
</span></div>
<div><span style="font-family:arial,sans-serif">This works because the Section: matched will be the first one found, i.e. the one belonging to foo, and then .foo will be looked for on the same line. However, I noticed today that this pattern has its own problem,
 namely that there could be something between the Section tag and .foo. In other words, the above pattern would match "Section: .bar.foo". A couple of solutions to this are:</span></div>
<div><span style="font-family:monospace"><br>
</span></div>
<div><span style="font-family:monospace"># CHECK: Section:</span></div>
<div><span style="font-family:monospace"># CHECK-NOT: {{[:graph:]}}</span></div>
<div><span style="font-family:monospace"># CHECK-SAME: .foo (1)</span></div>
<div><span style="font-family:monospace"><br>
</span></div>
<div><span style="font-family:monospace"># CHECK: Section:</span></div>
<div><span style="font-family:monospace"># CHECK-SAME: {{^}} .foo (1)<br>
</span></div>
<div><span style="font-family:monospace"><br>
</span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif">The first one ensures that there's no non-whitespace between the end of "Section:" and the start of ".foo (1)". The second ensures that the start of the CHECK-SAME match is the "start of
 line", and since the first half of the line has already been consumed, it means " .foo (1)" must immediately follow "Section:". However, the first is even less readable than the current CHECK-SAME approach, whilst the second is somewhat confusing if you don't
 realise that FileCheck effectively consumes the things it has matched already, so that they effectively don't exist any more.<br>
</font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><br>
</font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif">Does anybody have any other suggestions/thoughts/comments? One idea I had was for a new directive something like "CHECK-IMMEDIATE" which is implicitly the same as the final approach I suggested
 above, but maybe adding a new directive to achieve this isn't the right approach?</font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><br>
</font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif">James<br>
</font></span></div>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
<font size="1">** 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.<br>
<font></font></font>
</div>

</blockquote></div>