[PATCH] D65788: [ADT] Remove O(1) requirement to range passed to llvm::size

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 03:26:33 PDT 2019


MaskRay added a subscriber: vsk.
MaskRay added a comment.

In D65788#1616378 <https://reviews.llvm.org/D65788#1616378>, @jhenderson wrote:

> How many places use this and in what context? I'm conscious of std::size which becomes available in C++17, and the natural implementation of that is to simply use the standard .size() method on a container (see https://en.cppreference.com/w/cpp/iterator/size). It also does something else for fixed-sized arrays, but this particular version doesn't work for that. Finally, why do you need llvm::size() instead of a container.size() method?


My language server says there are 5 references:

https://github.com/llvm/llvm-project/blob/1177bc597d5f1bab4f4ed79b2fe88ae1d2461c39/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp#L138
https://github.com/llvm/llvm-project/blob/1177bc597d5f1bab4f4ed79b2fe88ae1d2461c39/llvm/lib/Analysis/LazyCallGraph.cpp#L1288
https://github.com/llvm/llvm-project/blob/1177bc597d5f1bab4f4ed79b2fe88ae1d2461c39/llvm/lib/Analysis/LazyCallGraph.cpp#L1754 (I'll delete this one)
https://github.com/llvm/llvm-project/blob/1177bc597d5f1bab4f4ed79b2fe88ae1d2461c39/llvm/lib/Analysis/LazyCallGraph.cpp#L1762 (I'll delete this one)
https://github.com/llvm/llvm-project/blob/1177bc597d5f1bab4f4ed79b2fe88ae1d2461c39/llvm/lib/Transforms/Scalar/GVNHoist.cpp#L580

After deleting the 2 references, the remaining 3 are all `iterator_range<T>`. is_splat, which calls size, has other 4 references.

CC @vsk who implemented llvm::size in D46976 <https://reviews.llvm.org/D46976>


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

https://reviews.llvm.org/D65788





More information about the llvm-commits mailing list