From 790eb1c4901a7bd2e1d71f12ea0ad92167f3461b Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 29 Apr 2016 06:17:47 +0000 Subject: DivergenceAnalysis: Fix crash with unreachable blocks Unreachable blocks may not be in the dominator tree, so don't crash on them. llvm-svn: 268001 --- llvm/lib/Analysis/DivergenceAnalysis.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Analysis/DivergenceAnalysis.cpp') diff --git a/llvm/lib/Analysis/DivergenceAnalysis.cpp b/llvm/lib/Analysis/DivergenceAnalysis.cpp index b30539f3b31..d38725ff0ac 100644 --- a/llvm/lib/Analysis/DivergenceAnalysis.cpp +++ b/llvm/lib/Analysis/DivergenceAnalysis.cpp @@ -138,6 +138,11 @@ void DivergencePropagator::exploreSyncDependency(TerminatorInst *TI) { // a2 = 2; // a = phi(a1, a2); // sync dependent on (tid < 5) BasicBlock *ThisBB = TI->getParent(); + + // Unreachable blocks may not be in the dominator tree. + if (!DT.isReachableFromEntry(ThisBB)) + return; + BasicBlock *IPostDom = PDT.getNode(ThisBB)->getIDom()->getBlock(); if (IPostDom == nullptr) return; -- cgit v1.2.3