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 | a05633e105cc2df01f0a5017b1269b6f32e01416 (patch) | |
| tree | 0cd054e5465d3df86a493c7b0d9b45d069190cdf /llvm/lib/Transforms/IPO/StructRetPromotion.cpp | |
| parent | c966a737c52264b95387f677f6200c21274a9403 (diff) | |
| download | bcm5719-llvm-a05633e105cc2df01f0a5017b1269b6f32e01416.tar.gz bcm5719-llvm-a05633e105cc2df01f0a5017b1269b6f32e01416.zip | |
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.
llvm-svn: 56704
Diffstat (limited to 'llvm/lib/Transforms/IPO/StructRetPromotion.cpp')
| -rw-r--r-- | llvm/lib/Transforms/IPO/StructRetPromotion.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/StructRetPromotion.cpp b/llvm/lib/Transforms/IPO/StructRetPromotion.cpp index 07b9e504c74..96ef66c1272 100644 --- a/llvm/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/llvm/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()); |

