[PATCH] D135463: [FuncSpec] Do not generate multiple copies for identical specializations.
Momchil Velikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 08:45:27 PST 2022
chill added inline comments.
================
Comment at: llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h:82
-using CallSpecBinding = std::pair<CallBase *, SpecializationInfo>;
-// We are using MapVector because it guarantees deterministic iteration
-// order across executions.
-using SpecializationMap = SmallMapVector<CallBase *, SpecializationInfo, 8>;
+using UniqueSpecSet = std::set<SpecInfo, std::not_equal_to<SpecInfo>>;
----------------
labrinea wrote:
> chill wrote:
> > This has to be a `DenseSet`. `std::set` has logarithmic complexity of operations.
> DenseSet is more expensive to iterate on. I have another patch which sorts the specializations globally (across module, not per function) where I keep the specializations sorted in a std::multiset and I use std::merge to unite the two sets. That's relatively cheap as it doesn't perform copies of objects but shuffles pointers around. Also that multiset is iterated a lot more than the set I am adding here. The compexity is logarithmic to the number of callsites, still not a huge number in my opinion.
This should be a comparison function which induces strict weak ordering on the elements.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135463/new/
https://reviews.llvm.org/D135463
More information about the llvm-commits
mailing list