[llvm-commits] [llvm] r47906 - /llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
Devang Patel
dpatel at apple.com
Tue Mar 4 13:32:09 PST 2008
Author: dpatel
Date: Tue Mar 4 15:32:09 2008
New Revision: 47906
URL: http://llvm.org/viewvc/llvm-project?rev=47906&view=rev
Log:
Filter nested structs
Modified:
llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp?rev=47906&r1=47905&r2=47906&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Tue Mar 4 15:32:09 2008
@@ -48,6 +48,7 @@
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 @@
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 @@
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;
+}
More information about the llvm-commits
mailing list