diff options
author | Michael Liao <michael.liao@intel.com> | 2015-03-17 18:03:10 +0000 |
---|---|---|
committer | Michael Liao <michael.liao@intel.com> | 2015-03-17 18:03:10 +0000 |
commit | 24fcae8fa03ee609d2f8e65b028a6198ba2a2411 (patch) | |
tree | 37d62194489fccb89beeda0720e533940ba240f5 /llvm/lib/Transforms/Utils/LowerSwitch.cpp | |
parent | 3aecd1807d7ae8fbf96232911a48408e23d75ebc (diff) | |
download | bcm5719-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.cpp | 7 |
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); } } |