[llvm] [MemProf][PGO] Prevent dropping of profile metadata during optimization (PR #121359)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 30 13:55:20 PST 2024


nikic 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.

https://github.com/llvm/llvm-project/pull/121359


More information about the llvm-commits mailing list