[IR] Abstract away ArgNo+1 attribute indexing as much as possible
authorReid Kleckner <rnk@google.com>
Wed, 3 May 2017 18:17:31 +0000 (18:17 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 3 May 2017 18:17:31 +0000 (18:17 +0000)
commita0b45f4bfccb3ab197ca504032c28160ce82eac2
tree91fbb62cc8ff2350e9319c9d020f148632427bc7
parent2e23ce4cadeace53fd7de8c89d786f59108f378a
[IR] Abstract away ArgNo+1 attribute indexing as much as possible

Summary:
Do three things to help with that:
- Add AttributeList::FirstArgIndex, which is an enumerator currently set
  to 1. It allows us to change the indexing scheme with fewer changes.
- Add addParamAttr/removeParamAttr. This just shortens addAttribute call
  sites that would otherwise need to spell out FirstArgIndex.
- Remove some attribute-specific getters and setters from Function that
  take attribute list indices.  Most of these were only used from
  BuildLibCalls, and doesNotAlias was only used to test or set if the
  return value is malloc-like.

I'm happy to split the patch, but I think they are probably easier to
review when taken together.

This patch should be NFC, but it sets the stage to change the indexing
scheme to this, which is more convenient when indexing into an array:
  0: func attrs
  1: retattrs
  2...: arg attrs

Reviewers: chandlerc, pete, javed.absar

Subscribers: david2050, llvm-commits

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

llvm-svn: 302060
26 files changed:
clang/lib/CodeGen/CGObjCGNU.cpp
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/IR/CallSite.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/IR/Instructions.h
llvm/lib/Analysis/CFLGraph.h
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/AArch64/AArch64CallLowering.cpp
llvm/lib/Target/ARM/ARMCallLowering.cpp
llvm/lib/Target/X86/X86WinEHState.cpp
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
llvm/utils/TableGen/IntrinsicEmitter.cpp