[LLVMbugs] [Bug 19113] New: 'tbaa vtable pointer' attr is missed for member function pointer deref

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 12 01:16:01 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19113

            Bug ID: 19113
           Summary: 'tbaa vtable pointer' attr is missed for member
                    function pointer deref
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dvyukov at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140312/4dff7028/attachment.html>


More information about the llvm-bugs mailing list