[llvm] [MemProf][PGO] Prevent dropping of profile metadata during optimization (PR #121359)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 01:16:29 PST 2025
================
@@ -3379,6 +3379,10 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J,
K->setMetadata(Kind,
MDNode::getMostGenericAlignmentOrDereferenceable(JMD, KMD));
break;
+ case LLVMContext::MD_memprof:
+ case LLVMContext::MD_callsite:
+ // Preserve !memprof and !callsite metadata on K.
----------------
nikic wrote:
If it's not possible to correctly merge the metadata, we shouldn't include it in combineMetadata, as it will produce an incorrect result for the sink/hoist cases. It sounds like it would be sufficient for your case to only fix what MemCpyOptimizer does (to avoid merging for memprof/callsite in the first place). I'd rather not introduce incorrect merging logic in combineMetadata to cancel out incorrect code in MemCpyOptimizer...
https://github.com/llvm/llvm-project/pull/121359
More information about the llvm-commits
mailing list