s/isReturnStruct()/hasStructRetAttr()/g
authorDevang Patel <dpatel@apple.com>
Mon, 3 Mar 2008 21:46:28 +0000 (21:46 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 3 Mar 2008 21:46:28 +0000 (21:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47857 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Function.h
include/llvm/Instructions.h
lib/Target/CBackend/CBackend.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp
lib/Transforms/IPO/StructRetPromotion.cpp
lib/VMCore/Function.cpp
lib/VMCore/Instructions.cpp
lib/VMCore/Verifier.cpp

index 40b9c46de235d6749ec369f092ce4edf64d625c8..3d75db8a03f0db57ba696ce3dc6b922c348713ec 100644 (file)
@@ -181,8 +181,9 @@ public:
   /// @brief Determine if the function does not access or only reads memory.
   bool onlyReadsMemory() const;
 
-  /// @brief Determine if the function returns a structure.
-  bool isStructReturn() const;
+  /// @brief Determine if the function returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() const;
 
   /// deleteBody - This method deletes the body of the function, and converts
   /// the linkage to external.
index 2e6b85b729b18cb50b15a736b65b63ffafac1cca..3dd42797c63cbe905388f2ecedb39cd8d694440c 100644 (file)
@@ -957,8 +957,9 @@ public:
   bool doesNotThrow() const;
   void setDoesNotThrow(bool doesNotThrow = true);
 
-  /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const;
+  /// @brief Determine if the call returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() const;
 
   /// @brief Determine if any call argument is an aggregate passed by value.
   bool hasByValArgument() const;
@@ -1769,8 +1770,9 @@ public:
   bool doesNotThrow() const;
   void setDoesNotThrow(bool doesNotThrow = true);
 
-  /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const;
+  /// @brief Determine if the call returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() const;
 
   /// getCalledFunction - Return the function called, or null if this is an
   /// indirect function invocation.
index 946a28315218fc29ef0d7231879ecae836c41fe0..3a4e97e276c86dfa5b9fbf2b8e3bcf494fb6db7a 100644 (file)
@@ -1904,7 +1904,7 @@ void CWriter::printContainedStructs(const Type *Ty,
 
 void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
   /// 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->hasDLLImportLinkage()) Out << "__declspec(dllimport) ";
@@ -2024,7 +2024,7 @@ static inline bool isFPIntBitCast(const Instruction &I) {
 
 void CWriter::printFunction(Function &F) {
   /// isStructReturn - Should this function actually return a struct by-value?
-  bool isStructReturn = F.isStructReturn();
+  bool isStructReturn = F.hasStructRetAttr();
 
   printFunctionSignature(&F, false);
   Out << " {\n";
@@ -2148,7 +2148,7 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
 //
 void CWriter::visitReturnInst(ReturnInst &I) {
   // 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) {
     Out << "  return StructReturn;\n";
@@ -2584,7 +2584,7 @@ void CWriter::visitCallInst(CallInst &I) {
   // parameter instead of passing it to the call.
   const ParamAttrsList *PAL = I.getParamAttrs();
   bool hasByVal = I.hasByValArgument();
-  bool isStructRet = I.isStructReturn();
+  bool isStructRet = I.hasStructRetAttr();
   if (isStructRet) {
     writeOperandDeref(I.getOperand(1));
     Out << " = ";
index 9720100e3707fb7310307e078f92ef270af59c18..98e7d9c1e819943de53eced9a5819162666f9057 100644 (file)
@@ -102,13 +102,13 @@ void X86SharedAsmPrinter::decorateName(std::string &Name,
   case StdCall:
     // "Pure" variadic functions do not receive @0 suffix.
     if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
-        (FT->getNumParams() == 1 && F->isStructReturn()))
+        (FT->getNumParams() == 1 && F->hasStructRetAttr()))
       Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
     break;
   case FastCall:
     // "Pure" variadic functions do not receive @0 suffix.
     if (!FT->isVarArg() || (FT->getNumParams() == 0) ||
-        (FT->getNumParams() == 1 && F->isStructReturn()))
+        (FT->getNumParams() == 1 && F->hasStructRetAttr()))
       Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
 
     if (Name[0] == '_') {
index 2ee54510e6b46bdbfa3307bf0b33615615dee50f..088269d816d52040ad3d76ac7615b06b5945320c 100644 (file)
@@ -255,7 +255,7 @@ DAE::Liveness DAE::getArgumentLiveness(const Argument &A) {
   const Function *F = A.getParent();
   
   // 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;
   
   if (A.use_empty())  // First check, directly dead?
index 1de066e31226fe161ad34fac0d1d35ed9297bf97..298b5b1c1f1c289b879472a099ee11d424afff5c 100644 (file)
@@ -75,7 +75,7 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
     return false;
 
   // 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;
 
   assert (F->getReturnType() == Type::VoidTy && "Invalid function return type");
index 92737f66d92b09117eebd7ab22db4fbf5a6e6cef..f5712e7561bd9f4c8a0fae4277c75960de2412df 100644 (file)
@@ -168,10 +168,10 @@ bool Function::onlyReadsMemory() const {
   return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
 }
 
-/// @brief Determine if the function returns a structure.
-bool Function::isStructReturn() const {
-  return paramHasAttr(1, ParamAttr::StructRet) 
-    || isa<StructType>(getReturnType());
+/// @brief Determine if the function returns a structure through first 
+/// pointer argument.
+bool Function::hasStructRetAttr() const {
+  return paramHasAttr(1, ParamAttr::StructRet);
 }
 
 //===----------------------------------------------------------------------===//
index dfd3b830caaced46159274ce467e4d9764323d94..f7401ec979789ade514462acba668b4b2b9480a4 100644 (file)
@@ -419,8 +419,9 @@ bool CallInst::doesNotThrow() const {
   return paramHasAttr(0, ParamAttr::NoUnwind);
 }
 
-/// @brief Determine if the call returns a structure.
-bool CallInst::isStructReturn() const {
+/// @brief Determine if the call returns a structure through first 
+/// pointer argument.
+bool CallInst::hasStructRetAttr() const {
   // Be friendly and also check the callee.
   return paramHasAttr(1, ParamAttr::StructRet);
 }
@@ -560,8 +561,9 @@ void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
   setParamAttrs(PAL);
 }
 
-/// @brief Determine if the call returns a structure.
-bool InvokeInst::isStructReturn() const {
+/// @brief Determine if the invoke returns a structure through first 
+/// pointer argument.
+bool InvokeInst::hasStructRetAttr() const {
   // Be friendly and also check the callee.
   return paramHasAttr(1, ParamAttr::StructRet);
 }
index 3d6832475f6d78f9156e881fee26113d994f5113..9ce886cd86279bf447b7b771e5954d554b9c26d1 100644 (file)
@@ -455,6 +455,9 @@ void Verifier::visitFunction(Function &F) {
           isa<StructType>(F.getReturnType()),
           "Functions cannot return aggregate values!", &F);
 
+  Assert1(!F.hasStructRetAttr() || F.getReturnType() == Type::VoidTy,
+          "Invalid struct return type!", &F);
+
   const ParamAttrsList *Attrs = F.getParamAttrs();
 
   Assert1(!Attrs ||