From 855d70cb67eb4fff11fe75a6539350712f946f46 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Tue, 9 May 2017 01:20:05 +0000 Subject: [CodeGen][ObjC] Emit @objc_retain at -O0 for variables captured by blocks. r302270 made changes to avoid emitting clang.arc.use at -O0 and instead emit @objc_release. We also have to emit @objc_retain for the captured variable at -O0 to match the @objc_release instead of just storing the pointer to the capture field. llvm-svn: 302495 --- clang/lib/CodeGen/CGBlocks.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CGBlocks.cpp') diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 2b2a92dd601..2f7f43be924 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -878,7 +878,8 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { // If type is const-qualified, copy the value into the block field. } else if (type.isConstQualified() && - type.getObjCLifetime() == Qualifiers::OCL_Strong) { + type.getObjCLifetime() == Qualifiers::OCL_Strong && + CGM.getCodeGenOpts().OptimizationLevel != 0) { llvm::Value *value = Builder.CreateLoad(src, "captured"); Builder.CreateStore(value, blockField); -- cgit v1.2.3