[PATCH] D11606: Vtable aliasing improvement: makes obj->vtable noalias obj and modref(obj->virt_call, obj->vtable) = REF

Richard Smith richard at metafoo.co.uk
Wed Aug 5 14:05:53 PDT 2015


rsmith added a subscriber: rsmith.
rsmith requested changes to this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision now requires changes to proceed.

Your assumption that the vptr for an object cannot change during a virtual call to that object is not correct; the rules here are more subtle. See the recent "Clang devirtualization proposal" thread on llvm-dev / cfe-dev for an approach that handles the cases where the vptr actually cannot change; Piotr Padlewski is currently working on implementing that approach.


================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1462-1464
@@ -1436,1 +1461,5 @@
+
+    // Considering Object's Vtable can't alias Object
+    if (isVtableLoadFrom(O1, O2) || isVtableLoadFrom(O2, O1))
+      return NoAlias;
   }
----------------
This is redundant in many cases (we can already deduce this if the load from the object has TBAA metadata, or if we can see the pointers are distinct), and wrong in other cases (for instance, using memcpy to write over the storage for an object that had a vptr).


http://reviews.llvm.org/D11606





More information about the llvm-commits mailing list