[all-commits] [llvm/llvm-project] 256976: [Attributes] Support int attributes with zero value

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Oct 11 01:46:49 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 256976774f6d41a6f851e5e1dd2da2fddad1377e
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-10-11 (Tue, 11 Oct 2022)

  Changed paths:
    M llvm/include/llvm/IR/Attributes.h
    M llvm/lib/IR/AttributeImpl.h
    M llvm/lib/IR/Attributes.cpp

  Log Message:
  [Attributes] Support int attributes with zero value

This regularly comes up as a stumbling stone when adding int
attributes: They currently need to be encoded in a way to avoids
the zero value.

This adds support for zero-value int attributes by a) making the
ctor determine int/enum attribute based on attribute kind, not
whether the value is non-zero and b) switching getRawIntAttr()
to return an Optional, so that it's possible to distinguish a zero
value from non-existence.

Differential Revision: https://reviews.llvm.org/D135572

More information about the All-commits mailing list