<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 - Chromium miscompile after r326991"
   href="https://bugs.llvm.org/show_bug.cgi?id=36729">36729</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Chromium miscompile after r326991
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I don't fully understand the root cause here, but this what I've got so far.

After r326991, a large unit test in the Chromium Fuchsia port started failing.
The way this test runs is complicated (runs in some sort of emulated
environment) and I'm not familiar with it, so I'm not sure exactly what's going
wrong. I think something is crashing, but it's hard to tell from the logs.

(Example failed build here:
<a href="https://ci.chromium.org/buildbot/tryserver.chromium.linux/fuchsia_x64/86148">https://ci.chromium.org/buildbot/tryserver.chromium.linux/fuchsia_x64/86148</a>)

Luckily, there's only a single function whose machine code changes after
r326991: Skia's grayA_to_rgbA_portable. I've verified that if I put
__attribute__((optnone)) on that, the tests pass.

Here's a mostly stand-alone repro to show the difference:

#include <stdint.h>

static void grayA_to_rgbA_portable(uint32_t dst[], const void* vsrc, int count)
{
    const uint8_t* src = (const uint8_t*)vsrc;
    for (int i = 0; i < count; i++) {
        uint8_t g = src[0],
                a = src[1];
        src += 2;
        g = (g*a+127)/255;
        dst[i] = (uint32_t)a << 24
               | (uint32_t)g << 16
               | (uint32_t)g << 8
               | (uint32_t)g << 0;
    }
}
void grayA_to_rgbA(uint32_t dst[], const void* src, int count) {
    grayA_to_rgbA_portable(dst, src, count);
}

$ diff -u <(/work/llvm.combined/build.release.good/bin/clang++ -fPIC -m64
-march=x86-64 -fomit-frame-pointer -O2 -std=c++14 -x c++ -c /tmp/SkOpts.ii -S
-o -) <(/work/llvm.combined/build.release.bad/bin/clang++ -fPIC -m64
-march=x86-64 -fomit-frame-pointer -O2 -std=c++14 -x c++ -c /tmp/SkOpts.ii -S
-o -)


The diff shows a PSHUFD going missing in the new version, the rest of the diff
is just register names. I haven't dug into the assembly enough to tell why this
is breaking anything.

Craig, does this make any sense to you? Was your change supposed to alter
codegen or was it just reorganizing the code?</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>