summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2014-08-02 23:41:54 +0000
committerManman Ren <manman.ren@gmail.com>2014-08-02 23:41:54 +0000
commit062f58d5507df9b38c75e204e6dd4e8eb487f1ab (patch)
tree1639eada83928038ab1a3617c06f73bb60b82f25 /llvm/lib
parent0670abdd2e712b6a5c3402cb2245ec305aa4431b (diff)
downloadbcm5719-llvm-062f58d5507df9b38c75e204e6dd4e8eb487f1ab.tar.gz
bcm5719-llvm-062f58d5507df9b38c75e204e6dd4e8eb487f1ab.zip
[SimplifyCFG] fix accessing deleted PHINodes in switch-to-table conversion.
When we have a covered lookup table, make sure we don't delete PHINodes that are cached in PHIs. rdar://17887153 llvm-svn: 214642
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 1c62559739f..63cb1c9abbf 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3830,7 +3830,10 @@ static bool SwitchToLookupTable(SwitchInst *SI,
const bool GeneratingCoveredLookupTable = MaxTableSize == TableSize;
if (GeneratingCoveredLookupTable) {
Builder.CreateBr(LookupBB);
- SI->getDefaultDest()->removePredecessor(SI->getParent());
+ // We cached PHINodes in PHIs, to avoid accessing deleted PHINodes later,
+ // do not delete PHINodes here.
+ SI->getDefaultDest()->removePredecessor(SI->getParent(),
+ true/*DontDeleteUselessPHIs*/);
} else {
Value *Cmp = Builder.CreateICmpULT(TableIndex, ConstantInt::get(
MinCaseVal->getType(), TableSize));
OpenPOWER on IntegriCloud