[PATCH] D108614: [NFC] Rename attribute methods that work with indexes

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 10:02:35 PDT 2021


aeubanks created this revision.
Herald added subscribers: ormris, dexonsmith, okura, jdoerfert, kuter, arphaman, hiraditya.
aeubanks updated this revision to Diff 368379.
aeubanks added a comment.
aeubanks added a reviewer: rnk.
aeubanks published this revision for review.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

update


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108614

Files:
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/ValueMapper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108614.368379.patch
Type: text/x-patch
Size: 41488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210824/b856a1ba/attachment-0001.bin>


More information about the llvm-commits mailing list