@@ -3355,10 +3355,9 @@ static void combineMetadata(Instruction *K, const Instruction *J,
33553355 case LLVMContext::MD_invariant_group:
33563356 // Preserve !invariant.group in K.
33573357 break ;
3358- // Keep empty cases for prof, mmra, memprof, and callsite to prevent them
3359- // from being removed as unknown metadata. The actual merging is handled
3358+ // Keep empty cases for mmra, memprof, and callsite to prevent them from
3359+ // being removed as unknown metadata. The actual merging is handled
33603360 // separately below.
3361- case LLVMContext::MD_prof:
33623361 case LLVMContext::MD_mmra:
33633362 case LLVMContext::MD_memprof:
33643363 case LLVMContext::MD_callsite:
@@ -3387,6 +3386,10 @@ static void combineMetadata(Instruction *K, const Instruction *J,
33873386 if (!AAOnly)
33883387 K->setMetadata (Kind, JMD);
33893388 break ;
3389+ case LLVMContext::MD_prof:
3390+ if (!AAOnly && DoesKMove)
3391+ K->setMetadata (Kind, MDNode::getMergedProfMetadata (KMD, JMD, K, J));
3392+ break ;
33903393 case LLVMContext::MD_noalias_addrspace:
33913394 if (DoesKMove)
33923395 K->setMetadata (Kind,
@@ -3433,16 +3436,6 @@ static void combineMetadata(Instruction *K, const Instruction *J,
34333436 K->setMetadata (LLVMContext::MD_callsite,
34343437 MDNode::getMergedCallsiteMetadata (KCallSite, JCallSite));
34353438 }
3436-
3437- // Merge prof metadata.
3438- // Handle separately to support cases where only one instruction has the
3439- // metadata.
3440- auto *JProf = J->getMetadata (LLVMContext::MD_prof);
3441- auto *KProf = K->getMetadata (LLVMContext::MD_prof);
3442- if (!AAOnly && (JProf || KProf)) {
3443- K->setMetadata (LLVMContext::MD_prof,
3444- MDNode::getMergedProfMetadata (KProf, JProf, K, J));
3445- }
34463439}
34473440
34483441void llvm::combineMetadataForCSE (Instruction *K, const Instruction *J,
0 commit comments