[PATCH] D16268: Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 18 13:43:24 PST 2016


LGTM.  In the DenseMapInfo, it might be cleaner to store the hash
in the LookupKey as an Optional<unsigned> rather than creating a
third type that the DenseMapInfo understands, but I'm not sure.
Either way seems fine.

> On 2016-Jan-16, at 23:07, Mehdi AMINI <mehdi.amini at apple.com> wrote:
> 
> joker.eph created this revision.
> joker.eph added reviewers: dexonsmith, chandlerc.
> joker.eph added a subscriber: llvm-commits.
> 
> Just like the existing find_as() method, the new insert_as() accepts
> an extra parameter which is used as a key to find the bucket in the
> map.
> When creating a Constant, we want to check the map before actually
> creating the object. In this case we have to perform two queries to
> the map, and this extra parameter can save recomputing the hash value
> for the second query.
> 
> http://reviews.llvm.org/D16268
> 
> Files:
>  include/llvm/ADT/DenseMap.h
>  lib/IR/ConstantsContext.h
> 
> <D16268.45089.patch>



More information about the llvm-commits mailing list