[PATCH][C++] Fix PR38334, TBAA issues with vtbl loads

Mark Mitchell mark@codesourcery.com
Tue Dec 2 21:40:00 GMT 2008

Richard Guenther wrote:

> optimization figured out that the memfun delta is zero, so if
> D.1853_6 & 1 is true we load the vtbl pointer from the start of
> the object in question (where there isn't such). 

I almost commented on this in the previous email, but hadn't realized
that the delta was zero in your case.

If we can prove that the access is happening through a class that
doesn't have a vtable (that is, the static type of the pointer is not a
dynamic class), then we can turn that access into a call to
__builtin_trap, or, even better, eliminate that entire conditional.

In other words, if the pointer-to-function-member is { delta: 0; ptr:
<something> }, and the instance is not dynamic, then we can safely
optimize by assuming that pointer-to-function-member is not to a virtual
function.  That would be considerably better than trying to work around
the aliasing issue.

Mark Mitchell
(650) 331-3385 x713

More information about the Gcc-patches mailing list