This is an archive of the discontinued LLVM Phabricator instance.

[clang][AST] make FunctionProtoType::Profile consistent for FoldingSet
Needs ReviewPublic

Authored by troyj on Oct 26 2022, 12:05 PM.

Details

Reviewers
bruno
Summary

This patch changes the Profile function to match the FunctionProtoType constructor, which uses epi.ExceptionSpec.SourceDecl and not epi.ExceptionSpec.SourceDecl->getCanonicalDecl(). This change eliminates an inconsistency that was observed within the FunctionProtoTypes set by adding a verification function to FoldingSet to assert that all items in the set still hash to their current bucket. Asserting this verification showed that some FunctionProtoTypes no longer hashed to their original bucket. This inconsistency was not catastrophic because of self-correction -- FoldingSet does not store hashes and recomputes them whenever it rebuckets. Thus, it's not possible to observe the issue immediately after rebucketing. Comparing the before and after profiles of a FunctionProtoType that was in the wrong bucket showed that the only part of the profile that changed was epi.ExceptionSpec.SourceDecl->getCanonicalDecl(). After changing the profile function to match the constructor, no incorrectly bucketed FunctionProtoTypes were observed in a TU with ~2.6M prototypes.

Diff Detail

Event Timeline

troyj created this revision.Oct 26 2022, 12:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 12:05 PM
troyj requested review of this revision.Oct 26 2022, 12:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 12:05 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript