<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 --- - TBAA information are not uniquily identified and this does not play nice with LTO"
   href="https://llvm.org/bugs/show_bug.cgi?id=26550">26550</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>TBAA information are not uniquily identified and this does not play nice with LTO
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>LLVM Codegen
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>* SUMMARY
TBAA information are encoded in bitcode file as metadata. When LTO is invovled,
TBAA information are merged such that two perfectly equal metadata end up being
just one.
This works great when the metadata is generated the same way in all the files.
However, if the project starts to mix up C and C++ code, we end up with
discrepancy in metadata related to TBAA.

* STEPS TO REPRODUCE
clang++ -flto -O1 bar.cpp -o - -S
clang -flto -O1 foo.c -o - -S

* RESULTS
The structure C_CPP got two different identifier and the related TBAA nodes
won't get merged:
cpp:
!3 = !{!"_ZTS5C_CPP", !4, i64 0, !4, i64 4}
c:
!3 = !{!"", !4, i64 0, !4, i64 4}

This causes <rdar://problem/24285442> because we think the accesses don't
aliases.

* NOTES
This is not a bug in the source, because according to the standard, extern "C"
is not used on structures.
The problem is that code in clang:
    SmallString<256> OutName;
    if (Features.CPlusPlus) {
      // Don't use the mangler for C code.
      llvm::raw_svector_ostream Out(OutName);
      MContext.mangleTypeName(QualType(Ty, 0), Out);
      Out.flush();
    } else {
      OutName = RD->getName();
    }

Which basically gives a different naming based on the type of the input file.</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>