From: Chris Lattner Date: Mon, 28 Jun 2010 22:51:39 +0000 (+0000) Subject: make the trivial forms of CreateCoerced{Load|Store} trivial. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ae0069f5db96b8ed5adc598d576e695e5ac4134;p=clang make the trivial forms of CreateCoerced{Load|Store} trivial. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107091 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index ec865e58c6..9719dfa432 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -421,6 +421,11 @@ static llvm::Value *CreateCoercedLoad(llvm::Value *SrcPtr, CodeGenFunction &CGF) { const llvm::Type *SrcTy = cast(SrcPtr->getType())->getElementType(); + + // If SrcTy and Ty are the same, just do a load. + if (SrcTy == Ty) + return CGF.Builder.CreateLoad(SrcPtr); + uint64_t DstSize = CGF.CGM.getTargetData().getTypeAllocSize(Ty); if (const llvm::StructType *SrcSTy = dyn_cast(SrcTy)) { @@ -476,11 +481,15 @@ static void CreateCoercedStore(llvm::Value *Src, bool DstIsVolatile, CodeGenFunction &CGF) { const llvm::Type *SrcTy = Src->getType(); - uint64_t SrcSize = CGF.CGM.getTargetData().getTypeAllocSize(SrcTy); - const llvm::Type *DstTy = cast(DstPtr->getType())->getElementType(); - + if (SrcTy == DstTy) { + CGF.Builder.CreateStore(Src, DstPtr, DstIsVolatile); + return; + } + + uint64_t SrcSize = CGF.CGM.getTargetData().getTypeAllocSize(SrcTy); + if (const llvm::StructType *DstSTy = dyn_cast(DstTy)) { DstPtr = EnterStructPointerForCoercedAccess(DstPtr, DstSTy, SrcSize, CGF); DstTy = cast(DstPtr->getType())->getElementType();