[llvm-branch-commits] [llvm] [Metadata] Preserve MD_prof when merging instructions when one is missing. (PR #132433)

Snehasish Kumar via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Mar 30 14:08:56 PDT 2025


================
@@ -3436,6 +3433,16 @@ static void combineMetadata(Instruction *K, const Instruction *J,
     K->setMetadata(LLVMContext::MD_callsite,
                    MDNode::getMergedCallsiteMetadata(KCallSite, JCallSite));
   }
+
+  // Merge prof metadata.
+  // Handle separately to support cases where only one instruction has the
+  // metadata.
+  auto JProf = J->getMetadata(LLVMContext::MD_prof);
+  auto KProf = K->getMetadata(LLVMContext::MD_prof);
+  if (!AAOnly && (JProf || KProf)) {
----------------
snehasish wrote:

Removing the condition was intentional. In the case that `DoesKMove` is true, the merging of md_prof can be skipped if `J` does not have prof metadata (a minor optimization). I felt that it was simpler to just perform the merge regardless. Let me know if you feel otherwise.

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


More information about the llvm-branch-commits mailing list