]> granicus.if.org Git - clang/commitdiff
No write-barrier for initializations.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 27 May 2009 19:54:11 +0000 (19:54 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 27 May 2009 19:54:11 +0000 (19:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72492 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprAgg.cpp
test/CodeGenObjC/objc2-no-write-barrier.m [new file with mode: 0644]

index 59c00528a838bd5bac0105ef0f044564402f015d..af1bbfdd58bc21e7cede18695de4ac68bac690fe 100644 (file)
@@ -459,6 +459,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
 
     // FIXME: volatility
     LValue FieldLoc = CGF.EmitLValueForField(DestPtr, *Field, false, 0);
+    // We never generate write-barries for initialized fields.
+    LValue::SetObjCNonGC(FieldLoc, true);
     if (CurInitVal < NumInitElements) {
       // Store the initializer into the field
       EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc);
diff --git a/test/CodeGenObjC/objc2-no-write-barrier.m b/test/CodeGenObjC/objc2-no-write-barrier.m
new file mode 100644 (file)
index 0000000..2c53509
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: clang-cc -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s &&
+// RUN: grep 'objc_assign' %t | count 0
+
+typedef struct {
+    int ival;
+    id submenu;
+} XCBinderContextMenuItem;
+
+id actionMenuForDataNode(void) {
+    XCBinderContextMenuItem menusToCreate[]  = {
+        {1, 0}
+    };
+    return 0;
+}
+
+XCBinderContextMenuItem GmenusToCreate[]  = {
+        {1, 0}
+};