diff options
| author | Reid Kleckner <rnk@google.com> | 2017-04-13 00:58:09 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2017-04-13 00:58:09 +0000 |
| commit | 7f72033e1cde7a3a76da8c79634dfb7bf4919b54 (patch) | |
| tree | 91cd8b6c041464464cf122c8b204588149e44536 /llvm/lib/Transforms/InstCombine | |
| parent | 4104cf8257717c068622383441ee37bacaa1b74a (diff) | |
| download | bcm5719-llvm-7f72033e1cde7a3a76da8c79634dfb7bf4919b54.tar.gz bcm5719-llvm-7f72033e1cde7a3a76da8c79634dfb7bf4919b54.zip | |
[IR] Take func, ret, and arg attrs separately in AttributeList::get
This seems like a much more natural API, based on Derek Schuff's
comments on r300015. It further hides the implementation detail of
AttributeList that function attributes come last and appear at index
~0U, which is easy for the user to screw up. git diff says it saves code
as well: 97 insertions(+), 137 deletions(-)
This also makes it easier to change the implementation, which I want to
do next.
llvm-svn: 300153
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index cdae9571851..814f5933a58 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4232,16 +4232,13 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS, if (NestTy) { Instruction *Caller = CS.getInstruction(); std::vector<Value*> NewArgs; - std::vector<AttributeSet> NewAttrs; + std::vector<AttributeSet> NewArgAttrs; NewArgs.reserve(CS.arg_size() + 1); - NewAttrs.reserve(CS.arg_size() + 2); + NewArgAttrs.reserve(CS.arg_size()); // Insert the nest argument into the call argument list, which may // mean appending it. Likewise for attributes. - // Add any result attributes. - NewAttrs.push_back(Attrs.getRetAttributes()); - { unsigned Idx = 1; CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); @@ -4252,7 +4249,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS, if (NestVal->getType() != NestTy) NestVal = Builder->CreateBitCast(NestVal, NestTy, "nest"); NewArgs.push_back(NestVal); - NewAttrs.push_back(NestAttr); + NewArgAttrs.push_back(NestAttr); } if (I == E) @@ -4260,16 +4257,13 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS, // Add the original argument and attributes. NewArgs.push_back(*I); - NewAttrs.push_back(Attrs.getParamAttributes(Idx)); + NewArgAttrs.push_back(Attrs.getParamAttributes(Idx)); ++Idx; ++I; } while (true); } - // Add any function attributes. - NewAttrs.push_back(Attrs.getFnAttributes()); - // The trampoline may have been bitcast to a bogus type (FTy). // Handle this by synthesizing a new function type, equal to FTy // with the chain parameter inserted. @@ -4308,7 +4302,9 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS, NestF->getType() == PointerType::getUnqual(NewFTy) ? NestF : ConstantExpr::getBitCast(NestF, PointerType::getUnqual(NewFTy)); - AttributeList NewPAL = AttributeList::get(FTy->getContext(), NewAttrs); + AttributeList NewPAL = + AttributeList::get(FTy->getContext(), Attrs.getFnAttributes(), + Attrs.getRetAttributes(), NewArgAttrs); SmallVector<OperandBundleDef, 1> OpBundles; CS.getOperandBundlesAsDefs(OpBundles); |

