aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorFreddy Ye <freddy.ye@intel.com>2024-08-29 08:44:22 +0800
committerGitHub <noreply@github.com>2024-08-29 08:44:22 +0800
commit3a5c5789662d50814e1867ac7c196dd7e7ac782c (patch)
treeb84a82c06aff643315877b529d56c903a97cae1a /llvm/lib/CodeGen/CodeGenPrepare.cpp
parentb75fe11fd6fe751157012a8881ece2f247bd3887 (diff)
downloadllvm-3a5c5789662d50814e1867ac7c196dd7e7ac782c.zip
llvm-3a5c5789662d50814e1867ac7c196dd7e7ac782c.tar.gz
llvm-3a5c5789662d50814e1867ac7c196dd7e7ac782c.tar.bz2
[MachineLoopInfo] Fix getLoopID to handle multi latches. (#106195)
This patch also fixed `CodegenPrepare` to preserve loop metadata when merging blocks. This fixes issue #102632
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index bf48c1f..da6c758 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1183,6 +1183,12 @@ void CodeGenPrepare::eliminateMostlyEmptyBlock(BasicBlock *BB) {
}
}
+ // Preserve loop Metadata.
+ if (BI->hasMetadata(LLVMContext::MD_loop)) {
+ for (auto *Pred : predecessors(BB))
+ Pred->getTerminator()->copyMetadata(*BI, LLVMContext::MD_loop);
+ }
+
// The PHIs are now updated, change everything that refers to BB to use
// DestBB and remove BB.
BB->replaceAllUsesWith(DestBB);