diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-12-30 00:13:21 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-12-30 00:13:21 +0000 |
commit | 9f0c7cc36d29cf591c33962931f5862847145f3e (patch) | |
tree | 39269ee4705c774eb1f09846e64c98036662c506 /lib/CodeGen/CodeGenFunction.cpp | |
parent | 272324bc881450a71873d2f4e72f17837d8998df (diff) |
Simplify mem{cpy, move, set} creation with IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 8a0d78cc21..281a62f899 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -534,22 +534,20 @@ CodeGenFunction::EmitNullInitialization(llvm::Value *DestPtr, QualType Ty) { // Cast the dest ptr to the appropriate i8 pointer type. unsigned DestAS = cast<llvm::PointerType>(DestPtr->getType())->getAddressSpace(); - const llvm::Type *BP = - llvm::Type::getInt8PtrTy(VMContext, DestAS); + const llvm::Type *BP = Builder.getInt8PtrTy(DestAS); if (DestPtr->getType() != BP) DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp"); // Get size and alignment info for this aggregate. std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty); - uint64_t Size = TypeInfo.first; - unsigned Align = TypeInfo.second; + uint64_t Size = TypeInfo.first / 8; + unsigned Align = TypeInfo.second / 8; // Don't bother emitting a zero-byte memset. if (Size == 0) return; - llvm::ConstantInt *SizeVal = llvm::ConstantInt::get(IntPtrTy, Size / 8); - llvm::ConstantInt *AlignVal = Builder.getInt32(Align / 8); + llvm::ConstantInt *SizeVal = llvm::ConstantInt::get(IntPtrTy, Size); // If the type contains a pointer to data member we can't memset it to zero. // Instead, create a null constant and copy it to the destination. @@ -567,10 +565,7 @@ CodeGenFunction::EmitNullInitialization(llvm::Value *DestPtr, QualType Ty) { // FIXME: variable-size types? // Get and call the appropriate llvm.memcpy overload. - llvm::Constant *Memcpy = - CGM.getMemCpyFn(DestPtr->getType(), SrcPtr->getType(), IntPtrTy); - Builder.CreateCall5(Memcpy, DestPtr, SrcPtr, SizeVal, AlignVal, - /*volatile*/ Builder.getFalse()); + Builder.CreateMemCpy(DestPtr, SrcPtr, SizeVal, Align, false); return; } @@ -579,9 +574,7 @@ CodeGenFunction::EmitNullInitialization(llvm::Value *DestPtr, QualType Ty) { // handled above) are guaranteed to have a bit pattern of all zeros. // FIXME: Handle variable sized types. - Builder.CreateCall5(CGM.getMemSetFn(BP, IntPtrTy), DestPtr, - Builder.getInt8(0), - SizeVal, AlignVal, /*volatile*/ Builder.getFalse()); + Builder.CreateMemSet(DestPtr, Builder.getInt8(0), SizeVal, Align, false); } llvm::BlockAddress *CodeGenFunction::GetAddrOfLabel(const LabelStmt *L) { |