diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-06-07 16:13:49 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-06-07 16:13:49 +0000 |
commit | 47b0c0a9a0d920917e1fb10ac1c851c6e3b8aa27 (patch) | |
tree | 3345550d1366348cb9f8168c6c71b5bf6dc7ebd1 /lib | |
parent | 74f03455e5ee463a43a0f82efbd2fbd364e2cbda (diff) | |
download | external_llvm-47b0c0a9a0d920917e1fb10ac1c851c6e3b8aa27.zip external_llvm-47b0c0a9a0d920917e1fb10ac1c851c6e3b8aa27.tar.gz external_llvm-47b0c0a9a0d920917e1fb10ac1c851c6e3b8aa27.tar.bz2 |
R600: Fix a potential iterator invalidation issue.
As a bonus this reduces the loop from O(n^2) to O(n).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183532 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/R600/R600OptimizeVectorRegisters.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Target/R600/R600OptimizeVectorRegisters.cpp b/lib/Target/R600/R600OptimizeVectorRegisters.cpp index 9d237bb..0c123a1 100644 --- a/lib/Target/R600/R600OptimizeVectorRegisters.cpp +++ b/lib/Target/R600/R600OptimizeVectorRegisters.cpp @@ -198,11 +198,9 @@ MachineInstr *R600VectorRegMerger::RebuildVector( .addReg(SubReg) .addImm(Chan); UpdatedRegToChan[SubReg] = Chan; - for (std::vector<unsigned>::iterator RemoveIt = UpdatedUndef.begin(), - RemoveE = UpdatedUndef.end(); RemoveIt != RemoveE; ++ RemoveIt) { - if (*RemoveIt == Chan) - UpdatedUndef.erase(RemoveIt); - } + UpdatedUndef.erase( + std::remove(UpdatedUndef.begin(), UpdatedUndef.end(), Chan), + UpdatedUndef.end()); DEBUG(dbgs() << " ->"; Tmp->dump();); (void)Tmp; SrcVec = DstReg; |