This patch replaces all uses of std::vector with llvm::SmallVector in the flang-omp-report plugin.
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM, wait for another review though
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | just putting this here as a note (this should be done in a separate patch): |
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | You can use std::unordered_map here instead. |
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | Use of std::unordered_map is highly discouraged in llvm because it has portability issues across implementations. See https://llvm.org/docs/ProgrammersManual.html#other-map-like-container-options for more details |
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | Unordered_set is discourage but not unordered_map. It is used widely in the code base |
@DavidTruby & @clementval , many thanks for your feedback! Just as an FYI, I suggested Josh to have one patch per ADT container. As a warm-up :) @josh.mottley.arm , I suggest incorporating feedback from David in Valentin in your next patch.
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | I'm not sure why unordered_set would be discouraged but not unordered_map, they're implemented the same way so would surely exhibit the same issues? The section of the manual I linked to specifically says to avoid that "hash map like" containers and then (I think erroneously) calls out unordered_set when I presume it means unordered_map. Perhaps that needs a fix in the manual? Regardless with a quick grep through llvm I don't see many uses of unordered_map outside of libcxx (which of course defines it), especially compared to uses of DenseMap. |
There are usage of unordered map elsewhere in the code than libcxx but if you want to go with DenseMap do whatever. It is just more complicated to put in place.
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | You probably read between the line because the section you linked does not says avoid hash map like container anywhere. It just mentions that the STL provides such containers.
|
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h | ||
---|---|---|
101 | I'm actually fairly sure this is a mistake in the guide, because this section is talking exclusively about maps and then starts talking about sets (which are covered in a separate section) for no apparent reason! That ambiguity should probably be taken up in a separate review. Regardless elsewhere we have the following :
Which seems to pretty clearly discourage either map or unordered_map in favour of DenseMap |
@DavidTruby & @clementval Just to let you know, got the map and string patches up for review now :)
just putting this here as a note (this should be done in a separate patch):
This std::map should probably be changed to an llvm::DenseMap or similar