This is an archive of the discontinued LLVM Phabricator instance.

Reimplement mlir::Identifier to be a wrapper around 'StringMapEntry*' instead of a wrapper around a 'const char*'. This makes it so strref() can be computed without calling strlen, which is more efficient and less error-prone. While here...
ClosedPublic

Authored by lattner on Apr 12 2020, 10:15 PM.

Details

Summary

..., reimplement DenseMapInfo<mlir::Identifier>::getHashValue in terms of mlir::hash_value(Identifier).

Both of these improvements were suggested by River, thanks!

Diff Detail

Event Timeline

lattner created this revision.Apr 12 2020, 10:15 PM
Herald added a project: Restricted Project. · View Herald Transcript
rriddle accepted this revision.Apr 12 2020, 10:41 PM

Thanks, looks much better now.

mlir/include/mlir/IR/Identifier.h
94

nit: Can we change this to arg.getAsOpaquePointer() to avoid the pointer arithmetic of getKeyData.

This revision is now accepted and ready to land.Apr 12 2020, 10:41 PM
rriddle added inline comments.Apr 12 2020, 10:56 PM
mlir/include/mlir/IR/Identifier.h
84–85

Can you also fix these while you are at it? These should really just be inline operators that compare the entry.

84–85

(By inline I mean in the class)

lattner marked 3 inline comments as done.Apr 13 2020, 8:49 AM
lattner added inline comments.
mlir/include/mlir/IR/Identifier.h
84–85

I changed these to compare the entry, and moved the Id/Id versions inline. However, we can't move the StringRef versions inline splitting the equality operators into two groups.

I think both are fine, but please give me an a +1 that this is what you wanted.

Incidentally, the is() method should go away now. I can take care of that cleanup in a separate patch.

lattner updated this revision to Diff 256995.Apr 13 2020, 8:50 AM

Tidy up some things River requested.

rriddle added inline comments.Apr 13 2020, 10:16 AM
mlir/include/mlir/IR/Identifier.h
84–85

Yeah, that's what I meant. +1 thanks.

rriddle marked an inline comment as done.Apr 13 2020, 10:17 AM
rriddle added inline comments.
mlir/include/mlir/IR/Identifier.h
84–85

(i.e. what you have looks good to me. I only meant the Identifier, Identifier ones)

This revision was automatically updated to reflect the committed changes.