<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 - RTTI cxxabi pointers are 'external global i8*', but are referenced using 'getelementptr inbounds' with index '2'"
   href="https://bugs.llvm.org/show_bug.cgi?id=35352">35352</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>RTTI cxxabi pointers are 'external global i8*', but are referenced using 'getelementptr inbounds' with index '2'
          </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>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>ahmed.bougacha@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Take a simple class:

  class A { virtual void f1(); };
  void A::f1() { }

With RTTI enabled, we emit a reference to the libcxxabi RTTI base:

  @_ZTVN10__cxxabiv117__class_type_infoE = external global i8*

and later use it in a GEP:

  @_ZTI1A = constant ... { ... i8** getelementptr inbounds (i8*, i8**
@_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), ... }

Is that correct?  As far as IR is concerned, the global is only 8-bytes wide. 
LangRef says:

  If the inbounds keyword is present, the result value of the getelementptr is
a poison value if the base pointer is not an in bounds address of an allocated
object

The object isn't allocated in this module, and irgen knows that the allocated
object is large enough.   But still, it seems fishy.  I haven't found anything
conclusive either way in the GEP/pointer aliasing rules.</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>