This is an archive of the discontinued LLVM Phabricator instance.

Avoid unnecessarily storing vtable pointers in more destructor cases
Needs ReviewPublic

Authored by scott-0 on Aug 26 2015, 8:23 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This makes an existing optimization apply in more cases.

Diff Detail

Event Timeline

scott-0 updated this revision to Diff 33206.Aug 26 2015, 8:23 AM
scott-0 retitled this revision from to Avoid unnecessarily storing vtable pointers in more destructor cases.
scott-0 updated this object.
scott-0 added a subscriber: cfe-commits.
rsmith added a subscriber: rsmith.Aug 26 2015, 5:11 PM
rsmith added inline comments.
lib/CodeGen/CGClass.cpp
1369–1382

This is not complete; you'll also need to at least consider atomic stores (that might store the this pointer and be picked up by another thread), the implicit call to operator new in a CXXNewExpr (which is not modeled as a CallExpr), implicit destructor calls (which aren't modeled in the AST at all), and probably a lot of other cases.

Maybe it would be simpler to store undef to the vptr immediately before calling the base class destructor, and let the LLVM optimization passes remove this vptr store as dead if it can prove the vptr is unused?

Thanks for the review and advice; I'll give undef a try. It's a much simpler approach.