[PATCH][AArch64] Add llvm-mc test for asm code generated from all LLVM IR tests

Jiangning Liu liujiangning1 at gmail.com
Mon Dec 2 19:32:22 PST 2013


Hi Jim,

Yes, llvm-mc is a tool rather than a compiler, but asm code is a kind of
interface between compiler output and the assembler tool, correct?

Without using assembler to test the asm output from compiler, how do we
know the assembly code is correct? llvm-mc test is just to check the
correctness of the assembly code generated from compiler.

The example is, without this test we would have the bug which can be fixed
by patch http://llvm.org/viewvc/llvm-project?view=revision&revision=195941.
Otherwise, we would have llvm-mc time failure.

--- llvm/trunk/test/CodeGen/AArch64/neon-scalar-shift-imm.ll 2013/11/29
01:38:49 195940
+++ llvm/trunk/test/CodeGen/AArch64/neon-scalar-shift-imm.ll 2013/11/29
02:11:22 195941
@@ -316,10 +316,10 @@

 define i8 @test_vqshrnh_n_s16(i16 %a) {
 ; CHECK: test_vqshrnh_n_s16
-; CHECK: sqshrn {{b[0-9]+}}, {{h[0-9]+}}, #15
+; CHECK: sqshrn {{b[0-9]+}}, {{h[0-9]+}}, #8
 entry:
   %vsqshrn = insertelement <1 x i16> undef, i16 %a, i32 0
-  %vsqshrn1 = call <1 x i8> @llvm.aarch64.neon.vsqshrn.v1i8(<1 x i16>
%vsqshrn, i32 15)
+  %vsqshrn1 = call <1 x i8> @llvm.aarch64.neon.vsqshrn.v1i8(<1 x i16>
%vsqshrn, i32 8)
   %0 = extractelement <1 x i8> %vsqshrn1, i32 0
   ret i8 %0
 }

Looking at this code change,
"
sqshrn b0, h1, #15" is invalid,
this shift amount should be <=8 and >=1, 
so without llvm-mc test we wouldn't know this is incorrect.

I know adding MCLayer test can capture this kind of bug as well, but it's
hard to capture every corner of negative tests in MCLayer, I think.

Thanks,
-Jiangning



2013/12/3 Jim Grosbach <grosbach at apple.com>

> It is a very, very strange way to write tests. llvm-mc is a tool to check
> the assembler and disassembler, not the compiler. What are you actually
> trying to do? I don’t understand the motivation. Perhaps an example?
>
>
> On Nov 28, 2013, at 3:33 AM, Tim Northover <t.p.northover at gmail.com>
> wrote:
>
> > Hi Jiangning,
> >
> > I think this might be a layering violation (I've CCed Jim Grosbach,
> > who's pretty much the authority). I know that object file tests are
> > discouraged from CodeGen, and this seems very similar.
> >
> > I think the preferred option would be to make sure any test you
> > believe it's usefully doing is part of the test/MC hierarchy.
> >
> > Cheers.
> >
> > Tim.
>
>


-- 
Thanks,
-Jiangning
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131203/b440b78f/attachment.html>


More information about the llvm-commits mailing list