<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 9/7/2012 12:12 PM, Krzysztof
      Parzyszek wrote:<br>
    </div>
    <blockquote cite="mid:504A2AF7.1080206@codeaurora.org" type="cite">On
      9/7/2012 7:20 AM, Matthew Curtis wrote:
      <br>
      <blockquote type="cite">
        <br>
        The attached patch implements one possible solution. It
        introduces a
        <br>
        position stack and a couple of directives:
        <br>
        <br>
          * 'CHECK-PUSH:' pushes the current match position onto the
        stack.
        <br>
          * 'CHECK-POP:' pops the top value off of the stack and uses it
        to set
        <br>
            the current match position.
        <br>
        <br>
        The above test can now be re-written as:
        <br>
        <br>
            ; CHECK-PUSH:
        <br>
            ; CHECK: memw(##a)
        <br>
            ; CHECK-POP:
        <br>
            ; CHECK: memw(##b)
        <br>
        <br>
            %0 = load i32* @a, align 4
        <br>
            %1 = load i32* @b, align 4
        <br>
        <br>
        which handles either ordering of memory reads for 'a' and 'b'.
        <br>
        <br>
        Thoughts?
        <br>
      </blockquote>
      <br>
      I'm not sure if I got the details of how the tests work, but
      wouldn't this allow false positives?
      <br>
      <br>
      Take this, for example:
      <br>
      <br>
      ; CHECK-PUSH:
      <br>
      ; CHECK: memw(##a)
      <br>
      ; CHECK-POP:
      <br>
      ; CHECK: memw(##b)
      <br>
      <br>
      %0 = load i32* @a, align 4
      <br>
      %1 = load i32* @b, align 4
      <br>
      <br>
      ; CHECK: memw(##a)
      <br>
      <br>
      %2 = load i32* @a, align 4
      <br>
      <br>
      <br>
      My understanding is that this is supposed to detect:
      <br>
      - 2 loads in any order, one from @a, the other from @b, followed
      by
      <br>
      - 1 load from @a,
      <br>
      that is, a total of 3 loads.
      <br>
      <br>
      At the same time I believe that it would positively match this
      code:
      <br>
        ... = memw(##b)
      <br>
        ... = memw(##a)
      <br>
      i.e. only two loads.  The second load would match two different
      CHECKs.
      <br>
      <br>
      -K
      <br>
      <br>
    </blockquote>
    You are correct. If the intent is to detect:<br>
    <ul>
      <li>2 loads in any order, one from @a, the other from @b, followed
        by
      </li>
      <li>1 load from @a,
      </li>
    </ul>
    the example does not do that. It matches additional sequences as
    well.<br>
    <br>
    I don't believe the PUSH/POP functionality is expressive enough to
    handle this case. You would have to modify the test in some way or
    add more functionality to FileCheck to handle this.<br>
    <br>
    Thinking of possible solutions ...<br>
    <br>
    We could keep track of a "high water mark" and add a directive to
    set the position to it:<br>
    <blockquote>; CHECK-PUSH: <br>
      ; CHECK: memw(##a)
      <br>
      ; CHECK-POP:
      <br>
      ; CHECK: memw(##b)
      <br>
      ; CHECK-HWM:<br>
       <br>
      %0 = load i32* @a, align 4
      <br>
      %1 = load i32* @b, align 4
      <br>
      <br>
      ; CHECK: memw(##a)
      <br>
      <br>
      %2 = load i32* @a, align 4
      <br>
    </blockquote>
    In this case CHECK-HWM (need a better name) will set the position to
    just after 'memw(##a)' or 'memw(##b)' whichever is later in the
    file.<br>
    <br>
    I've attached a new patch with support for the additional directive.<br>
    <br>
    Matthew Curtis.<br>
    <pre class="moz-signature" cols="72">-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation</pre>
  </body>
</html>