[cfe-commits] r127324 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGBlocks.h

John McCall rjmccall at apple.com
Wed Mar 9 00:39:33 PST 2011


Author: rjmccall
Date: Wed Mar  9 02:39:33 2011
New Revision: 127324

URL: http://llvm.org/viewvc/llvm-project?rev=127324&view=rev
Log:
Remove a rather egregious use of getFunctionInfo.


Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/lib/CodeGen/CGBlocks.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=127324&r1=127323&r2=127324&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Mar  9 02:39:33 2011
@@ -27,7 +27,7 @@
 
 CGBlockInfo::CGBlockInfo(const BlockExpr *blockExpr, const char *N)
   : Name(N), CXXThisIndex(0), CanBeGlobal(false), NeedsCopyDispose(false),
-    HasCXXObject(false), StructureType(0), Block(blockExpr) {
+    HasCXXObject(false), UsesStret(false), StructureType(0), Block(blockExpr) {
     
   // Skip asm prefix, if any.
   if (Name && Name[0] == '\01')
@@ -104,23 +104,6 @@
   return llvm::ConstantExpr::getBitCast(global, CGM.getBlockDescriptorType());
 }
 
-static BlockFlags computeBlockFlag(CodeGenModule &CGM,
-                                   const BlockExpr *BE,
-                                   BlockFlags flags) {
-  const FunctionType *ftype = BE->getFunctionType();
-  
-  // This is a bit overboard.
-  CallArgList args;
-  const CGFunctionInfo &fnInfo =
-    CGM.getTypes().getFunctionInfo(ftype->getResultType(), args,
-                                   ftype->getExtInfo());
-
-  if (CGM.ReturnTypeUsesSRet(fnInfo))
-    flags |= BLOCK_USE_STRET;
-
-  return flags;
-}
-
 /*
   Purely notional variadic template describing the layout of a block.
 
@@ -536,7 +519,7 @@
   BlockFlags flags = BLOCK_HAS_SIGNATURE;
   if (blockInfo.NeedsCopyDispose) flags |= BLOCK_HAS_COPY_DISPOSE;
   if (blockInfo.HasCXXObject) flags |= BLOCK_HAS_CXX_OBJ;
-  flags = computeBlockFlag(CGM, blockInfo.getBlockExpr(), flags);
+  if (blockInfo.UsesStret) flags |= BLOCK_USE_STRET;
 
   // Initialize the block literal.
   Builder.CreateStore(isa, Builder.CreateStructGEP(blockAddr, 0, "block.isa"));
@@ -747,7 +730,7 @@
   // Load the function.
   llvm::Value *Func = Builder.CreateLoad(FuncPtr, "tmp");
 
-  const FunctionType *FuncTy = FnType->getAs<FunctionType>();
+  const FunctionType *FuncTy = FnType->castAs<FunctionType>();
   QualType ResultType = FuncTy->getResultType();
 
   const CGFunctionInfo &FnInfo =
@@ -836,8 +819,9 @@
   fields[0] = CGM.getNSConcreteGlobalBlock();
 
   // __flags
-  BlockFlags flags = computeBlockFlag(CGM, blockInfo.getBlockExpr(),
-                                      BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE);
+  BlockFlags flags = BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE;
+  if (blockInfo.UsesStret) flags |= BLOCK_USE_STRET;
+                                      
   fields[1] = llvm::ConstantInt::get(CGM.IntTy, flags.getBitMask());
 
   // Reserved
@@ -915,6 +899,9 @@
   const CGFunctionInfo &fnInfo =
     CGM.getTypes().getFunctionInfo(fnType->getResultType(), args,
                                    fnType->getExtInfo());
+  if (CGM.ReturnTypeUsesSRet(fnInfo))
+    blockInfo.UsesStret = true;
+
   const llvm::FunctionType *fnLLVMType =
     CGM.getTypes().GetFunctionType(fnInfo, fnType->isVariadic());
 

Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=127324&r1=127323&r2=127324&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Wed Mar  9 02:39:33 2011
@@ -173,6 +173,10 @@
   /// need to be run even in GC mode.
   bool HasCXXObject : 1;
 
+  /// UsesStret : True if the block uses an stret return.  Mutable
+  /// because it gets set later in the block-creation process.
+  mutable bool UsesStret : 1;
+
   const llvm::StructType *StructureType;
   const BlockExpr *Block;
   CharUnits BlockSize;





More information about the cfe-commits mailing list