[cfe-commits] r151133 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGenObjC/arc.m
Eli Friedman
eli.friedman at gmail.com
Tue Feb 21 21:38:59 PST 2012
Author: efriedma
Date: Tue Feb 21 23:38:59 2012
New Revision: 151133
URL: http://llvm.org/viewvc/llvm-project?rev=151133&view=rev
Log:
Make sure null initialization in arrays works correctly with ARC types. <rdar://problem/10907547>.
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/test/CodeGenObjC/arc.m
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=151133&r1=151132&r2=151133&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Tue Feb 21 23:38:59 2012
@@ -853,9 +853,14 @@
return;
if (!CGF.hasAggregateLLVMType(type)) {
- // For non-aggregates, we can store zero
+ // For non-aggregates, we can store zero.
llvm::Value *null = llvm::Constant::getNullValue(CGF.ConvertType(type));
- CGF.EmitStoreThroughLValue(RValue::get(null), lv);
+ // Note that the following is not equivalent to
+ // EmitStoreThroughBitfieldLValue for ARC types.
+ if (lv.isBitField())
+ CGF.EmitStoreThroughBitfieldLValue(RValue::get(null), lv);
+ assert(lv.isSimple());
+ CGF.EmitStoreOfScalar(null, lv, /* isInitialization */ true);
} else {
// There's a potential optimization opportunity in combining
// memsets; that would be easy for arrays, but relatively
Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=151133&r1=151132&r2=151133&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Tue Feb 21 23:38:59 2012
@@ -1533,3 +1533,15 @@
// CHECK: [[T0:%.*]] = load [[TEST69]]** [[SELF]], align 8
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST69]]* [[T0]] to i8*
// CHECK-NEXT: ret i8* [[T1]]
+
+// rdar://problem/10907547
+void test70(id i) {
+ // CHECK: define void @test70
+ // CHECK: store i8* null, i8**
+ // CHECK: store i8* null, i8**
+ // CHECK: [[ID:%.*]] = call i8* @objc_retain(i8*
+ // CHECK: store i8* [[ID]], i8**
+ id x[3] = {
+ [2] = i
+ };
+}
More information about the cfe-commits
mailing list