diff options
author | Devang Patel <dpatel@apple.com> | 2008-03-04 21:32:09 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-03-04 21:32:09 +0000 |
commit | a9fe8bb3b668c7822ff458beae3fb60df920b16d (patch) | |
tree | 9d55c4acaefeb14800adaabb18892877404a4cc9 /lib/Transforms/IPO/StructRetPromotion.cpp | |
parent | dc00d42bb18a6748f43c365d9bd30c1ed0e800ac (diff) |
Filter nested structs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47906 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, 16 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 7ea85493ee..54a34e8803 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -48,6 +48,7 @@ namespace { bool isSafeToUpdateAllCallers(Function *F); Function *cloneFunctionBody(Function *F, const StructType *STy); void updateCallSites(Function *F, Function *NF); + bool nestedStructType(const StructType *STy); }; char SRETPromotion::ID = 0; @@ -88,6 +89,9 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) { dyn_cast<StructType>(FArgType->getElementType()); assert (STy && "Invalid sret parameter element type"); + if (nestedStructType(STy)) + return false; + // Check if it is ok to perform this promotion. if (isSafeToUpdateAllCallers(F) == false) { NumRejectedSRETUses++; @@ -319,3 +323,15 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) { Call->eraseFromParent(); } } + +/// nestedStructType - Return true if STy includes any +/// other aggregate types +bool SRETPromotion::nestedStructType(const StructType *STy) { + unsigned Num = STy->getNumElements(); + for (unsigned i = 0; i < Num; i++) { + const Type *Ty = STy->getElementType(i); + if (!Ty->isFirstClassType() && Ty != Type::VoidTy) + return true; + } + return false; +} |