diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-15 13:53:02 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-15 14:27:48 -0800 |
commit | ceaf0110ff5e0c2de1f03d65d13703d34d0d5737 (patch) | |
tree | a259e61a6b0031387d21b57a03664649a5ad5bf9 /llvm/lib/Transforms/Utils/Debugify.cpp | |
parent | ceb3cdccd0fb597659147e0f538fdee91414541e (diff) | |
download | llvm-ceaf0110ff5e0c2de1f03d65d13703d34d0d5737.zip llvm-ceaf0110ff5e0c2de1f03d65d13703d34d0d5737.tar.gz llvm-ceaf0110ff5e0c2de1f03d65d13703d34d0d5737.tar.bz2 |
Revert "Revert "ADT: Fix reference invalidation in SmallVector...""
This reverts commit 33be50daa9ce1074c3b423a4ab27c70c0722113a,
effectively reapplying:
- 260a856c2abcef49c7cb3bdcd999701db3e2af38
- 3043e5a5c33c4c871f4a1dfd621a8839f9a1f0b3
- 49142991a685bd427d7e877c29c77371dfb7634c
... with a fix to skip a call to `SmallVector::isReferenceToStorage()`
when we know the parameter had been taken by value for small, POD-like
`T`. See https://reviews.llvm.org/D93779 for the discussion on the
revert.
At a high-level, these commits fix reference invalidation in
SmallVector's push_back, append, insert (one or N), and resize
operations. For more details, please see the original commit messages.
This commit fixes a bug that crept into
`SmallVectorTemplateCommon::reserveForAndGetAddress()` during the review
process after performance analysis was done. That function is now called
`reserveForParamAndGetAddress()`, clarifying that it only works for
parameter values. It uses that knowledge to bypass
`SmallVector::isReferenceToStorage()` when `TakesParamByValue`. This is
`constexpr` and avoids adding overhead for "small enough", trivially
copyable `T`.
Performance could potentially be tuned further by increasing the
threshold for `TakesParamByValue`, which is currently defined as:
```
bool TakesParamByValue = sizeof(T) <= 2 * sizeof(void *);
```
in the POD-like version of SmallVectorTemplateBase (else, `false`).
Differential Revision: https://reviews.llvm.org/D94800
Diffstat (limited to 'llvm/lib/Transforms/Utils/Debugify.cpp')
0 files changed, 0 insertions, 0 deletions