This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Move generated *Attr class methods out of line
ClosedPublic

Authored by rnk on Mar 11 2020, 7:53 PM.

Details

Summary

After this change, clang spends ~200ms parsing Attrs.inc instead of
~560ms. A large part of the cost was from the StringSwitch
instantiations, but this is a good way to avoid similar problems in the
future.

Diff Detail

Event Timeline

rnk created this revision.Mar 11 2020, 7:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2020, 7:53 PM

Are there any classes of methods which are worth continuing to generate inline? Surely some of the accessors are trivial.

rnk marked an inline comment as done.Mar 11 2020, 9:27 PM

The main things going out of line are:

  • Create* factory methods
  • Constructors
  • Enum/string converters (use StringSwitch -> slow to instantiate)

Here's two examples from before & after:
https://reviews.llvm.org/P8203
https://reviews.llvm.org/P8204

The constructors and factory methods *could* be trivial, but some of them are quite complex.

clang/utils/TableGen/ClangAttrEmitter.cpp
269

Most trivial accessors are still defined inline, like here. I think there's only one override of writeAccesorDefinitions.

rjmccall accepted this revision.Mar 11 2020, 10:11 PM

Okay, thanks. LGTM.

This revision is now accepted and ready to land.Mar 11 2020, 10:11 PM
aaron.ballman accepted this revision.Mar 12 2020, 4:35 AM

LGTM as well, though please run clang-format over the patch (some of the formatting looks to have gone weird in places).

rnk added a comment.Mar 12 2020, 8:52 AM

LGTM as well, though please run clang-format over the patch (some of the formatting looks to have gone weird in places).

Thanks, done. I undid some of its more questionable reformattings in writeCtorBody where the original formatting more clearly shows the generated code.

This revision was automatically updated to reflect the committed changes.