[PATCH] D87326: [ADT] Fix reference invalidation when self referencing a SmallVector

Nathan James via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 13:45:41 PDT 2020


njames93 created this revision.
njames93 added reviewers: lattner, chandlerc, dblaikie, bkramer.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.
njames93 requested review of this revision.

Fix issues when calling methods from SmallVector that insert or append an item already inside a SmallVector where by the reference is invalidated when the container grows.

For example `SmallVec.push_back(SmallVec[0])` If this call causes the vector to grow, SmallVec[0] will now be referencing invalid memory.
This also slightly speeds up SmallVec::Insert by only moving data after the insertion point once when the container grows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87326

Files:
  llvm/include/llvm/ADT/SmallVector.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87326.290575.patch
Type: text/x-patch
Size: 13284 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200908/5538e3e5/attachment.bin>


More information about the llvm-commits mailing list