[PATCH] D11859: Generating vptr assume loads

John McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 13:20:52 PDT 2015


rjmccall added inline comments.

================
Comment at: lib/CodeGen/CGClass.cpp:1862
@@ +1861,3 @@
+  for (const VPtr &Vptr : getVTablePointers(ClassDecl))
+    if (CGM.getCXXABI().requiresVPtrInitialization(Vptr))
+      EmitVTableAssumptionLoad(Vptr, This);
----------------
No, it only checks whether VTableClass has novtable.  VTableClass is the derived class for which we're initializing subobject v-tables, and it's invariant during getVTablePointers; that's why it's passed separately from BaseSubobject.

And if you think about how novtable works as a language feature, you'll see that it has to be that way.  The purpose of "novtable" is to avoid emitting v-tables just for the short-term purposes of construction and destruction.  It's not supposed to apply when initializing derived classes: eventually, the complete object does need all the v-tables to be initialized, or else you'll never be able to call virtual methods on it, meaning that it might as well not have any.


http://reviews.llvm.org/D11859





More information about the cfe-commits mailing list