mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
Filter nested structs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47906 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -48,6 +48,7 @@ namespace {
|
|||||||
bool isSafeToUpdateAllCallers(Function *F);
|
bool isSafeToUpdateAllCallers(Function *F);
|
||||||
Function *cloneFunctionBody(Function *F, const StructType *STy);
|
Function *cloneFunctionBody(Function *F, const StructType *STy);
|
||||||
void updateCallSites(Function *F, Function *NF);
|
void updateCallSites(Function *F, Function *NF);
|
||||||
|
bool nestedStructType(const StructType *STy);
|
||||||
};
|
};
|
||||||
|
|
||||||
char SRETPromotion::ID = 0;
|
char SRETPromotion::ID = 0;
|
||||||
@@ -88,6 +89,9 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
|
|||||||
dyn_cast<StructType>(FArgType->getElementType());
|
dyn_cast<StructType>(FArgType->getElementType());
|
||||||
assert (STy && "Invalid sret parameter element type");
|
assert (STy && "Invalid sret parameter element type");
|
||||||
|
|
||||||
|
if (nestedStructType(STy))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Check if it is ok to perform this promotion.
|
// Check if it is ok to perform this promotion.
|
||||||
if (isSafeToUpdateAllCallers(F) == false) {
|
if (isSafeToUpdateAllCallers(F) == false) {
|
||||||
NumRejectedSRETUses++;
|
NumRejectedSRETUses++;
|
||||||
@@ -319,3 +323,15 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
|
|||||||
Call->eraseFromParent();
|
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;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user