[llvm-branch-commits] [llvm] ba53f94 - [SimplifyCFG] Fix null pointer dereference in foldCondBranchOnValueKnownInPredecessorImpl (#178835)
Cullen Rhodes via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 2 00:57:24 PST 2026
Author: dianqk
Date: 2026-02-02T08:57:17Z
New Revision: ba53f94747b6d779161890214f9fe0aec8e6506b
URL: https://github.com/llvm/llvm-project/commit/ba53f94747b6d779161890214f9fe0aec8e6506b
DIFF: https://github.com/llvm/llvm-project/commit/ba53f94747b6d779161890214f9fe0aec8e6506b.diff
LOG: [SimplifyCFG] Fix null pointer dereference in foldCondBranchOnValueKnownInPredecessorImpl (#178835)
(cherry picked from commit 956770a9cb27d56cd04432be90f1241d3e932019)
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/jump-threading.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 3cb3018a70559..5f4807242581d 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3605,6 +3605,8 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
// Split the predecessors we are threading into a new edge block. We'll
// clone the instructions into this block, and then redirect it to RealDest.
BasicBlock *EdgeBB = SplitBlockPredecessors(BB, PredBBs, ".critedge", DTU);
+ if (!EdgeBB)
+ continue;
// TODO: These just exist to reduce test
diff , we can drop them if we like.
EdgeBB->setName(RealDest->getName() + ".critedge");
diff --git a/llvm/test/Transforms/SimplifyCFG/jump-threading.ll b/llvm/test/Transforms/SimplifyCFG/jump-threading.ll
index a4073ae6eb0b4..e99e351dc3df0 100644
--- a/llvm/test/Transforms/SimplifyCFG/jump-threading.ll
+++ b/llvm/test/Transforms/SimplifyCFG/jump-threading.ll
@@ -447,3 +447,44 @@ if.then:
if.end:
ret void
}
+
+define void @cleanuppad() personality ptr null {
+; CHECK-LABEL: @cleanuppad(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: invoke void @foo()
+; CHECK-NEXT: to label [[BB1:%.*]] unwind label [[CLEANUP:%.*]]
+; CHECK: cleanup:
+; CHECK-NEXT: [[C:%.*]] = phi i1 [ true, [[ENTRY:%.*]] ], [ false, [[BB1]] ]
+; CHECK-NEXT: [[CP:%.*]] = cleanuppad within none []
+; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[C]], true
+; CHECK-NEXT: call void @llvm.assume(i1 [[TMP0]])
+; CHECK-NEXT: cleanupret from [[CP]] unwind to caller
+; CHECK: bb1:
+; CHECK-NEXT: invoke void @bar()
+; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CLEANUP]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ invoke void @foo()
+ to label %bb1 unwind label %cleanup
+
+cleanup:
+ %c = phi i1 [ true, %entry ], [ false, %bb1 ]
+ %cp = cleanuppad within none []
+ br i1 %c, label %cleanup_2, label %cpret
+
+bb1:
+ invoke void @bar()
+ to label %exit unwind label %cleanup
+
+exit:
+ ret void
+
+cpret:
+ cleanupret from %cp unwind to caller
+
+cleanup_2:
+ store i1 false, ptr null, align 1
+ br label %cpret
+}
More information about the llvm-branch-commits
mailing list