-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[VPlan] Add extra checks for LoopForBB. NFC. #132306
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
base: main
Are you sure you want to change the base?
Conversation
Adding the checks for LoopForBB not being nullptr before try to dereference it.
|
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-vectorizers Author: None (offsake) ChangesAdding the checks for LoopForBB not being nullptr before try to dereference it. Full diff: https://github.com/llvm/llvm-project/pull/132306.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
index 4b8a2420b3037..467c83395b812 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
@@ -379,7 +379,7 @@ void PlainCFGBuilder::buildPlainCFG(
VPRegionBlock *Region = VPBB->getParent();
Loop *LoopForBB = LI->getLoopFor(BB);
// Set VPBB predecessors in the same order as they are in the incoming BB.
- if (!isHeaderBB(BB, LoopForBB)) {
+ if (LoopForBB && !isHeaderBB(BB, LoopForBB)) {
setVPBBPredsFromBB(VPBB, BB);
} else if (Region) {
// BB is a loop header and there's a corresponding region, set the
@@ -390,7 +390,7 @@ void PlainCFGBuilder::buildPlainCFG(
// Create VPInstructions for BB.
createVPInstructionsForVPBB(VPBB, BB);
- if (BB == TheLoop->getLoopLatch()) {
+ if (LoopForBB && BB == TheLoop->getLoopLatch()) {
VPBasicBlock *HeaderVPBB = getOrCreateVPBB(LoopForBB->getHeader());
VPBlockUtils::connectBlocks(VPBB, HeaderVPBB);
continue;
@@ -423,7 +423,7 @@ void PlainCFGBuilder::buildPlainCFG(
BasicBlock *IRSucc1 = BI->getSuccessor(1);
VPBasicBlock *Successor0 = getOrCreateVPBB(IRSucc0);
VPBasicBlock *Successor1 = getOrCreateVPBB(IRSucc1);
- if (BB == LoopForBB->getLoopLatch()) {
+ if (LoopForBB && BB == LoopForBB->getLoopLatch()) {
// For a latch we need to set the successor of the region rather than that
// of VPBB and it should be set to the exit, i.e., non-header successor,
// except for the top region, which is handled elsewhere.
|
|
Hello @fhahn, |
fhahn
left a comment
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.
Could you adda test case showing the issue?
|
Hello @fhahn , LoopBlocksRPO RPO(TheLoop); code might guarantee that all visited blocks have an associated loop. It means that the check below is redundant, which I removed in the second commit. |
Adding the checks for LoopForBB not being nullptr before try to dereference it.