diff options
author | Freddy Ye <freddy.ye@intel.com> | 2024-08-29 08:44:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 08:44:22 +0800 |
commit | 3a5c5789662d50814e1867ac7c196dd7e7ac782c (patch) | |
tree | b84a82c06aff643315877b529d56c903a97cae1a /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | b75fe11fd6fe751157012a8881ece2f247bd3887 (diff) | |
download | llvm-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.cpp | 6 |
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); |