[PATCH] D91837: ADT: Fix reference invalidation in SmallVector APIs that pass in a value
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 19 18:14:33 PST 2020
dexonsmith created this revision.
dexonsmith added reviewers: mehdi_amini, njames93, silvas, dblaikie.
Herald added subscribers: ributzka, pengfei.
Herald added a project: LLVM.
dexonsmith requested review of this revision.
Fix reference invalidation in SmallVector APIs that pass in a `T`, taking it by value when it's small enough and trivially copyable, and doing a pointer-to-index-to-pointer dance otherwise.
This doesn't fix all possible reference invalidation, but if it avoids the compile-time regressions from https://reviews.llvm.org/D87326 (which does fix them all) it seems like a good incremental step. The mental model also seems more clear than https://reviews.llvm.org/D91467 (which only fixed invalidation for small enough, trivially copyable `T`).
I'm currently building a few variants of `clang` (matching how the patches are sequenced in my local tree (probably they should be committed separately so they can be reverted individually if necessary, but I figured it made more sense to start with a single Phab review)) to test effects on compile-time:
- baseline
- fix only `push_back` and single-element `insert` (tied together since `insert` uses `push_back)
- fix also N-element versions of `append` and `insert` (tied together since `insert` uses `append`)
- fix also `resize`
I'll start with compiling a "big" file a few times (in the other review I used llvm/lib/Target/X86/X86ISelLowering.cpp), but I'm happy to do more work if it seems prudent.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91837
Files:
llvm/include/llvm/ADT/SmallVector.h
llvm/unittests/ADT/SmallVectorTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91837.306575.patch
Type: text/x-patch
Size: 15932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201120/b7156e48/attachment.bin>
More information about the llvm-commits
mailing list