<div dir="ltr"><font face="arial, sans-serif">There are a limited number of clang tests that check generated assembly in test/CodeGen, if you want to go that path, but it needs something like "</font>// REQUIRES: arm-registered-target".  Testing generated assembly from clang is generally discouraged, though, for better or worse.<div>
<div><font face="arial, sans-serif"><div><br></div><div><span style="font-family:arial">You could also do a purely semantic test like (untested):</span><br></div><div><div style="font-family:arial"><br></div><div style="font-family:arial">
// test/Sema/<span style="font-size:13px;font-family:arial,sans-serif">arm-</span><span style="font-size:13px;font-family:arial,sans-serif">cortex-cpus.c</span></div><div style="font-family:arial">// RUN: <span style="font-family:arial,sans-serif;font-size:13px">%clang_cc1 -target arm-linux-gnueabi -mcpu=cortex-m4 -verify</span></div>
<div style="font-family:arial"><span style="font-family:arial,sans-serif;font-size:13px">// expected-no-diagnostics</span></div><div style="font-family:arial"><span style="font-family:arial,sans-serif;font-size:13px">#ifndef </span><font face="arial, sans-serif">__ARM_ARCH_EXT_IDIV__</font></div>
<div style="font-family:arial"><font face="arial, sans-serif"># error "hwdiv wasn't set for cortex-m4!"</font></div><div style="font-family:arial"><font face="arial, sans-serif">#endif</font></div></div></font></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 28, 2014 at 10:03 AM, Artyom Skrobov <span dir="ltr"><<a href="mailto:Artyom.Skrobov@arm.com" target="_blank">Artyom.Skrobov@arm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Reid,<br>
<div class="im"><br>
> A couple things wrong here:<br>
> 1. This test fails if ARM is not a registered target (add "// REQUIRES:<br>
> arm-registered-target" to fix)<br>
> 2. Clang tests shouldn't test generated assembly, that's what LLVM tests<br>
> are for<br>
> 3. Driver tests shouldn't do IR generation, which this test does<br>
<br>
</div>This test is neither for the generated assembly per se, nor for the IR; it's for the target features, which are set in the front-end, and only affect the ARM build attributes that are emitted.<br>
The IR output doesn't include the build attributes, so it is completely unaffected.<br>
<div class="im"><br>
> I'm reverting this in r200242 for now, but feel free to recommit a test<br>
> in test/CodeGen that verifies you get the right attribute bits in the<br>
> IR, if that's how this gets passed down to LLVM.<br>
<br>
</div>No, this doesn't affect the attribute bits in the IR; I can see that the list of target features is passed to clang::EmitBackendOutput, which uses it to create an llvm::TargetMachine, which is then used to generate the output.<br>

Therefore, the only way to test this change is via the generated machine code.<br>
<br>
It might be possible to hack the IR printer so that for ARM targets it included a comment with a dump of the target features or the build attributes; but given that it's only needed for this test, I'd argue this would be even more sloppy than checking for the build attribute in the generated assembly.<br>

<br>
Do you agree?<br>
<br>
<br>
<br>
</blockquote></div><br></div>