summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-03-04 21:32:09 +0000
committerDevang Patel <dpatel@apple.com>2008-03-04 21:32:09 +0000
commitea4cb89d349a19c97f85ad1b653e4b89a8942e33 (patch)
tree6a6eea33b86e4690e988fd931a87590fcb8cfe7d /llvm/lib/Transforms
parent841322b32a93a24cb0c09500dab301e591327c79 (diff)
downloadbcm5719-llvm-ea4cb89d349a19c97f85ad1b653e4b89a8942e33.tar.gz
bcm5719-llvm-ea4cb89d349a19c97f85ad1b653e4b89a8942e33.zip
Filter nested structs
llvm-svn: 47906
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/StructRetPromotion.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/StructRetPromotion.cpp b/llvm/lib/Transforms/IPO/StructRetPromotion.cpp
index 7ea85493ee8..54a34e8803f 100644
--- a/llvm/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/llvm/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;
+}
OpenPOWER on IntegriCloud