@@ -3355,10 +3355,9 @@ static void combineMetadata(Instruction *K, const Instruction *J,
3355
3355
case LLVMContext::MD_invariant_group:
3356
3356
// Preserve !invariant.group in K.
3357
3357
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
3360
3360
// separately below.
3361
- case LLVMContext::MD_prof:
3362
3361
case LLVMContext::MD_mmra:
3363
3362
case LLVMContext::MD_memprof:
3364
3363
case LLVMContext::MD_callsite:
@@ -3387,6 +3386,10 @@ static void combineMetadata(Instruction *K, const Instruction *J,
3387
3386
if (!AAOnly)
3388
3387
K->setMetadata (Kind, JMD);
3389
3388
break ;
3389
+ case LLVMContext::MD_prof:
3390
+ if (!AAOnly && DoesKMove)
3391
+ K->setMetadata (Kind, MDNode::getMergedProfMetadata (KMD, JMD, K, J));
3392
+ break ;
3390
3393
case LLVMContext::MD_noalias_addrspace:
3391
3394
if (DoesKMove)
3392
3395
K->setMetadata (Kind,
@@ -3433,16 +3436,6 @@ static void combineMetadata(Instruction *K, const Instruction *J,
3433
3436
K->setMetadata (LLVMContext::MD_callsite,
3434
3437
MDNode::getMergedCallsiteMetadata (KCallSite, JCallSite));
3435
3438
}
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
- }
3446
3439
}
3447
3440
3448
3441
void llvm::combineMetadataForCSE (Instruction *K, const Instruction *J,
0 commit comments