[all-commits] [llvm/llvm-project] 85b732: [NFC] Remove some unclear attribute methods

aeubanks via All-commits all-commits at lists.llvm.org
Thu Sep 2 12:48:18 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 85b732b55903be80a2fc0b9eb6abb7de4a931430
      https://github.com/llvm/llvm-project/commit/85b732b55903be80a2fc0b9eb6abb7de4a931430
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2021-09-02 (Thu, 02 Sep 2021)

  Changed paths:
    M llvm/include/llvm/IR/Attributes.h
    M llvm/include/llvm/IR/Function.h
    M llvm/include/llvm/IR/InstrTypes.h

  Log Message:
  -----------
  [NFC] Remove some unclear attribute methods

To any downstream users broken by this change, please examine your uses
of these methods and see if you can use a better method. For example,
getAttribute(AttributeList::FunctionIndex) => getFnAttr(), or
addAttribute(AttributeList::FirstArgIndex + ArgNo) =>
addParamAttribute(ArgNo). 0 corresponds to ReturnIndex, ~0 corresponds
to FunctionIndex. This may make future cleanups less painful.

I've made the mistake of assuming that these indexes are for parameters
multiple times, but actually they're based off of a weird indexing
scheme AttributeList::AttrIndex where 0 is the return value and ~0 is
the function. Hopefully renaming these methods will make this clearer.
Ideally users should use more specific methods like
AttributeList::getFnAttr().

This touches all relevant methods in AttributeList, CallBase, and Function.

This hopefully will make easier a future change to cleanup AttrIndex. A
previous worry about cleaning up AttrIndex was that too many downstream
users would have to look through all uses of AttrIndex and relevant
attribute method calls to see if anything was unintentionally hardcoded
(e.g. using 0 instead of ReturnIndex). With this change hopefully
downstream users will look at existing usages of these methods and clean
them up.

Reviewed By: rnk, MaskRay

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




More information about the All-commits mailing list