<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body 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="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> George Rimar <grimar@accesssoftek.com><br>
<b>Sent:</b> 06 November 2019 13:01<br>
<b>To:</b> jh7370.2008@my.bristol.ac.uk <jh7370.2008@my.bristol.ac.uk><br>
<b>Cc:</b> Fāng-ruì Sòng <maskray@google.com>; llvm-dev <llvm-dev@lists.llvm.org>; Thomas Preud'homme <thomasp@graphcore.ai>; Paul Robinson <paul.robinson@sony.com><br>
<b>Subject:</b> Re: FileCheck idiom difficulties</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
{margin-top:0px;
margin-bottom:0px}
-->
</style>
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#FFFFFF; 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="x_Signature">
<div name="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div class="x_BodyFragment"><font size="2">
<div class="x_PlainText">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 tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> James Henderson <jh7370.2008@my.bristol.ac.uk><br>
<b>Отправлено:</b> 6 ноября 2019 г. 15:17<br>
<b>Кому:</b> llvm-dev; George Rimar; Fāng-ruì Sòng; Paul Robinson; thomasp@graphcore.ai<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:#ffffff; font-size:10pt; border:1px dotted #003333; padding:.8em">
<span style="color:#ff6600">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 ReportSpam@accesssoftek.com</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">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>
</body>
</html>