<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 - clang++ miss optimization at -O2 in OpenJDK’s stubRoutine.cpp"
   href="https://bugs.llvm.org/show_bug.cgi?id=42603">42603</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang++ miss optimization at -O2 in OpenJDK’s stubRoutine.cpp
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>OpenBSD
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bsdkurt@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Summary:

Building OpenJDK 11u on OpenBSD/i386 in fastdebug mode fails due to miss
optimization of stubRoutines.cpp at -O2 or -O3. Building this file with -O1
corrects the issue.

Details:

When OpenJDK is built in fastdebug mode on OpenBSD/i386, some test code is
enabled in stubRoutines.cpp (test_arraycopy_func). This test code aligns a
pointer to 8 bytes (align_up), then calls another function via a pointer that
was passed as an argument to test_arraycopy_func. The called function checks
the alignment (is_aligned). When compiled at -O2 or higher the align_up has
been optimized away incorrectly and the called method fails its alignment
check. Reducing optimization level to -O1 results in correct output where the
pointer has been aligned.

I have bisected the compile at -O2 and found that the output works up to pass
5170 but fails if higher. However, in order to do this I had to apply the patch
from <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang++ -opt-bisect-limit SIGSEGV with Emulated TLS"
   href="show_bug.cgi?id=42584">bug 42584</a>:

<a href="https://bugs.llvm.org/attachment.cgi?id=22229">https://bugs.llvm.org/attachment.cgi?id=22229</a>

The preprocessed source for this crash is 11MB and is too big to attach (even
when compressed). The preprocessed source and build script can be downloaded
here:

<a href="http://www.intricatesoftware.com/distfiles/clang++.openjdk.stubRoutines.tar.gz">http://www.intricatesoftware.com/distfiles/clang++.openjdk.stubRoutines.tar.gz</a>

Here is some of the BISECT context. Including pass 5171 results in the miss
optimization:

BISECT: running pass (5116) Simplify the CFG on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5117) Combine redundant instructions on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5118) Tail Call Elimination on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5119) Simplify the CFG on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5120) Reassociate expressions on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5121) Simplify the CFG on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5122) Combine redundant instructions on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5123) MergedLoadStoreMotion on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5124) Global Value Numbering on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5125) MemCpy Optimization on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5126) Sparse Conditional Constant Propagation on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5127) Bit-Tracking Dead Code Elimination on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5128) Combine redundant instructions on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5129) Jump Threading on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5130) Value Propagation on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5131) Dead Store Elimination on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5132) Aggressive Dead Code Elimination on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5133) Simplify the CFG on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5134) Combine redundant instructions on function
(_Z8align_upImiET_S0_T0_)
BISECT: running pass (5135) Remove unused exception handling info on SCC
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5136) Function Integration/Inlining on SCC
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5137) Deduce function attributes on SCC
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5138) SROA on function (_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5139) Early CSE w/ MemorySSA on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5140) Speculatively execute instructions if target has
divergent branches on function (_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5141) Jump Threading on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5142) Value Propagation on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5143) Simplify the CFG on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5144) Combine redundant instructions on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5145) Tail Call Elimination on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5146) Simplify the CFG on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5147) Reassociate expressions on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5148) Simplify the CFG on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5149) Combine redundant instructions on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5150) MergedLoadStoreMotion on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5151) Global Value Numbering on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5152) MemCpy Optimization on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5153) Sparse Conditional Constant Propagation on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5154) Bit-Tracking Dead Code Elimination on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5155) Combine redundant instructions on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5156) Jump Threading on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5157) Value Propagation on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5158) Dead Store Elimination on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5159) Aggressive Dead Code Elimination on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5160) Simplify the CFG on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5161) Combine redundant instructions on function
(_Z8align_upIhiEPT_S1_T0_)
BISECT: running pass (5162) Remove unused exception handling info on SCC
(_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5163) Function Integration/Inlining on SCC
(_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5164) Deduce function attributes on SCC
(_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5165) SROA on function (_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5166) Early CSE w/ MemorySSA on function
(_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5167) Speculatively execute instructions if target has
divergent branches on function (_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5168) Jump Threading on function
(_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5169) Value Propagation on function
(_ZL19test_arraycopy_funcPhi)
BISECT: running pass (5170) Simplify the CFG on function
(_ZL19test_arraycopy_funcPhi)
BISECT: NOT running pass (5171) Combine redundant instructions on function
(_ZL19test_arraycopy_funcPhi)</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>