[all-commits] [llvm/llvm-project] 42e88b: Replace sequences of v.push_back(v[i]); v.erase(&v...
Mehdi Amini via All-commits
all-commits at lists.llvm.org
Fri Nov 13 16:56:31 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 42e88bd6b18597fe0a46ee9663d4e2cf2f7a4e57
https://github.com/llvm/llvm-project/commit/42e88bd6b18597fe0a46ee9663d4e2cf2f7a4e57
Author: Mehdi Amini <joker.eph at gmail.com>
Date: 2020-11-14 (Sat, 14 Nov 2020)
Changed paths:
M clang/lib/CodeGen/CGBuiltin.cpp
Log Message:
-----------
Replace sequences of v.push_back(v[i]); v.erase(&v[i]); with std::rotate (NFC)
The code has a few sequence that looked like:
Ops.push_back(Ops[0]);
Ops.erase(Ops.begin());
And are equivalent to:
std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());
The latter has the advantage of never reallocating the vector, which
would be a bug in the original code as push_back would read from the
memory it deallocated.
Commit: 2c196bbc6bd897b3dcc1d87a3baac28e1e88df41
https://github.com/llvm/llvm-project/commit/2c196bbc6bd897b3dcc1d87a3baac28e1e88df41
Author: Mehdi Amini <joker.eph at gmail.com>
Date: 2020-11-14 (Sat, 14 Nov 2020)
Changed paths:
M llvm/include/llvm/ADT/SmallVector.h
M llvm/include/llvm/MC/MCInst.h
Log Message:
-----------
Add an assertion in SmallVector::push_back()
This assertion ensures the input value isn't part of the vector when
growing is required. In such cases the vector will grow and the input
value is invalidated before being read from.
This found 14 failed Tests.
Reviewed By: bkramer
Differential Revision: https://reviews.llvm.org/D84293
Compare: https://github.com/llvm/llvm-project/compare/703ef17e7a0a...2c196bbc6bd8
More information about the All-commits
mailing list