<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 --- - 'tbaa vtable pointer' attr is missed for member function pointer deref"
   href="http://llvm.org/bugs/show_bug.cgi?id=19113">19113</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>'tbaa vtable pointer' attr is missed for member function pointer deref
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dvyukov@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ clang -v
clang version 3.5.0 (203643)
Target: x86_64-unknown-linux-gnu

$ cat vptr.cc
struct X {
  virtual void foo();
};
void foo(X *x) {
  x->foo();
}
void bar(X *x, void (X::*fn)()) {
  (x->*fn)();  
}

$ clang++ vptr.cc -O1 -S -emit-llvm

$ cat vptr.ll
; ModuleID = '/tmp/vptr.cc'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.X = type { i32 (...)** }

; Function Attrs: uwtable
define void @_Z3fooP1X(%struct.X* %x) #0 {
  %1 = bitcast %struct.X* %x to void (%struct.X*)***
  %2 = load void (%struct.X*)*** %1, align 8, !tbaa !1
  %3 = load void (%struct.X*)** %2, align 8
  tail call void %3(%struct.X* %x)
  ret void
}

; Function Attrs: uwtable
define void @_Z3barP1XMS_FvvE(%struct.X* %x, i64 %fn.coerce0, i64 %fn.coerce1)
#0 {
  %1 = bitcast %struct.X* %x to i8*
  %2 = getelementptr inbounds i8* %1, i64 %fn.coerce1
  %3 = bitcast i8* %2 to %struct.X*
  %4 = and i64 %fn.coerce0, 1
  %5 = icmp eq i64 %4, 0
  br i1 %5, label %13, label %6

; <label>:6                                       ; preds = %0
  %7 = bitcast i8* %2 to i8**
  %8 = load i8** %7, align 8
  %9 = add i64 %fn.coerce0, -1
  %10 = getelementptr i8* %8, i64 %9
  %11 = bitcast i8* %10 to void (%struct.X*)**
  %12 = load void (%struct.X*)** %11, align 8
  br label %15

; <label>:13                                      ; preds = %0
  %14 = inttoptr i64 %fn.coerce0 to void (%struct.X*)*
  br label %15

; <label>:15                                      ; preds = %13, %6
  %16 = phi void (%struct.X*)* [ %12, %6 ], [ %14, %13 ]
  tail call void %16(%struct.X* %3)
  ret void
}

attributes #0 = { uwtable "less-precise-fpmad"="false"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
"unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.ident = !{!0}

!0 = metadata !{metadata !"clang version 3.5.0 (203643)"}
!1 = metadata !{metadata !2, metadata !2, i64 0}
!2 = metadata !{metadata !"vtable pointer", metadata !3, i64 0}
!3 = metadata !{metadata !"Simple C/C++ TBAA"}

============================================================

vptr load in foo() is marked with !tbaa !1
vptr load in bar() (%12 = load void (%struct.X*)** %11, align 8) is not marked
with !tbaa !1

This breaks ThreadSanitizer instrumentation pass, and leads to worse race
reports.</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>