This class is solely used as a lightweight and clean way to build a set of
attributes to be removed from an AttrBuilder. Previously AttrBuilder was used
both for building and removing, which introduced odd situation like creation of
Attribute with dummy value because the only relevant part was the attribute
kind.
Details
- Reviewers
nikic rnk aeubanks - Commits
- rG9290ccc3c1a1: Introduce the AttributeMask class
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Pre-merge checks also report a build failure in llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp:360.
llvm/include/llvm/IR/Attributes.h | ||
---|---|---|
1052 | I matched the implementation in AttrBuilder, which looks odd to me too. |
This looks good to me, but I'd recommend waiting a bit before landing in case there's further input, as this is a non-trivial API change.
I think separating AttrBuilder (which stores attribute keys and values) from AttributeMask (which only stores keys) makes sense conceptually. With the current API, it's not really obvious that the attribute values are completely ignored for removal operations -- on the surface it looks like the attribute would only get removed if both key and value match, but that's not how it actually works.
This should also give more flexibility in optimizing AttrBuilder for it's primary use case (which is adding attributes).
(Maybe valuable to start a quick thread on llvm-dev to get more eyes on this? (I'm not suggesting that's required, just pointing out the option...))
I think separating AttrBuilder (which stores attribute keys and values) from AttributeMask (which only stores keys) makes sense conceptually. With the current API, it's not really obvious that the attribute values are completely ignored for removal operations -- on the surface it looks like the attribute would only get removed if both key and value match, but that's not how it actually works.
This should also give more flexibility in optimizing AttrBuilder for it's primary use case (which is adding attributes).
FWIW, I agree that this approach seems good. (SGTM, not LGTM, only because I haven't reviewed the patch details.)
Looking at some of the changes here, I landed a couple of cleanup commits:
- https://github.com/llvm/llvm-project/commit/3b0f5a4856fce76a6535feddd1692747b81b60cd (this should fix the build failure)
- https://github.com/llvm/llvm-project/commit/e8e8bfeeb7233bde17d0a811b87d392271b33f42 (unnecessary AttrBuilder use for one attribute)
- https://github.com/llvm/llvm-project/commit/9f24f010abe6b9db3d3fd913805c9e0779d00334 (make RS4GC attribute removal more idiomatic)
I think the latter change should allow you to drop the AttrMask::hasAttributes() method from the API.
This assert doesn't make sense to me. AttributeMask doesn't accept arguments.