diff options
author | Devang Patel <dpatel@apple.com> | 2008-09-25 21:00:45 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-09-25 21:00:45 +0000 |
commit | d222f86d9d51a2d6299d43fb876099869430bf0f (patch) | |
tree | 5a33037d52126e5eb635d76afe643d9b854694a1 /lib/Transforms | |
parent | 3829e8a0e4d29e43d934b78935c3e067db8ff195 (diff) | |
download | external_llvm-d222f86d9d51a2d6299d43fb876099869430bf0f.zip external_llvm-d222f86d9d51a2d6299d43fb876099869430bf0f.tar.gz external_llvm-d222f86d9d51a2d6299d43fb876099869430bf0f.tar.bz2 |
Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g
This sets the stage
- to implement function notes as function attributes and
- to distinguish between function attributes and return value attributes.
This requires corresponding changes in llvm-gcc and clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56622 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/AddReadAttrs.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/ArgumentPromotion.cpp | 44 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadArgumentElimination.cpp | 62 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineAlways.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/LowerSetJmp.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/PruneEH.cpp | 14 | ||||
-rw-r--r-- | lib/Transforms/IPO/StructRetPromotion.cpp | 36 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 64 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SimplifyCFGPass.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineCost.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerInvoke.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 4 |
17 files changed, 131 insertions, 131 deletions
diff --git a/lib/Transforms/IPO/AddReadAttrs.cpp b/lib/Transforms/IPO/AddReadAttrs.cpp index 8f7fd6e..4e0677b 100644 --- a/lib/Transforms/IPO/AddReadAttrs.cpp +++ b/lib/Transforms/IPO/AddReadAttrs.cpp @@ -105,10 +105,10 @@ bool AddReadAttrs::runOnSCC(const std::vector<CallGraphNode *> &SCC) { MadeChange = true; // Clear out any existing attributes. - F->removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone); + F->removeAttribute(0, Attribute::ReadOnly | Attribute::ReadNone); // Add in the new attribute. - F->addParamAttr(0, ReadsMemory ? ParamAttr::ReadOnly : ParamAttr::ReadNone); + F->addAttribute(0, ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone); if (ReadsMemory) NumReadOnly++; diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index d71ed94..fe6583e 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -144,7 +144,7 @@ bool ArgPromotion::PromoteArguments(CallGraphNode *CGN) { SmallPtrSet<Argument*, 8> ArgsToPromote; SmallPtrSet<Argument*, 8> ByValArgsToTransform; for (unsigned i = 0; i != PointerArgs.size(); ++i) { - bool isByVal = F->paramHasAttr(PointerArgs[i].second+1, ParamAttr::ByVal); + bool isByVal = F->paramHasAttr(PointerArgs[i].second+1, Attribute::ByVal); // If this is a byval argument, and if the aggregate type is small, just // pass the elements, which is always safe. @@ -501,15 +501,15 @@ Function *ArgPromotion::DoPromotion(Function *F, // what the new GEP/Load instructions we are inserting look like. std::map<IndicesVector, LoadInst*> OriginalLoads; - // ParamAttrs - Keep track of the parameter attributes for the arguments + // Attributes - Keep track of the parameter attributes for the arguments // that we are *not* promoting. For the ones that we do promote, the parameter // attributes are lost - SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec; - const PAListPtr &PAL = F->getParamAttrs(); + SmallVector<AttributeWithIndex, 8> AttributesVec; + const AttrListPtr &PAL = F->getAttributes(); // Add any return attributes. - if (Attributes attrs = PAL.getParamAttrs(0)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs)); + if (Attributes attrs = PAL.getAttributes(0)) + AttributesVec.push_back(AttributeWithIndex::get(0, attrs)); // First, determine the new argument list unsigned ArgIndex = 1; @@ -525,8 +525,8 @@ Function *ArgPromotion::DoPromotion(Function *F, } else if (!ArgsToPromote.count(I)) { // Unchanged argument Params.push_back(I->getType()); - if (Attributes attrs = PAL.getParamAttrs(ArgIndex)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(Params.size(), attrs)); + if (Attributes attrs = PAL.getAttributes(ArgIndex)) + AttributesVec.push_back(AttributeWithIndex::get(Params.size(), attrs)); } else if (I->use_empty()) { // Dead argument (which are always marked as promotable) ++NumArgumentsDead; @@ -597,8 +597,8 @@ Function *ArgPromotion::DoPromotion(Function *F, // Recompute the parameter attributes list based on the new arguments for // the function. - NF->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end())); - ParamAttrsVec.clear(); + NF->setAttributes(AttrListPtr::get(AttributesVec.begin(), AttributesVec.end())); + AttributesVec.clear(); F->getParent()->getFunctionList().insert(F, NF); NF->takeName(F); @@ -618,11 +618,11 @@ Function *ArgPromotion::DoPromotion(Function *F, while (!F->use_empty()) { CallSite CS = CallSite::get(F->use_back()); Instruction *Call = CS.getInstruction(); - const PAListPtr &CallPAL = CS.getParamAttrs(); + const AttrListPtr &CallPAL = CS.getAttributes(); // Add any return attributes. - if (Attributes attrs = CallPAL.getParamAttrs(0)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs)); + if (Attributes attrs = CallPAL.getAttributes(0)) + AttributesVec.push_back(AttributeWithIndex::get(0, attrs)); // Loop over the operands, inserting GEP and loads in the caller as // appropriate. @@ -633,8 +633,8 @@ Function *ArgPromotion::DoPromotion(Function *F, if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) { Args.push_back(*AI); // Unmodified argument - if (Attributes Attrs = CallPAL.getParamAttrs(ArgIndex)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs)); + if (Attributes Attrs = CallPAL.getAttributes(ArgIndex)) + AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs)); } else if (ByValArgsToTransform.count(I)) { // Emit a GEP and load for each element of the struct. @@ -688,8 +688,8 @@ Function *ArgPromotion::DoPromotion(Function *F, // Push any varargs arguments on the list for (; AI != CS.arg_end(); ++AI, ++ArgIndex) { Args.push_back(*AI); - if (Attributes Attrs = CallPAL.getParamAttrs(ArgIndex)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs)); + if (Attributes Attrs = CallPAL.getAttributes(ArgIndex)) + AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs)); } Instruction *New; @@ -697,18 +697,18 @@ Function *ArgPromotion::DoPromotion(Function *F, New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(), Args.begin(), Args.end(), "", Call); cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); - cast<InvokeInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), - ParamAttrsVec.end())); + cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(), + AttributesVec.end())); } else { New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call); cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); - cast<CallInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), - ParamAttrsVec.end())); + cast<CallInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(), + AttributesVec.end())); if (cast<CallInst>(Call)->isTailCall()) cast<CallInst>(New)->setTailCall(); } Args.clear(); - ParamAttrsVec.clear(); + AttributesVec.clear(); // Update the alias analysis implementation to know that we are replacing // the old call with a new one. diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index ab3321d..eef326b 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -224,12 +224,12 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { Args.assign(CS.arg_begin(), CS.arg_begin()+NumArgs); // Drop any attributes that were on the vararg arguments. - PAListPtr PAL = CS.getParamAttrs(); + AttrListPtr PAL = CS.getAttributes(); if (!PAL.isEmpty() && PAL.getSlot(PAL.getNumSlots() - 1).Index > NumArgs) { - SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec; + SmallVector<AttributeWithIndex, 8> AttributesVec; for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i) - ParamAttrsVec.push_back(PAL.getSlot(i)); - PAL = PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end()); + AttributesVec.push_back(PAL.getSlot(i)); + PAL = AttrListPtr::get(AttributesVec.begin(), AttributesVec.end()); } Instruction *New; @@ -237,11 +237,11 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(), Args.begin(), Args.end(), "", Call); cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); - cast<InvokeInst>(New)->setParamAttrs(PAL); + cast<InvokeInst>(New)->setAttributes(PAL); } else { New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call); cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); - cast<CallInst>(New)->setParamAttrs(PAL); + cast<CallInst>(New)->setAttributes(PAL); if (cast<CallInst>(Call)->isTailCall()) cast<CallInst>(New)->setTailCall(); } @@ -589,11 +589,11 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { std::vector<const Type*> Params; // Set up to build a new list of parameter attributes. - SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec; - const PAListPtr &PAL = F->getParamAttrs(); + SmallVector<AttributeWithIndex, 8> AttributesVec; + const AttrListPtr &PAL = F->getAttributes(); // The existing function return attributes. - Attributes RAttrs = PAL.getParamAttrs(0); + Attributes RAttrs = PAL.getAttributes(0); // Find out the new return value. @@ -655,13 +655,13 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // here. Currently, this should not be possible, but special handling might be // required when new return value attributes are added. if (NRetTy == Type::VoidTy) - RAttrs &= ~ParamAttr::typeIncompatible(NRetTy); + RAttrs &= ~Attribute::typeIncompatible(NRetTy); else - assert((RAttrs & ParamAttr::typeIncompatible(NRetTy)) == 0 + assert((RAttrs & Attribute::typeIncompatible(NRetTy)) == 0 && "Return attributes no longer compatible?"); if (RAttrs) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, RAttrs)); + AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs)); // Remember which arguments are still alive. SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false); @@ -678,8 +678,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // Get the original parameter attributes (skipping the first one, that is // for the return value. - if (Attributes Attrs = PAL.getParamAttrs(i + 1)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(Params.size(), Attrs)); + if (Attributes Attrs = PAL.getAttributes(i + 1)) + AttributesVec.push_back(AttributeWithIndex::get(Params.size(), Attrs)); } else { ++NumArgumentsEliminated; DOUT << "DAE - Removing argument " << i << " (" << I->getNameStart() @@ -687,8 +687,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { } } - // Reconstruct the ParamAttrsList based on the vector we constructed. - PAListPtr NewPAL = PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end()); + // Reconstruct the AttributesList based on the vector we constructed. + AttrListPtr NewPAL = AttrListPtr::get(AttributesVec.begin(), AttributesVec.end()); // Work around LLVM bug PR56: the CWriter cannot emit varargs functions which // have zero fixed arguments. @@ -712,7 +712,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // Create the new function body and insert it into the module... Function *NF = Function::Create(NFTy, F->getLinkage()); NF->copyAttributesFrom(F); - NF->setParamAttrs(NewPAL); + NF->setAttributes(NewPAL); // Insert the new function before the old function, so we won't be processing // it again. F->getParent()->getFunctionList().insert(F, NF); @@ -726,15 +726,15 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { CallSite CS = CallSite::get(F->use_back()); Instruction *Call = CS.getInstruction(); - ParamAttrsVec.clear(); - const PAListPtr &CallPAL = CS.getParamAttrs(); + AttributesVec.clear(); + const AttrListPtr &CallPAL = CS.getAttributes(); // The call return attributes. - Attributes RAttrs = CallPAL.getParamAttrs(0); + Attributes RAttrs = CallPAL.getAttributes(0); // Adjust in case the function was changed to return void. - RAttrs &= ~ParamAttr::typeIncompatible(NF->getReturnType()); + RAttrs &= ~Attribute::typeIncompatible(NF->getReturnType()); if (RAttrs) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, RAttrs)); + AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs)); // Declare these outside of the loops, so we can reuse them for the second // loop, which loops the varargs. @@ -746,8 +746,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { if (ArgAlive[i]) { Args.push_back(*I); // Get original parameter attributes, but skip return attributes. - if (Attributes Attrs = CallPAL.getParamAttrs(i + 1)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs)); + if (Attributes Attrs = CallPAL.getAttributes(i + 1)) + AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs)); } if (ExtraArgHack) @@ -756,24 +756,24 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // Push any varargs arguments on the list. Don't forget their attributes. for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) { Args.push_back(*I); - if (Attributes Attrs = CallPAL.getParamAttrs(i + 1)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs)); + if (Attributes Attrs = CallPAL.getAttributes(i + 1)) + AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs)); } - // Reconstruct the ParamAttrsList based on the vector we constructed. - PAListPtr NewCallPAL = PAListPtr::get(ParamAttrsVec.begin(), - ParamAttrsVec.end()); + // Reconstruct the AttributesList based on the vector we constructed. + AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(), + AttributesVec.end()); Instruction *New; if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) { New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(), Args.begin(), Args.end(), "", Call); cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); - cast<InvokeInst>(New)->setParamAttrs(NewCallPAL); + cast<InvokeInst>(New)->setAttributes(NewCallPAL); } else { New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call); cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); - cast<CallInst>(New)->setParamAttrs(NewCallPAL); + cast<CallInst>(New)->setAttributes(NewCallPAL); if (cast<CallInst>(Call)->isTailCall()) cast<CallInst>(New)->setTailCall(); } diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 0c059ff..31f2144 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1627,23 +1627,23 @@ static void ChangeCalleesToFastCall(Function *F) { } } -static PAListPtr StripNest(const PAListPtr &Attrs) { +static AttrListPtr StripNest(const AttrListPtr &Attrs) { for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) { - if ((Attrs.getSlot(i).Attrs & ParamAttr::Nest) == 0) + if ((Attrs.getSlot(i).Attrs & Attribute::Nest) == 0) continue; // There can be only one. - return Attrs.removeAttr(Attrs.getSlot(i).Index, ParamAttr::Nest); + return Attrs.removeAttr(Attrs.getSlot(i).Index, Attribute::Nest); } return Attrs; } static void RemoveNestAttribute(Function *F) { - F->setParamAttrs(StripNest(F->getParamAttrs())); + F->setAttributes(StripNest(F->getAttributes())); for (Value::use_iterator UI = F->use_begin(), E = F->use_end(); UI != E;++UI){ CallSite User(cast<Instruction>(*UI)); - User.setParamAttrs(StripNest(User.getParamAttrs())); + User.setAttributes(StripNest(User.getAttributes())); } } @@ -1670,7 +1670,7 @@ bool GlobalOpt::OptimizeFunctions(Module &M) { Changed = true; } - if (F->getParamAttrs().hasAttrSomewhere(ParamAttr::Nest) && + if (F->getAttributes().hasAttrSomewhere(Attribute::Nest) && OnlyCalledDirectly(F)) { // The function is not used by a trampoline intrinsic, so it is safe // to remove the 'nest' attribute. diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp index 6d95ffd..448f246 100644 --- a/lib/Transforms/IPO/InlineAlways.cpp +++ b/lib/Transforms/IPO/InlineAlways.cpp @@ -63,7 +63,7 @@ bool AlwaysInliner::doInitialization(CallGraph &CG) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration() && !I->hasNote(FnAttr::AlwaysInline)) + if (!I->isDeclaration() && !I->hasNote(Attribute::AlwaysInline)) NeverInline.insert(I); return false; diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 1cf6c9e..b19494a 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -65,7 +65,7 @@ bool SimpleInliner::doInitialization(CallGraph &CG) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration() && I->hasNote(FnAttr::NoInline)) + if (!I->isDeclaration() && I->hasNote(Attribute::NoInline)) NeverInline.insert(I); // Get llvm.noinline diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 5718835..abc1094 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -141,7 +141,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { int CurrentThreshold = InlineThreshold; Function *Fn = CS.getCaller(); - if (Fn && !Fn->isDeclaration() && Fn->hasNote(FnAttr::OptimizeForSize) + if (Fn && !Fn->isDeclaration() && Fn->hasNote(Attribute::OptimizeForSize) && InlineThreshold != 50) { CurrentThreshold = 50; } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index d5997fb..dfc040b 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -474,7 +474,7 @@ void LowerSetJmp::visitCallInst(CallInst& CI) InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func], Params.begin(), Params.end(), CI.getName(), Term); II->setCallingConv(CI.getCallingConv()); - II->setParamAttrs(CI.getParamAttrs()); + II->setAttributes(CI.getAttributes()); // Replace the old call inst with the invoke inst and remove the call. CI.replaceAllUsesWith(II); diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 9968d59..821e7d5 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -125,18 +125,18 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) { // If the SCC doesn't unwind or doesn't throw, note this fact. if (!SCCMightUnwind || !SCCMightReturn) for (unsigned i = 0, e = SCC.size(); i != e; ++i) { - Attributes NewAttributes = ParamAttr::None; + Attributes NewAttributes = Attribute::None; if (!SCCMightUnwind) - NewAttributes |= ParamAttr::NoUnwind; + NewAttributes |= Attribute::NoUnwind; if (!SCCMightReturn) - NewAttributes |= ParamAttr::NoReturn; + NewAttributes |= Attribute::NoReturn; - const PAListPtr &PAL = SCC[i]->getFunction()->getParamAttrs(); - const PAListPtr &NPAL = PAL.addAttr(0, NewAttributes); + const AttrListPtr &PAL = SCC[i]->getFunction()->getAttributes(); + const AttrListPtr &NPAL = PAL.addAttr(0, NewAttributes); if (PAL != NPAL) { MadeChange = true; - SCC[i]->getFunction()->setParamAttrs(NPAL); + SCC[i]->getFunction()->setAttributes(NPAL); } } @@ -169,7 +169,7 @@ bool PruneEH::SimplifyFunction(Function *F) { Args.begin(), Args.end(), "", II); Call->takeName(II); Call->setCallingConv(II->getCallingConv()); - Call->setParamAttrs(II->getParamAttrs()); + Call->setAttributes(II->getAttributes()); // Anything that used the value produced by the invoke instruction // now uses the value produced by the call instruction. diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 69aecc3..07b9e50 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -205,13 +205,13 @@ Function *SRETPromotion::cloneFunctionBody(Function *F, const FunctionType *FTy = F->getFunctionType(); std::vector<const Type*> Params; - // ParamAttrs - Keep track of the parameter attributes for the arguments. - SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec; - const PAListPtr &PAL = F->getParamAttrs(); + // Attributes - Keep track of the parameter attributes for the arguments. + SmallVector<AttributeWithIndex, 8> AttributesVec; + const AttrListPtr &PAL = F->getAttributes(); // Add any return attributes. - if (Attributes attrs = PAL.getParamAttrs(0)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs)); + if (Attributes attrs = PAL.getAttributes(0)) + AttributesVec.push_back(AttributeWithIndex::get(0, attrs)); // Skip first argument. Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); @@ -221,8 +221,8 @@ Function *SRETPromotion::cloneFunctionBody(Function *F, unsigned ParamIndex = 2; while (I != E) { Params.push_back(I->getType()); - if (Attributes Attrs = PAL.getParamAttrs(ParamIndex)) - ParamAttrsVec.push_back(FnAttributeWithIndex::get(ParamIndex - 1, Attrs)); + if (Attributes Attrs = PAL.getAttributes(ParamIndex)) + AttributesVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs)); ++I; ++ParamIndex; } @@ -231,7 +231,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F, Function *NF = Function::Create(NFTy, F->getLinkage()); NF->takeName(F); NF->copyAttributesFrom(F); - NF->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end())); + NF->setAttributes(AttrListPtr::get(AttributesVec.begin(), AttributesVec.end())); F->getParent()->getFunctionList().insert(F, NF); NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList()); @@ -255,17 +255,17 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { CallGraph &CG = getAnalysis<CallGraph>(); SmallVector<Value*, 16> Args; - // ParamAttrs - Keep track of the parameter attributes for the arguments. - SmallVector<FnAttributeWithIndex, 8> ArgAttrsVec; + // Attributes - Keep track of the parameter attributes for the arguments. + SmallVector<AttributeWithIndex, 8> ArgAttrsVec; while (!F->use_empty()) { CallSite CS = CallSite::get(*F->use_begin()); Instruction *Call = CS.getInstruction(); - const PAListPtr &PAL = F->getParamAttrs(); + const AttrListPtr &PAL = F->getAttributes(); // Add any return attributes. - if (Attributes attrs = PAL.getParamAttrs(0)) - ArgAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs)); + if (Attributes attrs = PAL.getAttributes(0)) + ArgAttrsVec.push_back(AttributeWithIndex::get(0, attrs)); // Copy arguments, however skip first one. CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); @@ -276,14 +276,14 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { unsigned ParamIndex = 2; while (AI != AE) { Args.push_back(*AI); - if (Attributes Attrs = PAL.getParamAttrs(ParamIndex)) - ArgAttrsVec.push_back(FnAttributeWithIndex::get(ParamIndex - 1, Attrs)); + if (Attributes Attrs = PAL.getAttributes(ParamIndex)) + ArgAttrsVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs)); ++ParamIndex; ++AI; } - PAListPtr NewPAL = PAListPtr::get(ArgAttrsVec.begin(), ArgAttrsVec.end()); + AttrListPtr NewPAL = AttrListPtr::get(ArgAttrsVec.begin(), ArgAttrsVec.end()); // Build new call instruction. Instruction *New; @@ -291,11 +291,11 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(), Args.begin(), Args.end(), "", Call); cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); - cast<InvokeInst>(New)->setParamAttrs(NewPAL); + cast<InvokeInst>(New)->setAttributes(NewPAL); } else { New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call); cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); - cast<CallInst>(New)->setParamAttrs(NewPAL); + cast<CallInst>(New)->setAttributes(NewPAL); if (cast<CallInst>(Call)->isTailCall()) cast<CallInst>(New)->setTailCall(); } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index cec5192..1decf2d 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -8999,7 +8999,7 @@ static bool isSafeToEliminateVarargsCast(const CallSite CS, // The size of ByVal arguments is derived from the type, so we // can't change to a type with a different size. If the size were // passed explicitly we could avoid this check. - if (!CS.paramHasAttr(ix, ParamAttr::ByVal)) + if (!CS.paramHasAttr(ix, Attribute::ByVal)) return true; const Type* SrcTy = @@ -9099,7 +9099,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { return false; Function *Callee = cast<Function>(CE->getOperand(0)); Instruction *Caller = CS.getInstruction(); - const PAListPtr &CallerPAL = CS.getParamAttrs(); + const AttrListPtr &CallerPAL = CS.getAttributes(); // Okay, this is a cast from a function to a different type. Unless doing so // would cause a type conversion of one of our arguments, change this call to @@ -9127,8 +9127,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { return false; // Cannot transform this return value. if (!CallerPAL.isEmpty() && !Caller->use_empty()) { - Attributes RAttrs = CallerPAL.getParamAttrs(0); - if (RAttrs & ParamAttr::typeIncompatible(NewRetTy)) + Attributes RAttrs = CallerPAL.getAttributes(0); + if (RAttrs & Attribute::typeIncompatible(NewRetTy)) return false; // Attribute not compatible with transformed value. } @@ -9157,7 +9157,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (!CastInst::isCastable(ActTy, ParamTy)) return false; // Cannot transform this parameter value. - if (CallerPAL.getParamAttrs(i + 1) & ParamAttr::typeIncompatible(ParamTy)) + if (CallerPAL.getAttributes(i + 1) & Attribute::typeIncompatible(ParamTy)) return false; // Attribute not compatible with transformed value. // Converting from one pointer type to another or between a pointer and an @@ -9181,7 +9181,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (CallerPAL.getSlot(i - 1).Index <= FT->getNumParams()) break; Attributes PAttrs = CallerPAL.getSlot(i - 1).Attrs; - if (PAttrs & ParamAttr::VarArgsIncompatible) + if (PAttrs & Attribute::VarArgsIncompatible) return false; } @@ -9189,19 +9189,19 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { // inserting cast instructions as necessary... std::vector<Value*> Args; Args.reserve(NumActualArgs); - SmallVector<FnAttributeWithIndex, 8> attrVec; + SmallVector<AttributeWithIndex, 8> attrVec; attrVec.reserve(NumCommonArgs); // Get any return attributes. - Attributes RAttrs = CallerPAL.getParamAttrs(0); + Attributes RAttrs = CallerPAL.getAttributes(0); // If the return value is not being used, the type may not be compatible // with the existing attributes. Wipe out any problematic attributes. - RAttrs &= ~ParamAttr::typeIncompatible(NewRetTy); + RAttrs &= ~Attribute::typeIncompatible(NewRetTy); // Add the new return attributes. if (RAttrs) - attrVec.push_back(FnAttributeWithIndex::get(0, RAttrs)); + attrVec.push_back(AttributeWithIndex::get(0, RAttrs)); AI = CS.arg_begin(); for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) { @@ -9216,8 +9216,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { } // Add any parameter attributes. - if (Attributes PAttrs = CallerPAL.getParamAttrs(i + 1)) - attrVec.push_back(FnAttributeWithIndex::get(i + 1, PAttrs)); + if (Attributes PAttrs = CallerPAL.getAttributes(i + 1)) + attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs)); } // If the function takes more arguments than the call was taking, add them @@ -9246,8 +9246,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { } // Add any parameter attributes. - if (Attributes PAttrs = CallerPAL.getParamAttrs(i + 1)) - attrVec.push_back(FnAttributeWithIndex::get(i + 1, PAttrs)); + if (Attributes PAttrs = CallerPAL.getAttributes(i + 1)) + attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs)); } } } @@ -9255,7 +9255,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (NewRetTy == Type::VoidTy) Caller->setName(""); // Void type should not have a name. - const PAListPtr &NewCallerPAL = PAListPtr::get(attrVec.begin(),attrVec.end()); + const AttrListPtr &NewCallerPAL = AttrListPtr::get(attrVec.begin(),attrVec.end()); Instruction *NC; if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) { @@ -9263,7 +9263,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { Args.begin(), Args.end(), Caller->getName(), Caller); cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv()); - cast<InvokeInst>(NC)->setParamAttrs(NewCallerPAL); + cast<InvokeInst>(NC)->setAttributes(NewCallerPAL); } else { NC = CallInst::Create(Callee, Args.begin(), Args.end(), Caller->getName(), Caller); @@ -9271,7 +9271,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (CI->isTailCall()) cast<CallInst>(NC)->setTailCall(); cast<CallInst>(NC)->setCallingConv(CI->getCallingConv()); - cast<CallInst>(NC)->setParamAttrs(NewCallerPAL); + cast<CallInst>(NC)->setAttributes(NewCallerPAL); } // Insert a cast of the return type as necessary. @@ -9311,11 +9311,11 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { Value *Callee = CS.getCalledValue(); const PointerType *PTy = cast<PointerType>(Callee->getType()); const FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); - const PAListPtr &Attrs = CS.getParamAttrs(); + const AttrListPtr &Attrs = CS.getAttributes(); // If the call already has the 'nest' attribute somewhere then give up - // otherwise 'nest' would occur twice after splicing in the chain. - if (Attrs.hasAttrSomewhere(ParamAttr::Nest)) + if (Attrs.hasAttrSomewhere(Attribute::Nest)) return 0; IntrinsicInst *Tramp = @@ -9325,19 +9325,19 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { const PointerType *NestFPTy = cast<PointerType>(NestF->getType()); const FunctionType *NestFTy = cast<FunctionType>(NestFPTy->getElementType()); - const PAListPtr &NestAttrs = NestF->getParamAttrs(); + const AttrListPtr &NestAttrs = NestF->getAttributes(); if (!NestAttrs.isEmpty()) { unsigned NestIdx = 1; const Type *NestTy = 0; - Attributes NestAttr = ParamAttr::None; + Attributes NestAttr = Attribute::None; // Look for a parameter marked with the 'nest' attribute. for (FunctionType::param_iterator I = NestFTy->param_begin(), E = NestFTy->param_end(); I != E; ++NestIdx, ++I) - if (NestAttrs.paramHasAttr(NestIdx, ParamAttr::Nest)) { + if (NestAttrs.paramHasAttr(NestIdx, Attribute::Nest)) { // Record the parameter type and any other attributes. NestTy = *I; - NestAttr = NestAttrs.getParamAttrs(NestIdx); + NestAttr = NestAttrs.getAttributes(NestIdx); break; } @@ -9346,15 +9346,15 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { std::vector<Value*> NewArgs; NewArgs.reserve(unsigned(CS.arg_end()-CS.arg_begin())+1); - SmallVector<FnAttributeWithIndex, 8> NewAttrs; + SmallVector<AttributeWithIndex, 8> NewAttrs; NewAttrs.reserve(Attrs.getNumSlots() + 1); // Insert the nest argument into the call argument list, which may // mean appending it. Likewise for attributes. // Add any function result attributes. - if (Attributes Attr = Attrs.getParamAttrs(0)) - NewAttrs.push_back(FnAttributeWithIndex::get(0, Attr)); + if (Attributes Attr = Attrs.getAttributes(0)) + NewAttrs.push_back(AttributeWithIndex::get(0, Attr)); { unsigned Idx = 1; @@ -9366,7 +9366,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { if (NestVal->getType() != NestTy) NestVal = new BitCastInst(NestVal, NestTy, "nest", Caller); NewArgs.push_back(NestVal); - NewAttrs.push_back(FnAttributeWithIndex::get(NestIdx, NestAttr)); + NewAttrs.push_back(AttributeWithIndex::get(NestIdx, NestAttr)); } if (I == E) @@ -9374,9 +9374,9 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { // Add the original argument and attributes. NewArgs.push_back(*I); - if (Attributes Attr = Attrs.getParamAttrs(Idx)) + if (Attributes Attr = Attrs.getAttributes(Idx)) NewAttrs.push_back - (FnAttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr)); + (AttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr)); ++Idx, ++I; } while (1); @@ -9417,7 +9417,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg()); Constant *NewCallee = NestF->getType() == PointerType::getUnqual(NewFTy) ? NestF : ConstantExpr::getBitCast(NestF, PointerType::getUnqual(NewFTy)); - const PAListPtr &NewPAL = PAListPtr::get(NewAttrs.begin(),NewAttrs.end()); + const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),NewAttrs.end()); Instruction *NewCaller; if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) { @@ -9426,7 +9426,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { NewArgs.begin(), NewArgs.end(), Caller->getName(), Caller); cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv()); - cast<InvokeInst>(NewCaller)->setParamAttrs(NewPAL); + cast<InvokeInst>(NewCaller)->setAttributes(NewPAL); } else { NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end(), Caller->getName(), Caller); @@ -9434,7 +9434,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { cast<CallInst>(NewCaller)->setTailCall(); cast<CallInst>(NewCaller)-> setCallingConv(cast<CallInst>(Caller)->getCallingConv()); - cast<CallInst>(NewCaller)->setParamAttrs(NewPAL); + cast<CallInst>(NewCaller)->setAttributes(NewPAL); } if (Caller->getType() != Type::VoidTy && !Caller->use_empty()) Caller->replaceAllUsesWith(NewCaller); diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index a6f6bd7..15eaa78 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -430,7 +430,7 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){ Function *F = loopHeader->getParent(); // Do not unswitch if the function is optimized for size. - if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize)) + if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize)) return false; // Check to see if it would be profitable to unswitch current loop. diff --git a/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/lib/Transforms/Scalar/SimplifyCFGPass.cpp index 1246afc..b499279 100644 --- a/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -83,7 +83,7 @@ static void ChangeToCall(InvokeInst *II) { Args.end(), "", II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); - NewCall->setParamAttrs(II->getParamAttrs()); + NewCall->setAttributes(II->getAttributes()); II->replaceAllUsesWith(NewCall); // Follow the call by a branch to the normal destination. diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp index c35af25..55755c1 100644 --- a/lib/Transforms/Utils/InlineCost.cpp +++ b/lib/Transforms/Utils/InlineCost.cpp @@ -222,7 +222,7 @@ int InlineCostAnalyzer::getInlineCost(CallSite CS, if (CalleeFI.NeverInline) return 2000000000; - if (!Callee->isDeclaration() && Callee->hasNote(FnAttr::AlwaysInline)) + if (!Callee->isDeclaration() && Callee->hasNote(Attribute::AlwaysInline)) return -2000000000; // Add to the inline quality for properties that make the call valuable to diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 1339740..26b4de5 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -88,7 +88,7 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock, InvokeArgs.begin(), InvokeArgs.end(), CI->getName(), BB->getTerminator()); II->setCallingConv(CI->getCallingConv()); - II->setParamAttrs(CI->getParamAttrs()); + II->setAttributes(CI->getAttributes()); // Make sure that anything using the call now uses the invoke! CI->replaceAllUsesWith(II); @@ -246,7 +246,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { // by them explicit. However, we don't do this if the callee is readonly // or readnone, because the copy would be unneeded: the callee doesn't // modify the struct. - if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal) && + if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) && !CalledFunc->onlyReadsMemory()) { const Type *AggTy = cast<PointerType>(I->getType())->getElementType(); const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 437fdbe..20cff90 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -227,7 +227,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { CallArgs.begin(), CallArgs.end(), "",II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); - NewCall->setParamAttrs(II->getParamAttrs()); + NewCall->setAttributes(II->getAttributes()); II->replaceAllUsesWith(NewCall); // Insert an unconditional branch to the normal destination. @@ -296,7 +296,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); - NewCall->setParamAttrs(II->getParamAttrs()); + NewCall->setAttributes(II->getAttributes()); II->replaceAllUsesWith(NewCall); // Replace the invoke with an uncond branch. diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 587dac6..604a717 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1845,7 +1845,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { Args.begin(), Args.end(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); - CI->setParamAttrs(II->getParamAttrs()); + CI->setAttributes(II->getAttributes()); // If the invoke produced a value, the Call now does instead II->replaceAllUsesWith(CI); delete II; @@ -2019,7 +2019,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { Args.begin(), Args.end(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); - CI->setParamAttrs(II->getParamAttrs()); + CI->setAttributes(II->getAttributes()); // If the invoke produced a value, the Call does now instead. II->replaceAllUsesWith(CI); delete II; |