aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-03-09 08:39:33 +0000
committerJohn McCall <rjmccall@apple.com>2011-03-09 08:39:33 +0000
commit64cd2328ef55735c910d3d51dd40eafc38d7a504 (patch)
treefe12d50b0df1334cbdbd7661991c9c140e93fd0d /lib/CodeGen/CGBlocks.cpp
parent1f6f961293da9c2b1c23da2411c1b439a9502ed0 (diff)
Remove a rather egregious use of getFunctionInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127324 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r--lib/CodeGen/CGBlocks.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 832a18ab13..8351d36f25 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -27,7 +27,7 @@ using namespace CodeGen;
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 @@ static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM,
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 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const BlockExpr *blockExpr) {
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 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E,
// 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 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
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 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD,
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());