summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/LowerSwitch.cpp
diff options
context:
space:
mode:
authorMichael Liao <michael.liao@intel.com>2015-03-17 18:03:10 +0000
committerMichael Liao <michael.liao@intel.com>2015-03-17 18:03:10 +0000
commit24fcae8fa03ee609d2f8e65b028a6198ba2a2411 (patch)
tree37d62194489fccb89beeda0720e533940ba240f5 /llvm/lib/Transforms/Utils/LowerSwitch.cpp
parent3aecd1807d7ae8fbf96232911a48408e23d75ebc (diff)
downloadbcm5719-llvm-24fcae8fa03ee609d2f8e65b028a6198ba2a2411.tar.gz
bcm5719-llvm-24fcae8fa03ee609d2f8e65b028a6198ba2a2411.zip
[SwitchLowering] Remove incoming values in the reverse order
- To prevent invalidating *successive* indices. llvm-svn: 232510
Diffstat (limited to 'llvm/lib/Transforms/Utils/LowerSwitch.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LowerSwitch.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
index b3bdae47d94..7bfb3d9f4d4 100644
--- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
@@ -175,11 +175,16 @@ static void fixPhis(BasicBlock *SuccBB, BasicBlock *OrigBB, BasicBlock *NewBB,
// Remove additional occurences coming from condensed cases and keep the
// number of incoming values equal to the number of branches to SuccBB.
+ SmallVector<unsigned, 8> Indices;
for (++Idx; LocalNumMergedCases > 0 && Idx < E; ++Idx)
if (PN->getIncomingBlock(Idx) == OrigBB) {
- PN->removeIncomingValue(Idx);
+ Indices.push_back(Idx);
LocalNumMergedCases--;
}
+ // Remove incoming values in the reverse order to prevent invalidating
+ // *successive* index.
+ for (auto III = Indices.rbegin(), IIE = Indices.rend(); III != IIE; ++III)
+ PN->removeIncomingValue(*III);
}
}
OpenPOWER on IntegriCloud