summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-08 00:07:45 +0000
committerChris Lattner <sabre@nondot.org>2010-07-08 00:07:45 +0000
commitcb7696cf35e75a7bd28438dcdd471d08a4d73eb6 (patch)
treeb1b7590e2e64213c1faf7a24b149ccc6143074e8 /clang/lib/CodeGen
parent26b1a198421053a8e0ee58730532152d91fa41e6 (diff)
downloadbcm5719-llvm-cb7696cf35e75a7bd28438dcdd471d08a4d73eb6.tar.gz
bcm5719-llvm-cb7696cf35e75a7bd28438dcdd471d08a4d73eb6.zip
fix the clang side of PR7437: EmitAggregateCopy
was not producing a memcpy with the right address spaces because of two places in it doing casts of the arguments to i8, one of which that didn't preserve the address space. There is also an optimizer bug here. llvm-svn: 107842
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 8cf07fd36b6..35b7016ab35 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -806,11 +806,6 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
// equal, but other compilers do this optimization, and almost every memcpy
// implementation handles this case safely. If there is a libc that does not
// safely handle this, we can add a target hook.
- const llvm::Type *BP = llvm::Type::getInt8PtrTy(VMContext);
- if (DestPtr->getType() != BP)
- DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
- if (SrcPtr->getType() != BP)
- SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
// Get size and alignment info for this aggregate.
std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty);
@@ -829,18 +824,16 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
//
// we need to use a different call here. We use isVolatile to indicate when
// either the source or the destination is volatile.
- const llvm::Type *I1Ty = llvm::Type::getInt1Ty(VMContext);
- const llvm::Type *I8Ty = llvm::Type::getInt8Ty(VMContext);
const llvm::PointerType *DPT = cast<llvm::PointerType>(DestPtr->getType());
- const llvm::Type *DBP = llvm::PointerType::get(I8Ty, DPT->getAddressSpace());
- if (DestPtr->getType() != DBP)
- DestPtr = Builder.CreateBitCast(DestPtr, DBP, "tmp");
+ const llvm::Type *DBP =
+ llvm::Type::getInt8PtrTy(VMContext, DPT->getAddressSpace());
+ DestPtr = Builder.CreateBitCast(DestPtr, DBP, "tmp");
const llvm::PointerType *SPT = cast<llvm::PointerType>(SrcPtr->getType());
- const llvm::Type *SBP = llvm::PointerType::get(I8Ty, SPT->getAddressSpace());
- if (SrcPtr->getType() != SBP)
- SrcPtr = Builder.CreateBitCast(SrcPtr, SBP, "tmp");
+ const llvm::Type *SBP =
+ llvm::Type::getInt8PtrTy(VMContext, SPT->getAddressSpace());
+ SrcPtr = Builder.CreateBitCast(SrcPtr, SBP, "tmp");
if (const RecordType *RecordTy = Ty->getAs<RecordType>()) {
RecordDecl *Record = RecordTy->getDecl();
@@ -871,6 +864,6 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
DestPtr, SrcPtr,
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtrTy, TypeInfo.first/8),
- llvm::ConstantInt::get(Int32Ty, TypeInfo.second/8),
- llvm::ConstantInt::get(I1Ty, isVolatile));
+ Builder.getInt32(TypeInfo.second/8),
+ Builder.getInt1(isVolatile));
}
OpenPOWER on IntegriCloud