<html>
    <head>
      <base href="https://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 --- - CodeGenModule::EmitTargetMetadata() is redundant on all targets but xcore" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23927&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=2iq3Usi_1l7PLGfjZYYR8wK3Vmtf3GwfCk7_61nzITs&s=nk3poo8pypzfX5_EfJUxTu3y867YLr3JD7gZF5HQPOo&e=">23927</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CodeGenModule::EmitTargetMetadata() is redundant on all targets but xcore
          </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>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>yaron.keren@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The loop in EmitTargetMetadata introduced in r212263 iterates over all
MangledDeclNames (the module may have 1000s of them), for every one performing
a lookup in the module symbol table and then calling emitTargetMD() which is a
no-op on all targets but xcore.

Hopefully all of this optimizes out in release builds. In Debug builds the code
is still there, slowing down every run as EmitTargetMetadata is always called
by CodeGenModule::Release(). 

This xcore-specific functionality should probably move into xcore target rather
than living in CodeGenModule. At the very least it should bail out early if
target != xcore and skip the loop.

I don't know if this is wrong: EmitDeclMetadata() is called if
(getCodeGenOpts().EmitDeclMetadata) but EmitTargetMetadata() is always called
regardless the flag.

In addition, MangledDeclNames was modified from a DenseMap into a MapVector, a
heavier and slower data structure. If the code is decoupled into xmos target
maybe MangledDeclNames could be DenseMap again.

Finally, this code does not appear to be covered by regression tests at all. If
the whole function is #if 0 *and* MangledDeclNames is DenseMap, regression
tests pass, at least on Windows and Linux.</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>