[LLVMdev] teaching FileCheck to handle variations in order

Chandler Carruth chandlerc at google.com
Fri Sep 7 14:08:54 PDT 2012


On Fri, Sep 7, 2012 at 8:20 AM, Matthew Curtis <mcurtis at codeaurora.org>wrote:

>  Hello all,
>
> For the hexagon target, we have a couple of tests that are failing due to
> variations in the order of checked text. In these cases the ordering is not
> directly relevant to the functionality being tested.
>
> For example:
>
> ; CHECK: memw(##a)
> ; CHECK: memw(##b)
>
> %0 = load i32* @a, align 4
> %1 = load i32* @b, align 4
>
> requires that the compiler emit the memory operations for 'a' and 'b' in
> that order, even though the intent of the test might simply be to ensure
> that each 'load' results in a memory read.
>
> I'd like to teach FileCheck to allow tests to be more tolerant of these
> incidental variations.
>

So, I'm not a huge fan of this, but for a strange reason.

Fundamentally, I agree with you that these ordering dependencies are
unfortunate in tests. However, I would make a few observations:

1) The order of instructions, unlike some things such as register
allocation's selection of registers, should ideally not vary much.
Currently it does more that we would like due to the inability to unit test
single pieces of the backend, but I don't think we should make FileCheck
better to cope with that, I think we should fix the underlying problem.

2) It is usually fairly obvious when two such checks don't actually have an
ordering constraint that is important, and where it isn't, a comment makes
the intent clear.

3) By checking the ordering, we gain at least some early detection of
non-determinism in the code generator. I definitely caught several bugs in
the block placement pass while I was working on it due to this very
"feature" of the test suite.


Given these points, the value tradeoff here of making FileCheck
*significantly* more complicated (and the tests significantly more complex
as well) versus the time savings updating test cases when the ordering
changes...

But maybe others who have spent more time hammering against these problems
in the backend have a different sense of the magnitude of the problem?


> The attached patch implements one possible solution. It introduces a
> position stack and a couple of directives:
>
>    - 'CHECK-PUSH:' pushes the current match position onto the stack.
>    - 'CHECK-POP:' pops the top value off of the stack and uses it to set
>    the current match position.
>
> The above test can now be re-written as:
>
> ; CHECK-PUSH:
> ; CHECK: memw(##a)
> ; CHECK-POP:
> ; CHECK: memw(##b)
>
> %0 = load i32* @a, align 4
> %1 = load i32* @b, align 4
>
> which handles either ordering of memory reads for 'a' and 'b'.
>
> Thoughts?
>
> Thanks,
> Matthew Curtis
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120907/997dfc3e/attachment.html>


More information about the llvm-dev mailing list