-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MachineLoopInfo] Fix getLoopID to handle multi latches. #106195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This patch also fixed CodegenPrepare to reserve loop metadata when merging blocks. This fixes issue llvm#102632
0cf06ae
to
b52dc77
Compare
@llvm/pr-subscribers-backend-x86 Author: Freddy Ye (FreddyLeaf) ChangesThis patch also fixed CodegenPrepare to reserve loop metadata when merging blocks. This fixes issue #102632 Full diff: https://github.com/llvm/llvm-project/pull/106195.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index bf48c1fdab0ff0..c63a265fe27789 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1183,6 +1183,12 @@ void CodeGenPrepare::eliminateMostlyEmptyBlock(BasicBlock *BB) {
}
}
+ // Reserve 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);
diff --git a/llvm/lib/CodeGen/MachineLoopInfo.cpp b/llvm/lib/CodeGen/MachineLoopInfo.cpp
index 88ba10fbe29a91..b82b41fac662d7 100644
--- a/llvm/lib/CodeGen/MachineLoopInfo.cpp
+++ b/llvm/lib/CodeGen/MachineLoopInfo.cpp
@@ -211,8 +211,6 @@ MDNode *MachineLoop::getLoopID() const {
break;
}
}
- if (!MD)
- return nullptr;
if (!LoopID)
LoopID = MD;
else if (MD != LoopID)
diff --git a/llvm/test/CodeGen/X86/code-align-loops.ll b/llvm/test/CodeGen/X86/code-align-loops.ll
index 616478993a51da..40ad3b4c8d600e 100644
--- a/llvm/test/CodeGen/X86/code-align-loops.ll
+++ b/llvm/test/CodeGen/X86/code-align-loops.ll
@@ -111,7 +111,7 @@ for.body5: ; preds = %for.body, %for.body
; }
; }
; CHECK-LABEL: test3_multilatch:
-; ALIGN: .p2align 4, 0x90
+; ALIGN: .p2align 6, 0x90
; ALIGN-NEXT: .LBB2_1: # %while.cond
define dso_local i32 @test3_multilatch() #0 {
entry:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. The metadata transportation seems to work now. Just one remark about an edge case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thanks!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/3071 Here is the relevant piece of the build log for the reference
|
This patch also fixed
CodegenPrepare
to preserve loop metadata when merging blocks.This fixes issue #102632