Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap
authorMehdi Amini <mehdi.amini@apple.com>
Wed, 10 Feb 2016 23:07:29 +0000 (23:07 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Wed, 10 Feb 2016 23:07:29 +0000 (23:07 +0000)
commit2476e0027e9b6bc3fe85c3438b864aa7da17b70d
tree84917662997e148b48b1eaceb64976effa7271db
parent222e6c52120a6282eea89341ef833c2b18e52c47
Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap

Summary:
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.

Reviewers: dexonsmith, chandlerc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D16268

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 260458
llvm/include/llvm/ADT/DenseMap.h
llvm/lib/IR/ConstantsContext.h