<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Missing DSE for escaped local variable, affects pattern init"
   href="https://bugs.llvm.org/show_bug.cgi?id=50220">50220</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing DSE for escaped local variable, affects pattern init
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider this input:

$ cat t.c
void escape(int*);
int getval(void);
int missed_dse() {
  int v1 = 0;
  escape(&v1);
  int v2 = 55555;
  v2 = getval();
  escape(&v2);
  return v2 + v1;
}

DSE cannot eliminate the dead store of 55555:

$ clang -O2 t.c -o - -S -emit-llvm | grep store
  store i32 0, i32* %v1, align 4, !tbaa !3
  store i32 55555, i32* %v2, align 4, !tbaa !3
  store i32 %call, i32* %v2, align 4, !tbaa !3

Our users noticed that the Chrome binary contains lots of stores of 0xAAAA
constants after enabling -fauto-var-init=pattern, and this pattern stood out.

I attempted to debug why this happens, and basically DSE thinks that the
`getval` call can read the 5555 store from v2, even though it has not been
escaped yet. It will be escaped later in the program, but that hasn't happened
at the point of the call.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>