Deleted Added
full compact
CGBlocks.cpp (204643) CGBlocks.cpp (204793)
1//===--- CGBlocks.cpp - Emit LLVM Code for declarations -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 140 unchanged lines hidden (view full) ---

149
150 std::vector<llvm::Constant*> Elts(BlockFields);
151
152 llvm::Constant *C;
153 llvm::Value *V;
154
155 {
156 // C = BuildBlockStructInitlist();
1//===--- CGBlocks.cpp - Emit LLVM Code for declarations -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 140 unchanged lines hidden (view full) ---

149
150 std::vector<llvm::Constant*> Elts(BlockFields);
151
152 llvm::Constant *C;
153 llvm::Value *V;
154
155 {
156 // C = BuildBlockStructInitlist();
157 unsigned int flags = BLOCK_HAS_OBJC_TYPE;
157 unsigned int flags = BLOCK_HAS_SIGNATURE;
158
159 // We run this first so that we set BlockHasCopyDispose from the entire
160 // block literal.
161 // __invoke
162 CharUnits subBlockSize;
163 CharUnits subBlockAlign;
164 llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
165 bool subBlockHasCopyDispose = false;

--- 13 unchanged lines hidden (view full) ---

179 flags |= BLOCK_HAS_COPY_DISPOSE;
180
181 // __isa
182 C = CGM.getNSConcreteStackBlock();
183 C = llvm::ConstantExpr::getBitCast(C, PtrToInt8Ty);
184 Elts[0] = C;
185
186 // __flags
158
159 // We run this first so that we set BlockHasCopyDispose from the entire
160 // block literal.
161 // __invoke
162 CharUnits subBlockSize;
163 CharUnits subBlockAlign;
164 llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
165 bool subBlockHasCopyDispose = false;

--- 13 unchanged lines hidden (view full) ---

179 flags |= BLOCK_HAS_COPY_DISPOSE;
180
181 // __isa
182 C = CGM.getNSConcreteStackBlock();
183 C = llvm::ConstantExpr::getBitCast(C, PtrToInt8Ty);
184 Elts[0] = C;
185
186 // __flags
187 {
188 QualType BPT = BE->getType();
189 const FunctionType *ftype = BPT->getPointeeType()->getAs<FunctionType>();
190 QualType ResultType = ftype->getResultType();
191
192 CallArgList Args;
193 CodeGenTypes &Types = CGM.getTypes();
194 const CGFunctionInfo &FnInfo = Types.getFunctionInfo(ResultType, Args,
195 CC_Default, false);
196 if (CGM.ReturnTypeUsesSret(FnInfo))
197 flags |= BLOCK_USE_STRET;
198 }
187 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
188 CGM.getTypes().ConvertType(CGM.getContext().IntTy));
189 C = llvm::ConstantInt::get(IntTy, flags);
190 Elts[1] = C;
191
192 // __reserved
193 C = llvm::ConstantInt::get(IntTy, 0);
194 Elts[2] = C;
195
196 if (subBlockDeclRefDecls.size() == 0) {
197 // __descriptor
198 Elts[4] = BuildDescriptorBlockDecl(BE, subBlockHasCopyDispose, subBlockSize,
199 0, 0);
200
201 // Optimize to being a global block.
202 Elts[0] = CGM.getNSConcreteGlobalBlock();
199 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
200 CGM.getTypes().ConvertType(CGM.getContext().IntTy));
201 C = llvm::ConstantInt::get(IntTy, flags);
202 Elts[1] = C;
203
204 // __reserved
205 C = llvm::ConstantInt::get(IntTy, 0);
206 Elts[2] = C;
207
208 if (subBlockDeclRefDecls.size() == 0) {
209 // __descriptor
210 Elts[4] = BuildDescriptorBlockDecl(BE, subBlockHasCopyDispose, subBlockSize,
211 0, 0);
212
213 // Optimize to being a global block.
214 Elts[0] = CGM.getNSConcreteGlobalBlock();
215
203 Elts[1] = llvm::ConstantInt::get(IntTy, flags|BLOCK_IS_GLOBAL);
204
205 C = llvm::ConstantStruct::get(VMContext, Elts, false);
206
207 C = new llvm::GlobalVariable(CGM.getModule(), C->getType(), true,
208 llvm::GlobalValue::InternalLinkage, C,
209 "__block_holder_tmp_" +
210 llvm::Twine(CGM.getGlobalUniqueCount()));

--- 388 unchanged lines hidden (view full) ---

599 assert(subBlockSize == BlockLiteralSize
600 && "no imports allowed for global block");
601
602 // isa
603 LiteralFields[0] = getNSConcreteGlobalBlock();
604
605 // Flags
606 LiteralFields[1] =
216 Elts[1] = llvm::ConstantInt::get(IntTy, flags|BLOCK_IS_GLOBAL);
217
218 C = llvm::ConstantStruct::get(VMContext, Elts, false);
219
220 C = new llvm::GlobalVariable(CGM.getModule(), C->getType(), true,
221 llvm::GlobalValue::InternalLinkage, C,
222 "__block_holder_tmp_" +
223 llvm::Twine(CGM.getGlobalUniqueCount()));

--- 388 unchanged lines hidden (view full) ---

612 assert(subBlockSize == BlockLiteralSize
613 && "no imports allowed for global block");
614
615 // isa
616 LiteralFields[0] = getNSConcreteGlobalBlock();
617
618 // Flags
619 LiteralFields[1] =
607 llvm::ConstantInt::get(IntTy, BLOCK_IS_GLOBAL | BLOCK_HAS_OBJC_TYPE);
620 llvm::ConstantInt::get(IntTy, BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE);
608
609 // Reserved
610 LiteralFields[2] = llvm::Constant::getNullValue(IntTy);
611
612 // Function
613 LiteralFields[3] = Fn;
614
615 // Descriptor

--- 563 unchanged lines hidden ---
621
622 // Reserved
623 LiteralFields[2] = llvm::Constant::getNullValue(IntTy);
624
625 // Function
626 LiteralFields[3] = Fn;
627
628 // Descriptor

--- 563 unchanged lines hidden ---