diff options
author | Devang Patel <dpatel@apple.com> | 2008-09-26 22:53:05 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-09-26 22:53:05 +0000 |
commit | 19c874638d9478a5d5028854817a5ee72293bb2b (patch) | |
tree | 748636424f3d1005b6c8713365639fb969466c37 /lib/Transforms/IPO/StructRetPromotion.cpp | |
parent | d5d8191b202c0f96f33c826c93d9796451ff7fca (diff) |
Now Attributes are divided in three groups
- return attributes - inreg, zext and sext
- parameter attributes
- function attributes - nounwind, readonly, readnone, noreturn
Return attributes use 0 as the index.
Function attributes use ~0U as the index.
This patch requires corresponding changes in llvm-gcc and clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56704 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/StructRetPromotion.cpp')
-rw-r--r-- | lib/Transforms/IPO/StructRetPromotion.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 07b9e504c7..96ef66c127 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -210,7 +210,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F, const AttrListPtr &PAL = F->getAttributes(); // Add any return attributes. - if (Attributes attrs = PAL.getAttributes(0)) + if (Attributes attrs = PAL.getRetAttributes()) AttributesVec.push_back(AttributeWithIndex::get(0, attrs)); // Skip first argument. @@ -221,12 +221,17 @@ Function *SRETPromotion::cloneFunctionBody(Function *F, unsigned ParamIndex = 2; while (I != E) { Params.push_back(I->getType()); - if (Attributes Attrs = PAL.getAttributes(ParamIndex)) + if (Attributes Attrs = PAL.getParamAttributes(ParamIndex)) AttributesVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs)); ++I; ++ParamIndex; } + // Add any fn attributes. + if (Attributes attrs = PAL.getFnAttributes()) + AttributesVec.push_back(AttributeWithIndex::get(~0, attrs)); + + FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg()); Function *NF = Function::Create(NFTy, F->getLinkage()); NF->takeName(F); @@ -264,7 +269,7 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { const AttrListPtr &PAL = F->getAttributes(); // Add any return attributes. - if (Attributes attrs = PAL.getAttributes(0)) + if (Attributes attrs = PAL.getRetAttributes()) ArgAttrsVec.push_back(AttributeWithIndex::get(0, attrs)); // Copy arguments, however skip first one. @@ -276,12 +281,15 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { unsigned ParamIndex = 2; while (AI != AE) { Args.push_back(*AI); - if (Attributes Attrs = PAL.getAttributes(ParamIndex)) + if (Attributes Attrs = PAL.getParamAttributes(ParamIndex)) ArgAttrsVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs)); ++ParamIndex; ++AI; } + // Add any function attributes. + if (Attributes attrs = PAL.getFnAttributes()) + ArgAttrsVec.push_back(AttributeWithIndex::get(~0, attrs)); AttrListPtr NewPAL = AttrListPtr::get(ArgAttrsVec.begin(), ArgAttrsVec.end()); |