This is an archive of the discontinued LLVM Phabricator instance.

Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.
ClosedPublic

Authored by sbenza on Sep 30 2014, 9:36 AM.

Details

Summary

This change introduces DynMatcherInterface and changes the internal
representation of DynTypedMatcher and Matcher<T> to use a generic
interface instead.
It removes unnecessary indirections and virtual function calls when
converting matchers by implicit and dynamic casts.
DynTypedMatcher now remembers the stricter type in the chain of casts
and checks it before calling into DynMatcherInterface.
This change improves our clang-tidy related benchmark by ~14%.
Also, it opens the door for more optimizations of this kind that are
coming in future changes.

As a side effect of removing these template instantiations, it also
speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the
number of
symbols generated by ~30%.

Diff Detail

Repository
rL LLVM

Event Timeline

sbenza updated this revision to Diff 14231.Sep 30 2014, 9:36 AM
sbenza retitled this revision from to Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts..
sbenza updated this object.
sbenza edited the test plan for this revision. (Show Details)
sbenza added a reviewer: klimek.
sbenza added a subscriber: Unknown Object (MLST).

The current snapshot is the revert of the revert. It does not include any fix yet.
This way is the fixes are easier to review.
I'll update when it is ready to review.

sbenza updated this revision to Diff 14233.Sep 30 2014, 9:41 AM

Use a static_assert() instead of an enable_if<>.
We don't need to disable for overloading, and the default template argument is not supported on all platforms yet.

sbenza updated this revision to Diff 14234.Sep 30 2014, 9:51 AM

Rename DynMatcherInterface::matches() to DynMatcherInterface::dynMatches() to prevent warnings from -Woverloaded-virtual.

I looked through the buildbot logs and I could only find these two problems.
I think this is ready now.

klimek edited edge metadata.Sep 30 2014, 11:14 AM

Feel free to resubmit whenever. Unless you really need a second pair of
eyes in it...

Is there a way to test with the buildbots before submitting?
There might be more errors from the MSVC build that I didn't get to see because the build stopped on the first one or something like that.

I usually resubmit and watch irc, where the bots announce breakages

sbenza closed this revision.Oct 1 2014, 8:18 AM
sbenza updated this revision to Diff 14285.

Closed by commit rL218769 (authored by @sbenza).