<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57351>57351</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Potential Clang miscompilation issue caused by 7171615099142ed49042c0f27af437b05150dd9b
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            royjacobson
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zeroomega
      </td>
    </tr>
</table>

<pre>
    [clang-crashreports.zip](https://github.com/llvm/llvm-project/files/9419974/clang-crashreports.zip)

We are seeing Fuchsia build failures when using Tip-of-Tree clang after change 7171615099142ed49042c0f27af437b05150dd9b was landed. After examine the failure, we suspect it there might be a bug introduced in change 7171615099142ed49042c0f27af437b05150dd9b causing the clang to miscompile certain code.

In the attachment is the clang reproducer generated from affected TU from Fuchsia source tree.  `test_built_7171615.o` is the output generated from the reproducer using clang revision 7171615099142ed49042c0f27af437b05150dd9b and `test_built_ba8b5f.o` is the output generated from clang revision ba8b5ff874ad438a07ac3cc4f2bc75898b1401f8 (parent revision of 7171615099142ed49042c0f27af437b05150dd9b).  `test_7171615_readelf.txt` and `test_ba8b5f_readelf.txt` are readelf output from compiled TU using 2 different clangs. 

>From readelf output, it looks like a large numbers of symbols are missing from the binary compiled using 7171615099142ed49042c0f27af437b05150dd9b. In `.rela.text._Z8TestMainPvN4arch10EarlyTicksE`, number of entries dropped from 139 to 63. The `AddOne` function defined at L194742 in the TU is completely missing from the readelf results from 7171615099142ed49042c0f27af437b05150dd9b. While we have not yet fully understand why change 7171615099142ed49042c0f27af437b05150dd9b causes the differences we are seeing here, we suspect this change introduced a bug that caused the miscompilation issue and need to be investigated and fixed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVV1vnDoQ_TXsixUENizwwENu20iV7kcf9qpSXyJjD-DGi5FtNtn--js2Id2kvdK2UpQFbM-cc-bM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