[llvm] [MemProf][PGO] Prevent dropping of profile metadata during optimization (PR #121359)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 30 15:05:39 PST 2024
teresajohnson wrote:
> > @nikic curious for your thoughts on combineMetadata - it seems really fragile to new types of metadata, or new invocations such as in the case of the MemCpyOpt callsite, making it very easy to silently lose metadata (even !prof metadata was affected in one case I saw in real code). Is there a better way to do this?
>
> combineMetadata is typically used via combineMetadataForCSE, and both should be updated together.
>
> The usage in MemCpyOptimizer is quite unusual, as what we do there is not real CSE or instruction merging, so combineMetadata is not the best fit. That case needs to intersect AA attributes, but could keep all the non-AA/memory attributes of the original call. We don't have a great API to represent that use-case.
>
> The only other usage in InstCombine looks like it should just be using combineMetadataForCSE instead of maintaining its own metadata list.
I agree - @DianQK can you change MemCpyOptimizer to intersect the AA attributes without calling combineMetadata? Once that is done it should be straightforward to change the call from InstCombine to use combineMetadataForCSE, at which point combineMetadata should likely be just inlined into combineMetadataForCSE to prevent its use from expanding.
https://github.com/llvm/llvm-project/pull/121359
More information about the llvm-commits
mailing list