<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - relocations for new removed when optimization turned on"
   href="http://llvm.org/bugs/show_bug.cgi?id=21421">21421</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>relocations for new removed when optimization turned on
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>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>danalbert@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>danalbert@google.com, eric@efcs.ca, llvmbugs@cs.uiuc.edu, srhines@google.com
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>21420
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Enabling -Os or -O2 (probably others, but haven't checked) for the libc++ tests
causes
<a href="https://github.com/llvm-mirror/libcxx/blob/b64f8b07c104c6cc986570ac8ee0ed16a9f23976/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp">https://github.com/llvm-mirror/libcxx/blob/b64f8b07c104c6cc986570ac8ee0ed16a9f23976/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp</a>
to fail. Inspection shows this is because the optimization is causing no
relocation to nothrow new (mangled: _ZnwjRKSt9nothrow_t) to be emitted.

# With -O0
$ readelf -r foo.o | grep _ZnwjRK
00000018  0000840a R_ARM_THM_CALL    00000000   _ZnwjRKSt9nothrow_t

# With -Os
$ readelf -r baz.o | grep _ZnwjRK
# no output

The emitted IR shows no reference to _ZnwjRKSt9nothrow_t at -Os, but does at
-O0, so I'm assuming this is a clang codegen issue. Also checked with
-fno-assume-sane-operator-new, so I don't think this is related to the
new/delete being optimized out.

EricWF checked GCC, and said that it exhibits the correct behavior.</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>