This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profdata] Use std::unordered_map in SampleProfileMap
ClosedPublic

Authored by huangjd on Aug 28 2023, 1:33 PM.

Details

Summary

Patch D147740 Change back to std::unordered_map for SampleProfileMap because it has reference validity, the change to use llvm::DenseMap is moved to a different patch.

Diff Detail

Event Timeline

huangjd created this revision.Aug 28 2023, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 1:33 PM
huangjd requested review of this revision.Aug 28 2023, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 1:33 PM
wenlei accepted this revision.Aug 28 2023, 1:48 PM

lgtm with nits. thanks.

llvm/include/llvm/ADT/Hashing.h
687–688

Given this is only used by HashKeyMap and not really meant to enable general conversion from llvm hash to std hash, consider move it to SampleProf.h right above SampleProfileMap.

689

nit: Obj -> Val

This revision is now accepted and ready to land.Aug 28 2023, 1:48 PM
huangjd added inline comments.Aug 28 2023, 2:10 PM
llvm/include/llvm/ADT/Hashing.h
687–688

This can be problematic, if llvm::hash_code is being used in std::unordered_map somewhere else and the user defines std::hash<llvm::hash_code> locally, it will cause multiple definition of a class if the header somehow get included.

ayermolo accepted this revision.Aug 28 2023, 2:36 PM

Tried locally to confirm and build of a module succeeds.
Thank you for fixing it.

huangjd updated this revision to Diff 554076.Aug 28 2023, 3:30 PM

Coding style update

This revision was landed with ongoing or failed builds.Aug 28 2023, 3:32 PM
This revision was automatically updated to reflect the committed changes.