<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 --- - AddDiscriminators and DILocation::computeNewDiscriminator() modifies the LLVMContext inappropriately"
   href="https://llvm.org/bugs/show_bug.cgi?id=23200">23200</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AddDiscriminators and DILocation::computeNewDiscriminator() modifies the LLVMContext inappropriately
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>DebugInfo
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dexonsmith@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aprantl@apple.com, dblaikie@gmail.com, dnovillo@google.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>`DILocation::computeNewDiscriminator()` modifies a table in the LLVMContext
indexed by filename/line.  This will changes results in other modules created
in the same context, and the table doesn't get serialized to bitcode/assembly
(so roundtripping will change the results of `computeNewDiscriminator()`).

Although it doesn't cause problems for `clang` in practice, this is fairly
broken.

Fortunately, the fix is simple: move the table (and logic) into
`AddDiscriminators::runOnFunction()` and stop modifying the LLVMContext.  This
table is discriminating between adjacent basic blocks, so it doesn't need
global state.

I'll add FIXMEs and tag this PR when I move the function over to MDLocation,
and hopefully circle back to fix it soon after (if no one beats me to it).</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>