This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Add a SFINAE template parameter to DenseMapInfo
ClosedPublic

Authored by rriddle on Nov 10 2021, 7:13 PM.

Details

Summary

This allows for using SFINAE partial specialization for DenseMapInfo.
In MLIR, this is particularly useful as it will allow for defining partial
specializations that support all Attribute, Op, and Type classes without
needing to specialize DenseMapInfo for each individual class.

Fixes PR49815

Diff Detail

Event Timeline

rriddle created this revision.Nov 10 2021, 7:13 PM
rriddle requested review of this revision.Nov 10 2021, 7:13 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptNov 10 2021, 7:13 PM

Given the new template parameter, I needed to update the forward declarations. Some of them already had DenseMapInfo from an include, so I just dropped them. Some didn't, so I opted to just add an include for DenseMapInfo (seemed small enough). I could avoid the includes by adding an explicit void for the second template parameter. Let me know if there is a preference.

rriddle edited the summary of this revision. (Show Details)Nov 10 2021, 7:25 PM
bondhugula added inline comments.
llvm/include/llvm/ADT/DenseMapInfo.h
48

A code comment here?

silvas accepted this revision.Nov 11 2021, 11:14 AM

Nice :) This looks pretty straightforward, but given how core this is, wait for another approver or two.

llvm/include/llvm/ADT/DenseMapInfo.h
48

+1. Is there a doc that needs to be updated too? We should update the source of truth is for "here's how to use DenseMapInfo", if such documentation even exists :)

This revision is now accepted and ready to land.Nov 11 2021, 11:14 AM
lattner accepted this revision.Nov 11 2021, 1:24 PM

Nice, I'm very excited about this - this will allow a lot of cleanups. Thank you for doing this!

llvm/include/llvm/ADT/Hashing.h
59

Is there a way to keep the forward declarations references here instead of #include? DenseMapInfo.h pulls in a ton of stuff including <utility> and <tuple>

rriddle added inline comments.Nov 11 2021, 2:49 PM
llvm/include/llvm/ADT/Hashing.h
59

I mentioned it in a comment. If we don't want the includes, we'll need to sprinkle void everywhere that we specialize the template. (I don't have a preference either way)

I think a few void's probably won't hurt anyone?

Oh, are you concerned about staging this in? If you want to stage it (add the includes now, remove them later or something), that is totally fine with me. Maybe I don't understand the impact correctly.

rriddle updated this revision to Diff 387386.Nov 15 2021, 1:36 PM

resolve comments

Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2021, 1:36 PM
rriddle marked 3 inline comments as done.Nov 15 2021, 1:37 PM
This revision was landed with ongoing or failed builds.Nov 16 2021, 10:54 AM
This revision was automatically updated to reflect the committed changes.