From a10e89f372220a579faac02a1e4bdb0393b878a7 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 17 Aug 2009 17:00:57 +0000 Subject: [PATCH] Don't crash on critical edge. Patch by Andre Tavares. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79252 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/SSI.cpp | 2 +- test/Transforms/SSI/2009-08-17-CritEdge.ll | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/SSI/2009-08-17-CritEdge.ll diff --git a/lib/Transforms/Utils/SSI.cpp b/lib/Transforms/Utils/SSI.cpp index 7736f087684..7bb9495f3cf 100644 --- a/lib/Transforms/Utils/SSI.cpp +++ b/lib/Transforms/Utils/SSI.cpp @@ -95,7 +95,7 @@ void SSI::insertSigmaFunctions(SmallVectorImpl &value) { // Next Basic Block BasicBlock *BB_next = TI->getSuccessor(j); if (BB_next != BB && - BB_next->getUniquePredecessor() != NULL && + BB_next->getSinglePredecessor() != NULL && dominateAny(BB_next, value[i])) { PHINode *PN = PHINode::Create( value[i]->getType(), SSI_SIG, BB_next->begin()); diff --git a/test/Transforms/SSI/2009-08-17-CritEdge.ll b/test/Transforms/SSI/2009-08-17-CritEdge.ll new file mode 100644 index 00000000000..e5d1183dab0 --- /dev/null +++ b/test/Transforms/SSI/2009-08-17-CritEdge.ll @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | opt -abcd -disable-output + +define void @test(i32 %x) { +entry: + br label %label1 +label1: + %A = phi i32 [ 0, %entry ], [ %A.1, %label2 ] + %B = icmp slt i32 %A, %x + br i1 %B, label %label2, label %label2 +label2: + %A.1 = add i32 %A, 1 + br label %label1 +label3: ; No predecessors! + ret void +}