[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:03:34 PST 2024


================
@@ -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.
----------------
teresajohnson wrote:

There isn't a great way to merge them at the moment, unfortunately. They encode information about the call context and it can't currently support multiple distinct call locations. For now we pick one. In the actual case I was looking at in real code this handling was invoked by the byval argument optimization in MemCpyOptimizer though, where we aren't even combining two calls, so this change just ensures it isn't dropped unnecessarily (as you note this probably isn't the best facility to use in that code anyway).

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


More information about the llvm-commits mailing list