[PATCH] D39593: [ADCE] Use MapVector for BlockInfo to make iteration order deterministic
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 06:05:36 PDT 2017
kuhar added inline comments.
================
Comment at: lib/Transforms/Scalar/ADCE.cpp:214
void AggressiveDeadCodeElimination::initialize() {
- auto NumBlocks = F.size();
-
- // We will have an entry in the map for each block so we grow the
- // structure to twice that size to keep the load factor low in the hash table.
- BlockInfo.reserve(NumBlocks);
size_t NumInsts = 0;
----------------
uabelho wrote:
> kuhar wrote:
> > I can see that MapVector doesn't expose `.reserve` -- what is the reason for that? While I don't claim that it would have any noticeable performance impact here, I'm a bit surprised by that.
> Unfortunately I have no idea. I just noticed there is no such function, and thus removed the call.
>
> I don't really understand the comment preceding the original reserve call though, it says "so we grow the structure to twice that size", but then it only reserves NumBlocks anyway? Not 2*Numblocks?
I think it was meant to be `.reserve(NumBlocks * 2)`, but it also makes sense to just reduce the number of allocations.
I looked at MapVector and it should very easy to add reserve to it. Then, I think it would make sense to keep it here, and to update the comment or size for whichever makes more sense.
https://reviews.llvm.org/D39593
More information about the llvm-commits
mailing list