From: Fariborz Jahanian Date: Sat, 5 Jan 2013 00:32:13 +0000 (+0000) Subject: In my last patch initialize the destination to null (with a simple store) before... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba3c9ca16b3992248ec654ce9ec8c841c1c6d1e9;p=clang In my last patch initialize the destination to null (with a simple store) before doing a storeStrong to it. // rdar://12530881 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171572 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index e33e664430..84d8808bb3 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -1566,6 +1566,8 @@ public: llvm::ConstantPointerNull::get(cast(value->getType())); if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { + llvm::StoreInst *store = CGF.Builder.CreateStore(null, destField); + store->setAlignment(Alignment.getQuantity()); CGF.EmitARCStoreStrongCall(destField, value, /*ignored*/ true); CGF.EmitARCStoreStrongCall(srcField, null, /*ignored*/ true); return; diff --git a/test/CodeGenObjC/arc-unoptimized-byref-var.m b/test/CodeGenObjC/arc-unoptimized-byref-var.m index 4cfc5e9903..080da63ca3 100644 --- a/test/CodeGenObjC/arc-unoptimized-byref-var.m +++ b/test/CodeGenObjC/arc-unoptimized-byref-var.m @@ -7,6 +7,7 @@ void test19() { // CHECK-UNOPT: [[X:%.*]] = getelementptr inbounds [[BYREF_T:%.*]]* [[VAR:%.*]], i32 0, i32 6 // CHECK-UNOPT: [[X2:%.*]] = getelementptr inbounds [[BYREF_T:%.*]]* [[VAR1:%.*]], i32 0, i32 6 // CHECK-UNOPT-NEXT: [[SIX:%.*]] = load i8** [[X2]], align 8 +// CHECK-UNOPT-NEXT: store i8* null, i8** [[X]], align 8 // CHECK-UNOPT-NEXT: call void @objc_storeStrong(i8** [[X]], i8* [[SIX]]) nounwind // CHECK-UNOPT-NEXT: call void @objc_storeStrong(i8** [[X2]], i8* null) nounwind // CHECK-UNOPT-NEXT: ret void