This is an archive of the discontinued LLVM Phabricator instance.

[clang][AST] avoid unnecessary FunctionProtoTypes.FindNodeOrInsertPos call
Needs ReviewPublic

Authored by troyj on Oct 24 2022, 11:57 AM.

Details

Reviewers
bruno
Summary

getFunctionTypeInternal forms a FoldingSetNodeID and then calls FunctionProtoTypes.FindNodeOrInsertPos(). Later, upon returning from recursion, it calls FunctionProtoTypes.FindNodeOrInsertPos() again with the same ID. This second call will yield the same InsertPos unless the recursion caused FunctionProtoTypes to rebucket. The rebucketing can be detected by comparing the capacity of the set before and after the recursion, which allows us to skip the redundant call.

Diff Detail

Event Timeline

troyj created this revision.Oct 24 2022, 11:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2022, 11:57 AM
troyj requested review of this revision.Oct 24 2022, 11:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2022, 11:57 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Nice catch, thanks for improving this.

Any chance you've got any small enough example that trigger this that could be transformed into a testcase? It would be nice to have a unittest for this, see others in clang/unittests/AST.

Nitpick: please capitalize avoid in the title.