This is an archive of the discontinued LLVM Phabricator instance.

[clang][NFC] Optimize clang::ASTNodeKind::isBaseOf
ClosedPublic

Authored by PiotrZSL on Apr 29 2023, 7:42 AM.

Details

Summary

Create dedicated isBaseOf method without calculating
distance.

Tested on RISCVISelDAGToDAG.cpp with:
clang-tidy --checks=*,-bugprone-unchecked-optional-access

Amount of CPU cycles for isBaseOf reduced by ~15% (according to perf).

Diff Detail

Event Timeline

PiotrZSL created this revision.Apr 29 2023, 7:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2023, 7:42 AM
PiotrZSL requested review of this revision.Apr 29 2023, 7:42 AM
PiotrZSL added a comment.EditedApr 29 2023, 7:43 AM

Lookup matrix gives best result (~-80%), but it consume lot of memory due to big amount of enumerators (~950).

aaron.ballman accepted this revision.May 5 2023, 10:30 AM

Oh wow, I'm surprised that calculating the distance has that much compile time impact. Great catch! Please add NFC to the commit summary so folks know why there are no tests.

LGTM!

This revision is now accepted and ready to land.May 5 2023, 10:30 AM
PiotrZSL retitled this revision from [clang] Optimize clang::ASTNodeKind::isBaseOf to [clang][NFC] Optimize clang::ASTNodeKind::isBaseOf.May 5 2023, 10:40 AM
PiotrZSL updated this revision to Diff 520031.May 5 2023, 9:40 PM

Rebase without changes, just because some testcase in this baseline looks to fail.

This revision was landed with ongoing or failed builds.May 6 2023, 5:22 AM
This revision was automatically updated to reflect the committed changes.