From 1f95ef1815c9b6a961811ec78e44d14b277abdd3 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 13 Feb 2018 10:02:52 +0000 Subject: [LoopInterchange] Check number of latch successors before accessing them. In cases where the OuterMostLoopLatchBI only has a single successor, accessing the second successor will fail. This fixes a failure when building the test-suite with loop-interchange enabled. Reviewers: mcrosier, karthikthecool, davide Reviewed by: karthikthecool Differential Revision: https://reviews.llvm.org/D42906 llvm-svn: 324994 --- llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp index 8540f5ae30c..4cda6ed4b87 100644 --- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp @@ -541,7 +541,7 @@ struct LoopInterchange : public FunctionPass { BasicBlock *OuterMostLoopLatch = OuterMostLoop->getLoopLatch(); BranchInst *OuterMostLoopLatchBI = dyn_cast(OuterMostLoopLatch->getTerminator()); - if (!OuterMostLoopLatchBI) + if (!OuterMostLoopLatchBI || OuterMostLoopLatchBI->getNumSuccessors() != 2) return false; // Since we currently do not handle LCSSA PHI's any failure in loop -- cgit v1.2.3