[PATCH] D94739: ADT: Fix reference invalidation in SmallVector::emplace_back and the size+value version of SmallVector::assign

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 08:18:51 PST 2021


dexonsmith planned changes to this revision.
dexonsmith added a comment.

Note that this is a follow-up to https://reviews.llvm.org/D91837 (and the patches split out from it), and an alternative implementation for https://reviews.llvm.org/D87326.

I still need to do compile-time measurements; feel free to delay review until then.

The main concern I have (without having run numbers) is POD-like version of `emplace_back` (which now calls `push_back`). For large `T` where `TakesParamByValue` is false, this is now making a copy and I could imagine a slowdown. The other primary option is for `emplace_back` to use a split grow operation, but then it won't be able to use `realloc()`... I suspect the copy is less bad than dropping the `realloc`.

Hmm... or I could update the POD-like `!TakesParamByValue` to only copy when growing (only when it's useful). Marking this as "Plan Changes" to try implementing that before collecting compile-time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94739/new/

https://reviews.llvm.org/D94739



More information about the llvm-commits mailing list