s/isReturnStruct()/hasStructRetAttr()/g

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47857 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2008-03-03 21:46:28 +00:00
parent 6790943540
commit 41e2397b72
9 changed files with 30 additions and 22 deletions

View File

@ -181,8 +181,9 @@ public:
/// @brief Determine if the function does not access or only reads memory. /// @brief Determine if the function does not access or only reads memory.
bool onlyReadsMemory() const; bool onlyReadsMemory() const;
/// @brief Determine if the function returns a structure. /// @brief Determine if the function returns a structure through first
bool isStructReturn() const; /// pointer argument.
bool hasStructRetAttr() const;
/// deleteBody - This method deletes the body of the function, and converts /// deleteBody - This method deletes the body of the function, and converts
/// the linkage to external. /// the linkage to external.

View File

@ -957,8 +957,9 @@ public:
bool doesNotThrow() const; bool doesNotThrow() const;
void setDoesNotThrow(bool doesNotThrow = true); void setDoesNotThrow(bool doesNotThrow = true);
/// @brief Determine if the call returns a structure. /// @brief Determine if the call returns a structure through first
bool isStructReturn() const; /// pointer argument.
bool hasStructRetAttr() const;
/// @brief Determine if any call argument is an aggregate passed by value. /// @brief Determine if any call argument is an aggregate passed by value.
bool hasByValArgument() const; bool hasByValArgument() const;
@ -1769,8 +1770,9 @@ public:
bool doesNotThrow() const; bool doesNotThrow() const;
void setDoesNotThrow(bool doesNotThrow = true); void setDoesNotThrow(bool doesNotThrow = true);
/// @brief Determine if the call returns a structure. /// @brief Determine if the call returns a structure through first
bool isStructReturn() const; /// pointer argument.
bool hasStructRetAttr() const;
/// getCalledFunction - Return the function called, or null if this is an /// getCalledFunction - Return the function called, or null if this is an
/// indirect function invocation. /// indirect function invocation.

View File

@ -1904,7 +1904,7 @@ void CWriter::printContainedStructs(const Type *Ty,
void CWriter::printFunctionSignature(const Function *F, bool Prototype) { void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
/// isStructReturn - Should this function actually return a struct by-value? /// isStructReturn - Should this function actually return a struct by-value?
bool isStructReturn = F->isStructReturn(); bool isStructReturn = F->hasStructRetAttr();
if (F->hasInternalLinkage()) Out << "static "; if (F->hasInternalLinkage()) Out << "static ";
if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) "; if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) ";
@ -2024,7 +2024,7 @@ static inline bool isFPIntBitCast(const Instruction &I) {
void CWriter::printFunction(Function &F) { void CWriter::printFunction(Function &F) {
/// isStructReturn - Should this function actually return a struct by-value? /// isStructReturn - Should this function actually return a struct by-value?
bool isStructReturn = F.isStructReturn(); bool isStructReturn = F.hasStructRetAttr();
printFunctionSignature(&F, false); printFunctionSignature(&F, false);
Out << " {\n"; Out << " {\n";
@ -2148,7 +2148,7 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
// //
void CWriter::visitReturnInst(ReturnInst &I) { void CWriter::visitReturnInst(ReturnInst &I) {
// If this is a struct return function, return the temporary struct. // If this is a struct return function, return the temporary struct.
bool isStructReturn = I.getParent()->getParent()->isStructReturn(); bool isStructReturn = I.getParent()->getParent()->hasStructRetAttr();
if (isStructReturn) { if (isStructReturn) {
Out << " return StructReturn;\n"; Out << " return StructReturn;\n";
@ -2584,7 +2584,7 @@ void CWriter::visitCallInst(CallInst &I) {
// parameter instead of passing it to the call. // parameter instead of passing it to the call.
const ParamAttrsList *PAL = I.getParamAttrs(); const ParamAttrsList *PAL = I.getParamAttrs();
bool hasByVal = I.hasByValArgument(); bool hasByVal = I.hasByValArgument();
bool isStructRet = I.isStructReturn(); bool isStructRet = I.hasStructRetAttr();
if (isStructRet) { if (isStructRet) {
writeOperandDeref(I.getOperand(1)); writeOperandDeref(I.getOperand(1));
Out << " = "; Out << " = ";

View File

@ -102,13 +102,13 @@ void X86SharedAsmPrinter::decorateName(std::string &Name,
case StdCall: case StdCall:
// "Pure" variadic functions do not receive @0 suffix. // "Pure" variadic functions do not receive @0 suffix.
if (!FT->isVarArg() || (FT->getNumParams() == 0) || if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
(FT->getNumParams() == 1 && F->isStructReturn())) (FT->getNumParams() == 1 && F->hasStructRetAttr()))
Name += '@' + utostr_32(Info->getBytesToPopOnReturn()); Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
break; break;
case FastCall: case FastCall:
// "Pure" variadic functions do not receive @0 suffix. // "Pure" variadic functions do not receive @0 suffix.
if (!FT->isVarArg() || (FT->getNumParams() == 0) || if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
(FT->getNumParams() == 1 && F->isStructReturn())) (FT->getNumParams() == 1 && F->hasStructRetAttr()))
Name += '@' + utostr_32(Info->getBytesToPopOnReturn()); Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
if (Name[0] == '_') { if (Name[0] == '_') {

View File

@ -255,7 +255,7 @@ DAE::Liveness DAE::getArgumentLiveness(const Argument &A) {
const Function *F = A.getParent(); const Function *F = A.getParent();
// If this is the return value of a struct function, it's not really dead. // If this is the return value of a struct function, it's not really dead.
if (F->isStructReturn() && &*(F->arg_begin()) == &A) if (F->hasStructRetAttr() && &*(F->arg_begin()) == &A)
return Live; return Live;
if (A.use_empty()) // First check, directly dead? if (A.use_empty()) // First check, directly dead?

View File

@ -75,7 +75,7 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
return false; return false;
// Make sure that function returns struct. // Make sure that function returns struct.
if (F->arg_size() == 0 || !F->isStructReturn() || F->doesNotReturn()) if (F->arg_size() == 0 || !F->hasStructRetAttr() || F->doesNotReturn())
return false; return false;
assert (F->getReturnType() == Type::VoidTy && "Invalid function return type"); assert (F->getReturnType() == Type::VoidTy && "Invalid function return type");

View File

@ -168,10 +168,10 @@ bool Function::onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
} }
/// @brief Determine if the function returns a structure. /// @brief Determine if the function returns a structure through first
bool Function::isStructReturn() const { /// pointer argument.
return paramHasAttr(1, ParamAttr::StructRet) bool Function::hasStructRetAttr() const {
|| isa<StructType>(getReturnType()); return paramHasAttr(1, ParamAttr::StructRet);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -419,8 +419,9 @@ bool CallInst::doesNotThrow() const {
return paramHasAttr(0, ParamAttr::NoUnwind); return paramHasAttr(0, ParamAttr::NoUnwind);
} }
/// @brief Determine if the call returns a structure. /// @brief Determine if the call returns a structure through first
bool CallInst::isStructReturn() const { /// pointer argument.
bool CallInst::hasStructRetAttr() const {
// Be friendly and also check the callee. // Be friendly and also check the callee.
return paramHasAttr(1, ParamAttr::StructRet); return paramHasAttr(1, ParamAttr::StructRet);
} }
@ -560,8 +561,9 @@ void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
setParamAttrs(PAL); setParamAttrs(PAL);
} }
/// @brief Determine if the call returns a structure. /// @brief Determine if the invoke returns a structure through first
bool InvokeInst::isStructReturn() const { /// pointer argument.
bool InvokeInst::hasStructRetAttr() const {
// Be friendly and also check the callee. // Be friendly and also check the callee.
return paramHasAttr(1, ParamAttr::StructRet); return paramHasAttr(1, ParamAttr::StructRet);
} }

View File

@ -455,6 +455,9 @@ void Verifier::visitFunction(Function &F) {
isa<StructType>(F.getReturnType()), isa<StructType>(F.getReturnType()),
"Functions cannot return aggregate values!", &F); "Functions cannot return aggregate values!", &F);
Assert1(!F.hasStructRetAttr() || F.getReturnType() == Type::VoidTy,
"Invalid struct return type!", &F);
const ParamAttrsList *Attrs = F.getParamAttrs(); const ParamAttrsList *Attrs = F.getParamAttrs();
Assert1(!Attrs || Assert1(!Attrs ||