[PATCH] D11859: Generating vptr assume loads

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 13 18:07:30 PDT 2015


rsmith added inline comments.

================
Comment at: lib/CodeGen/CGClass.cpp:1832
@@ +1831,3 @@
+  // Generate vtable assumptions if we are calling dynamic class ctor
+  // and we are not in another ctor.
+  if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
----------------
Prazek wrote:
> hfinkel wrote:
> > I think this comment should be a little more verbose. How about this:
> > 
> >   // Generate vtable assumptions if we are calling dynamic-class's ctor, except when doing so as part of a derived class's ctor's base-class initialization. Doing so in this latter case would be useless, because the vtable is about to be overwritten by the derived class's vtable.
> > 
> The main point of not calling this function, is because it is useless to have assumption loads inside constructor, when they are generated also outside of ctor. I guess You could have case when You are not overriding base vptr, and You are calling base ctor from dynamic class
It might also be worth including in the comment that it is not correct to call `EmitVTableAssumptionLoads` here, because it assumes the object's vptr points to the complete object vtable; during a constructor call it will probably have a construction vtable instead.


http://reviews.llvm.org/D11859





More information about the cfe-commits mailing list