From c2f4c34ed8f79b4136f2c03e41ce3ea0c781bc9a Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Wed, 15 Apr 2009 22:11:36 +0000 Subject: [PATCH] Fixup codegen for copy/dispose for block literals. Radar 6791245 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69232 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBlocks.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 5047f06bd2..7a8cd0d822 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -775,7 +775,10 @@ GenerateCopyHelperFunction(bool BlockHasCopyDispose, const llvm::StructType *T, SrcObj = Builder.CreateLoad(SrcObj); llvm::Value *DstObj = CGF.GetAddrOfLocalVar(Dst); - DstObj = Builder.CreateBitCast(DstObj, llvm::PointerType::get(T, 0)); + llvm::Type *PtrPtrT; + PtrPtrT = llvm::PointerType::get(llvm::PointerType::get(T, 0), 0); + DstObj = Builder.CreateBitCast(DstObj, PtrPtrT); + DstObj = Builder.CreateLoad(DstObj); for (unsigned i=0; i < NoteForHelper.size(); ++i) { int flag = NoteForHelper[i].flag; @@ -924,7 +927,8 @@ GeneratebyrefCopyHelperFunction(const llvm::Type *T, int flag) { // dst->x llvm::Value *V = CGF.GetAddrOfLocalVar(Dst); - V = Builder.CreateBitCast(V, T); + V = Builder.CreateBitCast(V, llvm::PointerType::get(T, 0)); + V = Builder.CreateLoad(V); V = Builder.CreateStructGEP(V, 6, "x"); llvm::Value *DstObj = Builder.CreateBitCast(V, PtrToInt8Ty); @@ -983,9 +987,11 @@ BlockFunction::GeneratebyrefDestroyHelperFunction(const llvm::Type *T, CGF.StartFunction(FD, R, Fn, Args, SourceLocation()); llvm::Value *V = CGF.GetAddrOfLocalVar(Src); - V = Builder.CreateBitCast(V, T); + V = Builder.CreateBitCast(V, llvm::PointerType::get(T, 0)); + V = Builder.CreateLoad(V); V = Builder.CreateStructGEP(V, 6, "x"); - V = Builder.CreateBitCast(V, PtrToInt8Ty); + V = Builder.CreateBitCast(V, llvm::PointerType::get(PtrToInt8Ty, 0)); + V = Builder.CreateLoad(V); flag |= BLOCK_BYREF_CALLER; BuildBlockRelease(V, flag);