llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 956770a9cb27d56cd04432be90f1241d3e932019

Requested by: @<!-- -->dianqk

---
Full diff: https://github.com/llvm/llvm-project/pull/178857.diff


2 Files Affected:

- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+2) 
- (modified) llvm/test/Transforms/SimplifyCFG/jump-threading.ll (+41) 


``````````diff
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
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/178857
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to