This is an archive of the discontinued LLVM Phabricator instance.

Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap
ClosedPublic

Authored by mehdi_amini on Jan 16 2016, 11:07 PM.

Details

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.

Diff Detail

Event Timeline

mehdi_amini retitled this revision from to Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap.
mehdi_amini updated this object.
mehdi_amini added reviewers: dexonsmith, chandlerc.
mehdi_amini added a subscriber: llvm-commits.
dexonsmith edited edge metadata.Jan 18 2016, 1:43 PM
dexonsmith added a subscriber: dexonsmith.

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.

hfinkel accepted this revision.Feb 2 2016, 9:27 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

LGTM too.

This revision is now accepted and ready to land.Feb 2 2016, 9:27 PM
mehdi_amini closed this revision.Feb 10 2016, 3:14 PM

r260458.

I couldn't figure an easy way to merge the two keys, but I only tried to add the hash as an optional in a "tuple" (I guess it requires to expand to a custom class).