From 3d8400d9a61aa4b63ff35e5cede405b32a41425e Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 30 Aug 2008 19:51:14 +0000 Subject: Stub out CodeGenFunction::EmitObjCForCollectionStmt. Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55573 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 909486a6d1..09f3140773 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -201,6 +201,26 @@ unsigned CodeGenFunction::GetIDForAddrOfLabel(const LabelStmt *L) { return LabelIDs.insert(std::make_pair(L, LabelIDs.size())).first->second; } +void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty) +{ + const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); + if (DestPtr->getType() != BP) + DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp"); + + // Get size and alignment info for this aggregate. + std::pair TypeInfo = getContext().getTypeInfo(Ty); + + // FIXME: Handle variable sized types. + const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth); + + Builder.CreateCall4(CGM.getMemSetFn(), DestPtr, + llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty), + // TypeInfo.first describes size in bits. + llvm::ConstantInt::get(IntPtr, TypeInfo.first/8), + llvm::ConstantInt::get(llvm::Type::Int32Ty, + TypeInfo.second/8)); +} + void CodeGenFunction::EmitIndirectSwitches() { llvm::BasicBlock *Default; -- cgit v1.2.3-18-g5258