This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Devirtualize calls to methods marked final in a derived class
ClosedPublic

Authored by vsk on Oct 19 2016, 10:42 PM.

Details

Summary

If we see a virtual method call to Base::foo() but can infer that the
object is an instance of Derived, and that 'foo' is marked 'final' in
Derived, we can devirtualize the call to Derived::foo().

Note: This patch introduces a check which depends on the result of
Base->getBestDynamicClassType(). Since this API can return nullptr, I
took the opportunity to defensively group together the checks which rely
on the result. I can drop this change, or try it in a separate commit if
that would be better.

Diff Detail

Repository
rL LLVM

Event Timeline

vsk updated this revision to Diff 75266.Oct 19 2016, 10:42 PM
vsk retitled this revision from to [CodeGen] Devirtualize calls to methods marked final in a derived class.
vsk updated this object.
vsk added reviewers: rjmccall, pcc.
vsk added a subscriber: cfe-commits.
rjmccall edited edge metadata.Oct 20 2016, 11:08 AM

Looks great to me, thanks.

This revision was automatically updated to reflect the committed changes.