[PATCH] D124115: [Attributes] Update Attribute::get API to consider zero value for int attributes

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 12:57:02 PDT 2022


nikic added a comment.

In D124115#3462890 <https://reviews.llvm.org/D124115#3462890>, @anna wrote:

>> The current approach leaves behind a footgun if we start actually using zero values for int attributes (something that we are careful not to do currently).
>
> I'm confused why we cannot have zero values for int attributes? The change here was to specifically allow zero values for any int attribute (because we have a downstream attribute where the value can be zero). 
> Is this a verifier issue - for example, we cannot have `derferenceable_or_null` with 0.

I don't think there is a strong technical reason for this restriction, it's just an artifact of the API design. For some int attributes we perform an encode/decode step to translate between a "raw value" (which is never zero) and a semantic value (which can be zero). I do think we should lift this restriction, though I'm not sure if just adjusting this one constructor will be sufficient.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124115/new/

https://reviews.llvm.org/D124115



More information about the llvm-commits mailing list