add support for a 1<<29 bit in the block flags field to mark blocks using alternate struct return ABI
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97775 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 7076067..c10a401 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -154,7 +154,7 @@
{
// C = BuildBlockStructInitlist();
- unsigned int flags = BLOCK_HAS_OBJC_TYPE;
+ unsigned int flags = BLOCK_HAS_SIGNATURE;
// We run this first so that we set BlockHasCopyDispose from the entire
// block literal.
@@ -184,6 +184,18 @@
Elts[0] = C;
// __flags
+ {
+ QualType BPT = BE->getType();
+ const FunctionType *ftype = BPT->getPointeeType()->getAs<FunctionType>();
+ QualType ResultType = ftype->getResultType();
+
+ CallArgList Args;
+ CodeGenTypes &Types = CGM.getTypes();
+ const CGFunctionInfo &FnInfo = Types.getFunctionInfo(ResultType, Args,
+ CC_Default, false);
+ if (CGM.ReturnTypeUsesSret(FnInfo))
+ flags |= BLOCK_USE_STRET;
+ }
const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
CGM.getTypes().ConvertType(CGM.getContext().IntTy));
C = llvm::ConstantInt::get(IntTy, flags);
@@ -200,6 +212,7 @@
// Optimize to being a global block.
Elts[0] = CGM.getNSConcreteGlobalBlock();
+
Elts[1] = llvm::ConstantInt::get(IntTy, flags|BLOCK_IS_GLOBAL);
C = llvm::ConstantStruct::get(VMContext, Elts, false);
@@ -604,7 +617,7 @@
// Flags
LiteralFields[1] =
- llvm::ConstantInt::get(IntTy, BLOCK_IS_GLOBAL | BLOCK_HAS_OBJC_TYPE);
+ llvm::ConstantInt::get(IntTy, BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE);
// Reserved
LiteralFields[2] = llvm::Constant::getNullValue(IntTy);