Skip to content

Commit 7f2abe8

Browse files
authored
Revert "[Metadata] Preserve MD_prof when merging instructions when one is missing." (#134200)
Reverts #132433 I suspect this change caused a failure in the bolt build bot. https://lab.llvm.org/buildbot/#/builders/113/builds/6621 ``` !9185 = !{!"branch_weights", i32 3912, i32 802} Wrong number of operands !9185 = !{!"branch_weights", i32 3912, i32 802} fatal error: error in backend: Broken module found, compilation aborted! ```
1 parent f404826 commit 7f2abe8

File tree

3 files changed

+6
-138
lines changed

3 files changed

+6
-138
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

34483441
void llvm::combineMetadataForCSE(Instruction *K, const Instruction *J,

llvm/test/Transforms/SimplifyCFG/merge-direct-call-branch-weights-preserve-hoist.ll

Lines changed: 0 additions & 62 deletions
This file was deleted.

llvm/test/Transforms/SimplifyCFG/merge-direct-call-branch-weights-preserve-sink.ll

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)