On Mon, Mar 30, 2009 at 3:52 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div class="im"><div><div>On Mar 30, 2009, at 11:36 AM, Misha Brukman wrote:</div><blockquote type="cite"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_quote">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>>> @@ -1,4 +1,4 @@<br>>> -; RUN: llvm-as < %s | llc -march=ppc64 -debug |& not grep store<br>
>> +; RUN: llvm-as < %s | llc -march=ppc64 -debug |& not grep {= store}<br>><br>> I thought that "store" instructions were never assigned to a<br>> variable...<br><br></div>This test is grepping through the -debug output of llc, and the stores<br>
its<br>looking for do happen to be printed with =.<br><br>Grepping through -debug output isn't very nice in any case, but at the<br>moment there aren't any better ways to express this specific test.<font color="#888888"><br>
</font></blockquote></div><br>You can write a unittest to check this.  It might require some refactoring to be able to run all of LLC's passes separately from running the tool on the command line, since they are currently hard-coded in its main() function.<br>
</span></blockquote></div></div><div>I don't think we want unit tests for passes.  We only want unit tests for low level APIs.</div></div></blockquote><div><br>Let's drop the term "unit" and just call them tests.  I'm proposing we test passes in C++ instead of a shell script that calls grep.<br>
</div></div><br>How else can we check the correctness of a pass, which involves pattern-matching multiple instructions?  Grep can only look at a single line at a time, and doesn't have the semantic knowledge of what's an instruction and what's an operand, whereas we have all this information in C++.<br>
<br>This thread also shows how brittle shell scripts are for testing pass output, which shouldn't be the case for the LLVM C++ API.<br><br>Misha<br>