[llvm-commits] [llvm-gcc-4.2] r60061 - in /llvm-gcc-4.2/trunk: gcc/ gcc/config/ gcc/config/arm/ gcc/config/i386/ gcc/cp/ gcc/objc/ gcc/testsuite/g++.apple/ gcc/testsuite/gcc.apple/ gcc/testsuite/gcc.target/i386/ gcc/testsuite/obj-c++.dg/ gcc/testsuite/objc.dg/ libcpp/ libcpp/include/

Bill Wendling isanbard at gmail.com
Tue Nov 25 14:26:24 PST 2008


Author: void
Date: Tue Nov 25 16:26:23 2008
New Revision: 60061

URL: http://llvm.org/viewvc/llvm-project?rev=60061&view=rev
Log:
Update to latest GCC version. This includes a lot of "blocks" fixes.

Added:
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-block-67.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblock.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblockassign.C
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-67.c
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblock.c
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblockassign.c
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/4299257.c
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-objc2-protocol-3.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/objc2-objc2-protocol-3.m
    llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/ok-unimplemented-anon-category.m
Modified:
    llvm-gcc-4.2/trunk/gcc/ChangeLog.apple
    llvm-gcc-4.2/trunk/gcc/c-common.c
    llvm-gcc-4.2/trunk/gcc/c-common.h
    llvm-gcc-4.2/trunk/gcc/c-decl.c
    llvm-gcc-4.2/trunk/gcc/c-lex.c
    llvm-gcc-4.2/trunk/gcc/c-objc-common.h
    llvm-gcc-4.2/trunk/gcc/c-parser.c
    llvm-gcc-4.2/trunk/gcc/c-pragma.h
    llvm-gcc-4.2/trunk/gcc/config.host
    llvm-gcc-4.2/trunk/gcc/config/arm/arm.c
    llvm-gcc-4.2/trunk/gcc/config/darwin-c.c
    llvm-gcc-4.2/trunk/gcc/config/darwin-sections.def
    llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
    llvm-gcc-4.2/trunk/gcc/config/i386/predicates.md
    llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple
    llvm-gcc-4.2/trunk/gcc/cp/cp-objcp-common.h
    llvm-gcc-4.2/trunk/gcc/cp/decl.c
    llvm-gcc-4.2/trunk/gcc/cp/parser.c
    llvm-gcc-4.2/trunk/gcc/langhooks-def.h
    llvm-gcc-4.2/trunk/gcc/langhooks.c
    llvm-gcc-4.2/trunk/gcc/langhooks.h
    llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple
    llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
    llvm-gcc-4.2/trunk/gcc/stub-objc.c
    llvm-gcc-4.2/trunk/gcc/tree.c
    llvm-gcc-4.2/trunk/gcc/tree.h
    llvm-gcc-4.2/trunk/gcc/version.c
    llvm-gcc-4.2/trunk/libcpp/expr.c
    llvm-gcc-4.2/trunk/libcpp/include/cpplib.h

Modified: llvm-gcc-4.2/trunk/gcc/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ChangeLog.apple?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/ChangeLog.apple (original)
+++ llvm-gcc-4.2/trunk/gcc/ChangeLog.apple Tue Nov 25 16:26:23 2008
@@ -1,3 +1,100 @@
+2008-11-18  Stuart Hastings  <stuart at apple.com>
+
+	Radar 6353006
+	* tree.c (generic_block_literal_struct_type): Fix APPLE LOCAL.
+	* langhooks-def.h (lhd_build_generic_block_struct_type): Fix
+          APPLE LOCAL.
+
+2008-11-12  Caroline Tice  <ctice at apple.com>
+
+       * tree.c (generic_block_literal_struct_type):  Move global variable
+       decl here from  c-common.c.
+       (build_block_pointer_type):  Change call to
+       build_generic_block_struct_type to go through lang_hooks.
+       * tree.h:  Remove extern function dec, for
+       build_generic_block_struct_type.
+       * cp/cp-objcp-common.h:  Define c++-specific version of
+       LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE.
+       * cp/parser.c (build_generic_block_struct_type):  Rename function to
+       c_build_generic_block_struct_type.
+       * c-objc-common.h:  Define c-specific version of
+       LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE.
+       * langhooks.c (lhd_build_generic_block_struct_type):  New generic
+       function.
+       * langhooks.h (struct lang_hooks):  Add new function field,
+       build_generic_block_struct_type.
+       * c-common.c (generic_block_literal_struct_type): Move global variable
+       decl from here to tree.c.
+       * c-common.h  (c_build_generic_block_struct_type):  New extern
+       function decl.
+       * c-parser.c (build_generic_block_struct_type):  Rename function to
+       c_build_generic_block_struct_type.
+       * langhooks-def.h (lhd_build_generic_block_struct_type):  New extern
+       function decl.
+       (LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE):  New variable
+       definition.
+       (LANG_HOOKS_INITIALIZER):  Initialize new field to
+       LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
+
+2008-11-11  Fariborz Jahanian <fjahanian at apple.com>
+
+        Radar 6351990
+	* config/darwin.c (machopic_select_section): Accomodate change
+	for meta-data prefix name.
+	* config/darwin-sections.def (__objc_protorefs, __objc_protolist):
+	These sections are now coalesced.
+
+2008-11-11  Stuart Hastings  <stuart at apple.com>
+
+	Radar 4299257
+	* config/i386/i386.c (bdesc_com): Move ucomXX instructions
+	  from here...  (bdesc_ucomi): ...to here.  New.
+	  (ix86_init_mmx_sse_builtins): Add a loop to walk
+	  bdesc_ucomi[] and instantiate ucomiXX builtins.
+	  (ix86_expand_sse_ucomi): New.  (ix86_expand_builtin): Call
+	  it.
+
+2008-11-07  Fariborz Jahanian <fjahanian at apple.com>
+
+        Radar 5847976
+	* c-decl.c (synth_block_byref_id_object_copy_func): Takes a new
+	'flag' argument and generates the much simplified API.
+	(synth_block_byref_id_object_dispose_func): Ditto.
+	(new_block_byref_decl): Hack to prevent issuing bogus warning
+	on a field declared as __weak.
+	(init_byref_decl): Takes an additional 'flag' argument
+	and passes it down to synth_block_byref_id_object_copy_func and
+	synth_block_byref_id_object_dispose_func.
+	(finish_decl): Computes the flag for the block variable declaration.
+	* c-common.c (build_block_byref_release_decl, 
+	build_block_byref_assign_copy_decl): Removed.
+	(build_block_byref_release_exp): Use the new API.
+	(build_block_object_assign_decl, build_block_object_assign_call_exp,
+	build_block_object_dispose_decl, build_block_object_dispose_call_exp): New.			
+	(build_indirect_object_id_exp): Fixed a code gen bug which was exposed in
+	c/c++ mode, but not in ObjC/ObjC++ mode.
+	* c-common.h (build_block_object_assign_call_exp,
+	build_block_object_dispose_call_exp,
+	objc_is_gcable_type): New decls.
+	Declaration of several new flags.
+	(cast_to_pointer_to_id): Removed.
+	* stub-objc.c (objc_is_gcable_type): New
+	(copy_in_object, retain_block_component, release_block_component): Removed.
+	(cast_to_pointer_to_id): Removed.
+	* c-parser.c (build_block_struct_initlist): Remove call to copy_in_object.
+	(synth_copy_helper_block_func): Generates much simplified API.
+	(synth_destroy_helper_block_func): Ditto.
+	(block_object_dispose): Removed.
+	* config/darwin-c.c (darwin_cpp_builtins): Define __weak even when
+	-fobjc-gc is off.
+
+2008-11-4   Jim Grosbach <grosbach at apple.com>
+
+	Radar 6327222
+	* config/arm/arm.c (legitimize_pic_address): Be more generous about
+	constants when the operand is of the form  (const (plus (something)
+	(const)).
+
 2008-10-31  Stuart Hastings  <stuart at apple.com>
 
 	Radar 5813921

Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Tue Nov 25 16:26:23 2008
@@ -6161,7 +6161,7 @@
 /* APPLE LOCAL begin blocks 6040305 */
 
 /* This routine builds:
-   *(id *)(EXP+20) expression which references the object id pointer.
+   *(void **)(EXP+20) expression which references the object pointer.
 */
 tree
 build_indirect_object_id_exp (tree exp)
@@ -6169,7 +6169,7 @@
   tree dst_obj;
   int  int_size = int_cst_value (TYPE_SIZE_UNIT (unsigned_type_node));
   int offset;
-  /* dst->object = [src->object retail]; In thid case 'object' is the field
+  /* dst->object In thid case 'object' is the field
    of the object passed offset by: void * + void* + int + int + void* + void *
    This must match definition of Block_byref structs. */
   /* APPLE LOCAL radar 6244520 */
@@ -6179,74 +6179,23 @@
   dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
                     build_int_cst (NULL_TREE, offset));
   /* APPLE LOCAL begin radar 6180456 */
-  if (c_dialect_objc ())
-    {
-      /* Type case to: 'id *' */
-      dst_obj = cast_to_pointer_to_id (dst_obj);
-      dst_obj = build_indirect_ref (dst_obj, "unary *");
-    }
+  /* Type case to: 'void **' */
+  dst_obj = build_c_cast (build_pointer_type (ptr_type_node), dst_obj);
+  dst_obj = build_indirect_ref (dst_obj, "unary *");
   /* APPLE LOCAL end radar 6180456 */
   return dst_obj;
 }
 
-/* APPLE LOCAL begin radar 6180456 */
-static tree block_byref_release_decl;
-
-/* Build a: void _Block_byref_release (void *) if not done
-  already. */
-tree
-build_block_byref_release_decl (void)
-{
-  if (!block_byref_release_decl &&
-      !(block_byref_release_decl =
-        lookup_name (get_identifier ("_Block_byref_release"))))
-  {
-    tree func_type =
-    build_function_type (void_type_node,
-                         tree_cons (NULL_TREE, ptr_type_node, void_list_node));
-
-    block_byref_release_decl =
-      builtin_function ("_Block_byref_release", func_type, 0, NOT_BUILT_IN, 
-			0, NULL_TREE);
-
-    TREE_NOTHROW (block_byref_release_decl) = 0;
-  }
-  return block_byref_release_decl;
-}
-/* APPLE LOCAL end radar 6180456 */
-
-static tree block_byref_assign_copy_decl;
-tree
-build_block_byref_assign_copy_decl (void)
-{
-  /* Build a: void _Block_byref_assign_copy (void *, void *) if not done already. */
-  if (!block_byref_assign_copy_decl
-      && !(block_byref_assign_copy_decl
-             = lookup_name (get_identifier ("_Block_byref_assign_copy"))))
-    {
-      tree func_type
-        = build_function_type (void_type_node,
-                               tree_cons (NULL_TREE, ptr_type_node,
-                                          tree_cons (NULL_TREE, ptr_type_node, void_list_node)));
-
-      block_byref_assign_copy_decl
-        = builtin_function ("_Block_byref_assign_copy", func_type,
-                            0, NOT_BUILT_IN, 0, NULL_TREE);
-      TREE_NOTHROW (block_byref_assign_copy_decl) = 0;
-    }
-  return block_byref_assign_copy_decl;
-}
-
 /* This routine builds call to:
- _Block_byref_release(VAR_DECL.__forwarding);
+ _Block_object_dispose(VAR_DECL.__forwarding, BLOCK_FIELD_IS_BYREF);
  and adds it to the statement list.
  */
 tree
 build_block_byref_release_exp (tree var_decl)
 {
-  tree exp = var_decl, call_exp, func_params;
+  tree exp = var_decl, call_exp;
   tree type = TREE_TYPE (var_decl);
-  /* __block variables imported into Blocks are not _Block_byref_released()
+  /* __block variables imported into Blocks are not _Block_object_dispose()
    from within the Block statement itself; otherwise, each envokation of
    the block causes a release. Make sure to release __block variables declared 
    and used locally in the block though. */
@@ -6261,10 +6210,9 @@
   }
   TREE_USED (var_decl) = 1;
 
-  /* Declare: _Block_byref_release(void*) if not done already. */
+  /* Declare: _Block_object_dispose(void*, BLOCK_FIELD_IS_BYREF) if not done already. */
   exp = build_component_ref (exp, get_identifier ("__forwarding"));
-  func_params = tree_cons (NULL_TREE, exp, NULL_TREE);
-  call_exp = build_function_call (build_block_byref_release_decl (), func_params);
+  call_exp = build_block_object_dispose_call_exp (exp, BLOCK_FIELD_IS_BYREF);
   return call_exp;
 }
 /* APPLE LOCAL end blocks 6040305 */
@@ -9189,4 +9137,81 @@
 }
 /* APPLE LOCAL end radar 6246527 */
 
+/* APPLE LOCAL begin radar 5847976 */
+static GTY(()) tree block_object_assign_decl;
+static GTY(()) tree block_object_dispose_func_decl;
+/* This routine declares:
+   void _Block_object_assign (void *, void *, int) or uses an
+   existing one.
+*/
+static tree
+build_block_object_assign_decl (void)
+{
+  tree func_type;
+  if (block_object_assign_decl)
+    return block_object_assign_decl;
+  block_object_assign_decl = lookup_name (get_identifier ("_Block_object_assign"));
+  if (block_object_assign_decl)
+    return block_object_assign_decl;
+  func_type =
+            build_function_type (void_type_node,
+              tree_cons (NULL_TREE, ptr_type_node,
+                         tree_cons (NULL_TREE, ptr_type_node,
+                                    tree_cons (NULL_TREE, integer_type_node, void_list_node))));
+
+  block_object_assign_decl = builtin_function ("_Block_object_assign", func_type,
+                                               0, NOT_BUILT_IN, 0, NULL_TREE);
+  TREE_NOTHROW (block_object_assign_decl) = 0;
+  return block_object_assign_decl;
+}
+
+/* This routine builds:
+   _Block_object_assign(dest, src, flag)
+*/
+tree build_block_object_assign_call_exp (tree dst, tree src, int flag)
+{
+  tree func_params = tree_cons (NULL_TREE, dst,
+                               tree_cons (NULL_TREE, src,
+                                          tree_cons (NULL_TREE,
+                                                     build_int_cst (integer_type_node, flag),
+                                                     NULL_TREE)));
+  return build_function_call (build_block_object_assign_decl (), func_params);
+}
+
+/* This routine declares:
+   void _Block_object_dispose (void *, int) or uses an
+   existing one.
+*/
+static tree
+build_block_object_dispose_decl (void)
+{
+  tree func_type;
+  if (block_object_dispose_func_decl)
+    return block_object_dispose_func_decl;
+  block_object_dispose_func_decl = lookup_name (get_identifier ("_Block_object_dispose"));
+  if (block_object_dispose_func_decl)
+    return block_object_dispose_func_decl;
+  func_type =
+      build_function_type (void_type_node,
+                           tree_cons (NULL_TREE, ptr_type_node,
+                                      tree_cons (NULL_TREE, integer_type_node, void_list_node)));
+
+  block_object_dispose_func_decl = builtin_function ("_Block_object_dispose", func_type,
+                                       		     0, NOT_BUILT_IN, 0, NULL_TREE);
+  TREE_NOTHROW (block_object_dispose_func_decl) = 0;
+  return block_object_dispose_func_decl;
+}
+
+/* This routine builds the call tree:
+   _Block_object_dispose(src, flag)
+*/
+tree build_block_object_dispose_call_exp (tree src, int flag)
+{
+  tree func_params = tree_cons (NULL_TREE, src, 
+			        tree_cons (NULL_TREE,
+                                           build_int_cst (integer_type_node, flag),
+                                           NULL_TREE));
+  return build_function_call (build_block_object_dispose_decl (), func_params);
+}
+/* APPLE LOCAL end radar 5847976 */
 #include "gt-c-common.h"

Modified: llvm-gcc-4.2/trunk/gcc/c-common.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.h (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.h Tue Nov 25 16:26:23 2008
@@ -1022,6 +1022,11 @@
 extern void objc_start_category_implementation (tree, tree);
 /* APPLE LOCAL radar 4592503 */
 extern void objc_checkon_weak_attribute (tree);
+/* APPLE LOCAL begin radar 5847976 */
+extern tree build_block_object_assign_call_exp (tree, tree, int);
+extern tree build_block_object_dispose_call_exp (tree, int);
+extern int objc_is_gcable_type (tree);
+/* APPLE LOCAL end radar 5847976 */
 extern void objc_continue_implementation (void);
 extern void objc_finish_implementation (void);
 extern void objc_set_visibility (int);
@@ -1120,6 +1125,15 @@
 extern tree vector_constructor_from_expr (tree, tree);
 /* APPLE LOCAL end AltiVec */
 
+/* APPLE LOCAL begin radar 5847976 */
+/* Runtime support functions used by compiler when generating copy/dispose helpers */
+enum {
+    BLOCK_FIELD_IS_OBJECT   =  3,  /* id, NSObject, __attribute__((NSObject)), block, ... */
+    BLOCK_FIELD_IS_BLOCK    =  7,  /* a block variable */
+    BLOCK_FIELD_IS_BYREF    =  8,  /* the on stack structure holding the __block variable */
+    BLOCK_FIELD_IS_WEAK     = 16   /* declared __weak, only used in byref copy helpers */
+};
+/* APPLE LOCAL end radar 5847976 */
 /* APPLE LOCAL begin radar 5732232 - blocks */
 enum {
      BLOCK_NEEDS_FREE =        (1 << 24),
@@ -1183,10 +1197,7 @@
 extern void start_block_helper_function (tree func_decl);
 extern void block_build_prologue (struct block_sema_info *block_impl);
 extern tree c_finish_return (tree);
-extern tree copy_in_object (tree);
 extern bool block_requires_copying (tree);
-extern tree retain_block_component (tree);
-extern tree release_block_component (tree);
 /* APPLE LOCAL begin radar 5803600 */
 extern void add_block_global_byref_list (tree);
 extern bool in_block_global_byref_list (tree);
@@ -1195,7 +1206,6 @@
 /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
 extern tree build_byref_local_var_access (tree, tree);
 extern tree do_digest_init (tree, tree);
-extern tree cast_to_pointer_to_id (tree);
 /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
 /* APPLE LOCAL begin radar 6237713 */
 extern bool any_recognized_block_attribute (tree);
@@ -1206,8 +1216,6 @@
 /* APPLE LOCAL end radar 5847213 */
 /* APPLE LOCAL begin radar 6083129 - byref escapes */
 extern tree build_block_byref_release_exp (tree);
-extern tree build_block_byref_release_decl (void);
-extern tree build_block_byref_assign_copy_decl (void);
 /* APPLE LOCAL end radar 6083129 - byref escapes */
 
 /* APPLE LOCAL radar 6040305 - blocks */
@@ -1220,6 +1228,9 @@
 /* APPLE LOCAL radar 6160536 */
 extern tree build_block_helper_name (int);
 
+/* APPLE LOCAL radar 6353006  */
+extern tree c_build_generic_block_struct_type (void);
+
 /* In c-omp.c  */
 extern tree c_finish_omp_master (tree);
 extern tree c_finish_omp_critical (tree, tree);

Modified: llvm-gcc-4.2/trunk/gcc/c-decl.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-decl.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-decl.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-decl.c Tue Nov 25 16:26:23 2008
@@ -3582,17 +3582,17 @@
 
  void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
 				   struct Block_byref_id_object *src) {
-   dst->object = [src->object retain];  // objective-c only
-   _Block_byref_assign_copy(&_dest->object, _src->object)  // or: c language
+   _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
+   _Block_object_assign(&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK])  // blocks
  }  */
 static void
-synth_block_byref_id_object_copy_func (void)
+synth_block_byref_id_object_copy_func (int flag)
 {
   tree stmt, fnbody;
   tree dst_arg, src_arg;
   tree dst_obj, src_obj;
   struct c_arg_info * arg_info;
-
+  tree call_exp;
   gcc_assert (block_byref_id_object_copy);
   /* Set up: (void* _dest, void*_src) parameters. */
   dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
@@ -3625,23 +3625,10 @@
   src_obj = build_indirect_object_id_exp (src_arg);
 
   /* APPLE LOCAL begin radar 6180456 */
-  if (c_dialect_objc ())
-    {
-      tree retain_exp = retain_block_component (src_obj);
-
-      /* dst->object = [src->object retain]; */
-      tree store = build_modify_expr (dst_obj, NOP_EXPR, retain_exp);
-      add_stmt (store);
-    }
-  else 
-    {
-      /* _Block_byref_assign_copy(&_dest->object, _src->object) */
-      tree func_params = tree_cons (NULL_TREE, build_fold_addr_expr (dst_obj),
-                                    tree_cons (NULL_TREE, src_obj,
-                                               NULL_TREE));
-      tree call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
-      add_stmt (call_exp);
-    }
+  /* _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT) or :
+     _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK) */
+  call_exp = build_block_object_assign_call_exp (build_fold_addr_expr (dst_obj), src_obj, flag);
+  add_stmt (call_exp);
   /* APPLE LOCAL end radar 6180456 */
 
   fnbody = c_end_compound_stmt (stmt, true);
@@ -3655,16 +3642,15 @@
   This routine builds:
 
   void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
-    [_src->object release];   // objective-c or:
-    _Block_byref_release(_src->object) // c language
+    _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // object
+    _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // block
   }  */
 static void
-synth_block_byref_id_object_dispose_func (void)
+synth_block_byref_id_object_dispose_func (int flag)
 {
   tree stmt, fnbody;
   tree src_arg, src_obj, rel_exp;
   struct c_arg_info * arg_info;
-
   gcc_assert (block_byref_id_object_dispose);
   /* Set up: (void *_src) parameter. */
   src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
@@ -3685,15 +3671,9 @@
   src_obj = build_indirect_object_id_exp (src_arg);
 
   /* APPLE LOCAL begin radar 6180456 */
-  if (c_dialect_objc ())
-    /* [_src->object release]; */
-    rel_exp = release_block_component (src_obj);
-  else
-    {
-      /* _Block_byref_release(_src->object) */
-      tree func_params = tree_cons (NULL_TREE, src_obj, NULL_TREE);
-      rel_exp = build_function_call (build_block_byref_release_decl (), func_params);
-    }
+  /* _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT) : or
+     _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK) */
+  rel_exp = build_block_object_dispose_call_exp (src_obj, flag);
   /* APPLE LOCAL end radar 6180456 */
   add_stmt (rel_exp);
 
@@ -3722,6 +3702,8 @@
 new_block_byref_decl (tree decl)
 {
   static int unique_count;
+  /* APPLE LOCAL radar 5847976 */
+  int save_flag_objc_gc;
   tree Block_byref_type;
   tree field_decl_chain, field_decl;
   const char *prefix = "__Block_byref_";
@@ -3774,7 +3756,13 @@
   chainon (field_decl_chain, field_decl);
 
   pop_from_top_level ();
+  /* APPLE LOCAL begin radar 5847976 */
+  /* Hack so we don't issue warning on a field_decl having __weak attribute */
+  save_flag_objc_gc = flag_objc_gc;
+  flag_objc_gc = 0;
   finish_struct (Block_byref_type, field_decl_chain, NULL_TREE);
+  flag_objc_gc = save_flag_objc_gc;
+  /* APPLE LOCAL end radar 5847976 */
 
   TREE_TYPE (decl) = Block_byref_type;
   /* Force layout_decl to recompute these fields. */
@@ -3798,7 +3786,8 @@
      &initializer-expr};
 */
 static tree
-init_byref_decl (tree decl, tree init)
+/* APPLE LOCAL radar 5847976 */
+init_byref_decl (tree decl, tree init, int flag)
 {
   tree initlist;
   tree block_byref_type = TREE_TYPE (decl);
@@ -3811,7 +3800,10 @@
 
   fields = TYPE_FIELDS (block_byref_type);
   /* APPLE LOCAL begin radar 6244520 */
-  initlist = tree_cons (fields, fold_convert (ptr_type_node, integer_zero_node), 0);
+  /* APPLE LOCAL begin radar 5847976 */
+  initlist = tree_cons (fields, fold_convert (ptr_type_node, ((flag & BLOCK_FIELD_IS_WEAK) != 0) ? integer_one_node 
+									        : integer_zero_node), 0);
+  /* APPLE LOCAL end radar 5847976 */
   fields = TREE_CHAIN (fields);
 
   initlist = tree_cons (fields,
@@ -3843,7 +3835,7 @@
 	  block_byref_id_object_copy = build_helper_func_decl (get_identifier (name),
 							       func_type);
 	  /* Synthesize function definition. */
-	  synth_block_byref_id_object_copy_func ();
+	  synth_block_byref_id_object_copy_func (flag);
 	}
       initlist = tree_cons (fields,
 			    build_fold_addr_expr (block_byref_id_object_copy),
@@ -3861,7 +3853,7 @@
 	  block_byref_id_object_dispose = build_helper_func_decl (get_identifier (name),
 								  func_type);
 	  /* Synthesize function definition. */
-	  synth_block_byref_id_object_dispose_func ();
+	  synth_block_byref_id_object_dispose_func (flag);
 	}
       initlist = tree_cons (fields,
 			    build_fold_addr_expr (block_byref_id_object_dispose),
@@ -3919,6 +3911,16 @@
 	}
       else
 	{
+          int flag = 0;
+          if (objc_is_gcable_type (TREE_TYPE (decl)) == -1)
+	    flag = BLOCK_FIELD_IS_WEAK;
+	  if (block_requires_copying (decl))
+	    {
+	      if (TREE_CODE (TREE_TYPE (decl)) == BLOCK_POINTER_TYPE)
+		flag |= BLOCK_FIELD_IS_BLOCK;
+	      else 
+		flag |= BLOCK_FIELD_IS_OBJECT;
+	    }
 	  decl = new_block_byref_decl (decl);
 	  /* APPLE LOCAL begin radar 6289031 */
 	  if (! flag_objc_gc_only)
@@ -3926,8 +3928,10 @@
               push_cleanup (decl, build_block_byref_release_exp (decl), false);
 	    }
 	  /* APPLE LOCAL end radar 6289031 */
-
-	  init = init_byref_decl (decl, init);
+          /* APPLE LOCAL begin radar 5847976 */
+	  COPYABLE_WEAK_BLOCK (decl) = ((flag & BLOCK_FIELD_IS_WEAK) != 0);
+	  init = init_byref_decl (decl, init, flag);
+          /* APPLE LOCAL end radar 5847976 */
 	}
     }
   /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ cq) */
@@ -7907,6 +7911,8 @@
     {
       COPYABLE_BYREF_LOCAL_VAR (byref_decl) = 1;
       COPYABLE_BYREF_LOCAL_NONPOD (byref_decl) = COPYABLE_BYREF_LOCAL_NONPOD (decl);
+      /* APPLE LOCAL radar 5847976 */
+      COPYABLE_WEAK_BLOCK (byref_decl) = COPYABLE_WEAK_BLOCK (decl);
     }
   /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
 

Modified: llvm-gcc-4.2/trunk/gcc/c-lex.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-lex.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-lex.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-lex.c Tue Nov 25 16:26:23 2008
@@ -372,7 +372,8 @@
    non-NULL.  */
 
 enum cpp_ttype
-c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
+/* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, int defer)
 {
   static bool no_more_pch;
   const cpp_token *tok;
@@ -474,18 +475,24 @@
 
     case CPP_NUMBER:
       {
-	unsigned int flags = cpp_classify_number (parse_in, tok);
+	/* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+	unsigned int flags = cpp_classify_number (parse_in, tok, defer);
 
 	switch (flags & CPP_N_CATEGORY)
 	  {
 	  case CPP_N_INVALID:
+	    /* APPLE LOCAL begin CW asm blocks C++ comments 6338079 */
+	    if (flags & CPP_N_DEFER)
+	      {
+		add_flags = ERROR_DEFERRED;
+		*value = error_mark_node;
+		break;
+	      }
+	    /* APPLE LOCAL end CW asm blocks C++ comments 6338079 */
+
 	    /* cpplib has issued an error.  */
 	    *value = error_mark_node;
-	    /* APPLE LOCAL begin CW asm blocks 6276214 */
-	    /* If errors are deferred, they don't count as errors yet.  */
-	    if (!flag_ms_asms)
-	      errorcount++;
-	    /* APPLE LOCAL end CW asm blocks 6276214 */
+	    errorcount++;
 	    break;
 
 	  case CPP_N_INTEGER:
@@ -611,7 +618,7 @@
 	/* Because we don't recognize inline asm commments during
 	   lexing, we have to pass this back to the parser to error
 	   out with or eat as a comment as appropriate.  */
-	if (flag_iasm_blocks_local)
+	if (defer && flag_iasm_blocks_local)
 	  {
 	    *value = build_int_cst_wide (char_type_node, c, 0);
 	    break;

Modified: llvm-gcc-4.2/trunk/gcc/c-objc-common.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-objc-common.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-objc-common.h (original)
+++ llvm-gcc-4.2/trunk/gcc/c-objc-common.h Tue Nov 25 16:26:23 2008
@@ -140,4 +140,10 @@
 #undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
 #define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P c_vla_unspec_p
 
+/* APPLE LOCAL begin radar 6353006  */
+#undef LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
+#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
+  c_build_generic_block_struct_type
+/* APPLE LOCAL end radar 6353006  */
+
 #endif /* GCC_C_OBJC_COMMON */

Modified: llvm-gcc-4.2/trunk/gcc/c-parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-parser.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-parser.c Tue Nov 25 16:26:23 2008
@@ -389,7 +389,7 @@
   timevar_push (TV_LEX);
 
   /* APPLE LOCAL CW asm blocks */
-  token->type = c_lex_with_flags (&token->value, &token->location, &token->flags);
+  token->type = c_lex_with_flags (&token->value, &token->location, &token->flags, 0);
   token->id_kind = C_ID_NONE;
   token->keyword = RID_MAX;
   token->pragma_kind = PRAGMA_NONE;
@@ -5499,15 +5499,6 @@
   switch (c_parser_peek_token (parser)->type)
     {
     case CPP_NUMBER:
-      /* APPLE LOCAL begin CW asm blocks (in 4.2 ak) */
-      if (cpp_get_options (parse_in)->h_suffix
-	  && c_parser_peek_token (parser)->value == error_mark_node)
-	{
-	  /* This was previously deferred.  */
-	  cpp_error (parse_in, CPP_DL_ERROR, "invalid suffix on integer constant");
-	  c_parser_consume_token (parser);
-	}
-      /* APPLE LOCAL end CW asm blocks (in 4.2 ak) */
     case CPP_CHAR:
     case CPP_WCHAR:
       expr.value = c_parser_peek_token (parser)->value;
@@ -9326,7 +9317,9 @@
 	{
 	  /* (in 4.2 an) */
 	  aname = c_parser_iasm_identifier (parser);
-	  if (c_parser_next_token_is (parser, CPP_COLON))
+	  if (aname == error_mark_node)
+	    c_parser_consume_token (parser);
+	  else if (c_parser_next_token_is (parser, CPP_COLON))
 	    {
 	      c_parser_consume_token (parser);
 	      iasm_label (aname, false);
@@ -9366,12 +9359,6 @@
 }
 /* APPLE LOCAL end CW asm blocks */
 /* APPLE LOCAL begin radar 5732232 - blocks (C++ ce) */
-/* APPLE LOCAL begin radar 6175959 */
-static GTY(()) tree block_copy_assign_decl;
-static GTY(()) tree block_object_assign_decl;
-static GTY(()) tree block_destroy_decl;
-static GTY(()) tree block_object_dispose_func_decl;
-/* APPLE LOCAL end radar 6175959 */
 
 /* APPLE LOCAL begin radar 6300081  */
 
@@ -9406,7 +9393,8 @@
 */
 
 tree
-build_generic_block_struct_type (void)
+/* APPLE LOCAL radar 6353006  */
+c_build_generic_block_struct_type (void)
 {
   tree field_decl_chain;
   tree field_decl;
@@ -9728,7 +9716,7 @@
       tree y = TREE_VALUE (chain);
       TREE_USED (y) = 1;
       fields = TREE_CHAIN (fields);
-      initlist = tree_cons (fields, copy_in_object (y), initlist);
+      initlist = tree_cons (fields, y, initlist);
     }
   for (chain = block_impl->block_byref_decl_list; chain;
        chain = TREE_CHAIN (chain))
@@ -9898,8 +9886,8 @@
     if (block_requires_copying (TREE_VALUE (chain)))
     {
       /* APPLE LOCAL begin radar 6175959 */
-      tree which_function_decl;
-      tree func_params, call_exp;
+      int flag;
+      tree call_exp;
       tree p = TREE_VALUE (chain);
       tree dst_block_component, src_block_component;
       dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
@@ -9908,66 +9896,26 @@
 						 DECL_NAME (p));
 
       if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
-      {
-        /* _Block_copy_assign(&_dest->myImportedBlock, _src->myImportedClosure, 0) */
-        /* Build a: void _Block_copy_assign (void *, void *, int) if not done
-           already. */
-        /* APPLE LOCAL begin radar 6310599 */
-        if (!block_copy_assign_decl &&
-	    !(block_copy_assign_decl = lookup_name (get_identifier ("_Block_copy_assign"))))
-        /* APPLE LOCAL end radar 6310599 */
-        {
-          tree func_type =
-            build_function_type (void_type_node,
-              tree_cons (NULL_TREE, ptr_type_node,
-                         tree_cons (NULL_TREE, ptr_type_node, 
-				    tree_cons (NULL_TREE, integer_type_node, void_list_node))));
-
-          block_copy_assign_decl = builtin_function ("_Block_copy_assign", func_type,
-						     0, NOT_BUILT_IN, 0, NULL_TREE);
-          TREE_NOTHROW (block_copy_assign_decl) = 0;
-        }
-	which_function_decl = block_copy_assign_decl;
-      }
+        /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_BLOCK) */
+        flag = BLOCK_FIELD_IS_BLOCK;
       else
-      {
-        /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, 0) */
-        /* Build a: void _Block_object_assign (void *, void *, int) if not done
-           already. */
-        if (!block_object_assign_decl &&
-	    !(block_object_assign_decl = lookup_name (get_identifier ("_Block_object_assign"))))
-        {
-          tree func_type =
-            build_function_type (void_type_node,
-              tree_cons (NULL_TREE, ptr_type_node,
-                         tree_cons (NULL_TREE, ptr_type_node, 
-				    tree_cons (NULL_TREE, integer_type_node, void_list_node))));
-
-          block_object_assign_decl = builtin_function ("_Block_object_assign", func_type,
-						     0, NOT_BUILT_IN, 0, NULL_TREE);
-          TREE_NOTHROW (block_object_assign_decl) = 0;
-        }
-	which_function_decl = block_object_assign_decl;
-      }
+        /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_OBJECT) */
+        flag = BLOCK_FIELD_IS_OBJECT;
       dst_block_component = build_fold_addr_expr (dst_block_component);
-      func_params = tree_cons (NULL_TREE, dst_block_component,
-                               tree_cons (NULL_TREE, src_block_component,
-                                          tree_cons (NULL_TREE, 
-				                     build_int_cst (integer_type_node, 0), 
-				       		     NULL_TREE)));
-      call_exp = build_function_call (which_function_decl, func_params);
+      call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
       add_stmt (call_exp);
       /* APPLE LOCAL end radar 6175959 */
     }
 
   /* For each __block declared variable must generate call to:
-     _Block_byref_assign_copy(&_dest->myImportedBlock, _src->myImportedBlock)
+     _Block_object_assign(&_dest->myImportedBlock, _src->myImportedBlock, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK])
   */
   for (chain = block_impl->block_byref_decl_list; chain;
          chain = TREE_CHAIN (chain))
     if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
       {
-	tree func_params, call_exp;
+        int flag = BLOCK_FIELD_IS_BYREF;
+	tree call_exp;
 	tree p = TREE_VALUE (chain);
 	tree dst_block_component, src_block_component;
 	dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
@@ -9975,12 +9923,12 @@
 	src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
 						   DECL_NAME (p));
 
-	/* _Block_byref_assign_copy(&_dest->myImportedClosure, _src->myImportedClosure) */
+	/* _Block_object_assign(&_dest->myImportedClosure, _src->myImportedClosure, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK]) */
+        if (COPYABLE_WEAK_BLOCK (p))
+	  flag |= BLOCK_FIELD_IS_WEAK;
+        
 	dst_block_component = build_fold_addr_expr (dst_block_component);
-	func_params = tree_cons (NULL_TREE, dst_block_component,
-				 tree_cons (NULL_TREE, src_block_component,
-					    NULL_TREE));
-	call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
+	call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
 	add_stmt (call_exp);
       }
 
@@ -9991,30 +9939,6 @@
   free (arg_info);
 }
 
-/* APPLE LOCAL begin radar 6175959 */
-static tree 
-block_object_dispose (tree src_block_component)
-{
-  tree func_params;
-  if (!block_object_dispose_func_decl &&
-      !(block_object_dispose_func_decl = lookup_name (get_identifier ("_Block_object_dispose"))))
-    {
-      tree func_type =
-      build_function_type (void_type_node,
-                           tree_cons (NULL_TREE, ptr_type_node,
-                                      tree_cons (NULL_TREE, integer_type_node, void_list_node)));
-
-      block_object_dispose_func_decl = builtin_function ("_Block_object_dispose", func_type,
-                                       0, NOT_BUILT_IN, 0, NULL_TREE);
-     TREE_NOTHROW (block_object_dispose_func_decl) = 0;
-    }
-    func_params = tree_cons (NULL_TREE, src_block_component,
-                             tree_cons (NULL_TREE,
-                                        build_int_cst (integer_type_node, 0), NULL_TREE));
-    return build_function_call (block_object_dispose_func_decl, func_params);
-}
-/* APPLE LOCAL end radar 6175959 */
-
 static void
 synth_destroy_helper_block_func (struct block_sema_info * block_impl)
 {
@@ -10042,64 +9966,41 @@
        chain = TREE_CHAIN (chain))
     if (block_requires_copying (TREE_VALUE (chain)))
     {
-      /* APPLE LOCAL begin radar 6175959 */
+      int flag;
+      tree rel_exp;
       tree p = TREE_VALUE (chain);
       tree src_block_component;
       src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
 						 DECL_NAME (p));
 
       if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
-      {
-        tree func_params, call_exp;
-        /* _Block_destroy(_src->myImportedClosure); */
-        /* _Block_destroy (void *); */
-        /* Build a: void _Block_destroy (void *) if not done already. */
-        if (!block_destroy_decl &&
-	    !(block_destroy_decl = lookup_name (get_identifier ("_Block_destroy"))))
-        {
-          tree func_type =
-          build_function_type (void_type_node,
-                               tree_cons (NULL_TREE, ptr_type_node, 
-					  tree_cons (NULL_TREE, integer_type_node, void_list_node)));
-
-          block_destroy_decl = builtin_function ("_Block_destroy", func_type,
-						 0, NOT_BUILT_IN, 0, NULL_TREE);
-          TREE_NOTHROW (block_destroy_decl) = 0;
-        }
-        func_params = tree_cons (NULL_TREE, src_block_component, 
-				 tree_cons (NULL_TREE, 
-					    build_int_cst (integer_type_node, 0), NULL_TREE));
-        call_exp = build_function_call (block_destroy_decl, func_params);
-        add_stmt (call_exp);
-      }
+	/* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_BLOCK); */
+        flag = BLOCK_FIELD_IS_BLOCK;
       else
-      {
-        tree rel_exp;
-	/* _Block_object_dispose(_src->imported_object_0, 0); */
-        rel_exp = block_object_dispose (src_block_component);
-        add_stmt (rel_exp);
-      }
-      /* APPLE LOCAL end radar 6175959 */
+	/* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_OBJECT); */
+	flag = BLOCK_FIELD_IS_OBJECT;
+      rel_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+      add_stmt (rel_exp);
     }
 
   /* For each __block declared variable must generate call to:
-   _Block_byref_release(_src->myImportedClosure)
+   _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK])
    */
   for (chain = block_impl->block_byref_decl_list; chain;
        chain = TREE_CHAIN (chain))
     if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
       {
-	tree func_params, call_exp;
+	tree call_exp;
+        int flag = BLOCK_FIELD_IS_BYREF;
 	tree p = TREE_VALUE (chain);
 	tree src_block_component;
 
 	src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
 						   DECL_NAME (p));
-      /* _Block_byref_release(_src->myImportedClosure) */
-      /* Build a: void _Block_byref_release (void *) if not done
-	 already. */
-      func_params = tree_cons (NULL_TREE, src_block_component, NULL_TREE);
-      call_exp = build_function_call (build_block_byref_release_decl (), func_params);
+        if (COPYABLE_WEAK_BLOCK (p))
+          flag |= BLOCK_FIELD_IS_WEAK;
+      /* _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK]) */
+      call_exp = build_block_object_dispose_call_exp (src_block_component, flag);
       add_stmt (call_exp);
     }
 

Modified: llvm-gcc-4.2/trunk/gcc/c-pragma.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-pragma.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-pragma.h (original)
+++ llvm-gcc-4.2/trunk/gcc/c-pragma.h Tue Nov 25 16:26:23 2008
@@ -101,7 +101,8 @@
 extern const struct cpp_token *c_lex_peek (int);
 extern void c_lex_prepend (const struct cpp_token *, int);
 /* APPLE LOCAL end AltiVec */
-extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *);
+/* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *, int);
 
 /* If 1, then lex strings into the execution character set.
    If 0, lex strings into the host character set.

Modified: llvm-gcc-4.2/trunk/gcc/config.host
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.host?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config.host (original)
+++ llvm-gcc-4.2/trunk/gcc/config.host Tue Nov 25 16:26:23 2008
@@ -91,10 +91,10 @@
     # Generic darwin host support.
     out_host_hook_obj=host-darwin.o
     host_xmake_file="${host_xmake_file} x-darwin"
-    /* APPLE LOCAL begin ARM native compiler support */
-    /* Default size of memory to set aside for precompiled headers */
+    # APPLE LOCAL begin ARM native compiler support
+    # Default size of memory to set aside for precompiled headers
     host_xm_defines='DARWIN_PCH_ADDR_SPACE_SIZE=1024*1024*1024'
-    /* APPLE LOCAL end ARM native compiler support */
+    # APPLE LOCAL end ARM native compiler support
     ;;
 esac
 

Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/arm/arm.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Tue Nov 25 16:26:23 2008
@@ -84,6 +84,7 @@
 static const char *fp_const_from_val (REAL_VALUE_TYPE *);
 static arm_cc get_arm_condition_code (rtx);
 static HOST_WIDE_INT int_log2 (HOST_WIDE_INT);
+static rtx is_jump_table (rtx);
 static const char *output_multi_immediate (rtx *, const char *, const char *,
 					   int, HOST_WIDE_INT);
 static const char *shift_op (rtx, HOST_WIDE_INT *);
@@ -3859,6 +3860,10 @@
       offset = legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
 				       base == reg ? 0 : reg);
 
+      /* APPLE LOCAL begin 6327222 */
+      /* #if 0 for now so it's here for reference since this is a tricky
+         bit. */
+#if 0
       if (GET_CODE (offset) == CONST_INT)
 	{
 	  /* The base register doesn't really matter, we only want to
@@ -3872,7 +3877,8 @@
 	  if (GET_CODE (offset) == CONST_INT)
 	    return plus_constant (base, INTVAL (offset));
 	}
-
+#endif
+      /* APPLE LOCAL end 6327222 */
       if (GET_MODE_SIZE (mode) > 4
 	  && (GET_MODE_CLASS (mode) == MODE_INT
 	      || TARGET_SOFT_FLOAT))

Modified: llvm-gcc-4.2/trunk/gcc/config/darwin-c.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin-c.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin-c.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin-c.c Tue Nov 25 16:26:23 2008
@@ -1081,7 +1081,8 @@
   else
     {
       builtin_define ("__strong=");
-      builtin_define ("__weak=");
+      /* APPLE LOCAL radar 5847976 */
+      builtin_define ("__weak=__attribute__((objc_gc(weak)))");
     }
   /* APPLE LOCAL end ObjC GC */
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */

Modified: llvm-gcc-4.2/trunk/gcc/config/darwin-sections.def
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin-sections.def?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin-sections.def (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin-sections.def Tue Nov 25 16:26:23 2008
@@ -117,10 +117,12 @@
 	     ".section __DATA, __objc_nlclslist, regular, no_dead_strip", 1)
 DEF_SECTION (objc_v2_nonlazy_category_section, 0,
 	     ".section __DATA, __objc_nlcatlist, regular, no_dead_strip", 1)
+/* APPLE LOCAL begin radar 6351990 */
 DEF_SECTION (objc_v2_protocollist_section, 0,
-	     ".section __DATA, __objc_protolist, regular, no_dead_strip", 1)
+	     ".section __DATA, __objc_protolist, coalesced, no_dead_strip", 1)
 DEF_SECTION (objc_v2_protocolrefs_section, 0,
-	     ".section __DATA, __objc_protorefs, regular, no_dead_strip", 1)
+	     ".section __DATA, __objc_protorefs, coalesced, no_dead_strip", 1)
+/* APPLE LOCAL end radar 6351990 */
 DEF_SECTION (objc_v2_super_classrefs_section, 0,
 	     ".section __DATA, __objc_superrefs, regular, no_dead_strip", 1)
 DEF_SECTION (objc_v2_image_info_section, 0,

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Tue Nov 25 16:26:23 2008
@@ -2020,15 +2020,13 @@
         error ("-mstackrealign not supported in the 64bit mode");
       /* APPLE LOCAL end radar 4877693 */
 
-      target_flags |= TARGET_SUBTARGET64_DEFAULT & ~target_flags_explicit;
-
       /* Enable by default the SSE and MMX builtins.  Do allow the user to
          explicitly disable any of these.  In particular, disabling SSE and
          MMX for kernel code is extremely useful.  */
       if (!ix86_arch_specified)
         target_flags
-          |= ((MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE)
-               & ~target_flags_explicit);
+          |= ((MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE
+               | TARGET_SUBTARGET64_DEFAULT) & ~target_flags_explicit);
       /* APPLE LOCAL begin mainline candidate */
       /* Disable the red zone for kernel compilation.
 	 ??? Why aren't we using -mcmodel=kernel?  */
@@ -6882,12 +6880,9 @@
 	  /* TLS references should always be enclosed in UNSPEC.  */
 	  if (SYMBOL_REF_TLS_MODEL (op0))
 	    return false;
-	  /* APPLE LOCAL begin 6227434 */
+	  /* APPLE LOCAL begin fix-and-continue 6227434 */
 #if TARGET_MACHO
-	  /* ObjC machinery always has a legitimate PIC
-	     address.  */
-	  if (objc_anonymous_local_objc_name (XSTR (op0, 0))
-	      || SYMBOL_REF_LOCAL_P (op0))
+	  if (machopic_data_defined_p (op0))
 	    return true;
 	  /* Under -mfix-and-continue, even local storage is
 	     addressed via the GOT, so that the value of local
@@ -6895,7 +6890,7 @@
 	  if (TARGET_FIX_AND_CONTINUE)
 	    return false;
 #endif
-	  /* APPLE LOCAL end 6227434 */
+	  /* APPLE LOCAL end fix-and-continue 6227434 */
 	  if (!SYMBOL_REF_FAR_ADDR_P (op0) && SYMBOL_REF_LOCAL_P (op0))
 	    return true;
 	  break;
@@ -7452,6 +7447,10 @@
 		      new = XEXP (new, 1);
 		    }
 		  new = gen_rtx_PLUS (Pmode, base, new);
+		  /* APPLE LOCAL begin fix-and-continue 6358507 */
+		  if (!legitimate_address_p (Pmode, new, FALSE))
+		    new = force_reg (Pmode, new);
+		  /* APPLE LOCAL end fix-and-continue 6358507 */
 		}
 	    }
 	}
@@ -15537,6 +15536,7 @@
   const unsigned int flag;
 };
 
+/* APPLE LOCAL begin 4299257 */
 static const struct builtin_description bdesc_comi[] =
 {
   { MASK_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comieq", IX86_BUILTIN_COMIEQSS, UNEQ, 0 },
@@ -15545,25 +15545,29 @@
   { MASK_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comigt", IX86_BUILTIN_COMIGTSS, GT, 0 },
   { MASK_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comige", IX86_BUILTIN_COMIGESS, GE, 0 },
   { MASK_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comineq", IX86_BUILTIN_COMINEQSS, LTGT, 0 },
-  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomieq", IX86_BUILTIN_UCOMIEQSS, UNEQ, 0 },
-  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomilt", IX86_BUILTIN_UCOMILTSS, UNLT, 0 },
-  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomile", IX86_BUILTIN_UCOMILESS, UNLE, 0 },
-  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomigt", IX86_BUILTIN_UCOMIGTSS, GT, 0 },
-  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomige", IX86_BUILTIN_UCOMIGESS, GE, 0 },
-  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomineq", IX86_BUILTIN_UCOMINEQSS, LTGT, 0 },
   { MASK_SSE2, CODE_FOR_sse2_comi, "__builtin_ia32_comisdeq", IX86_BUILTIN_COMIEQSD, UNEQ, 0 },
   { MASK_SSE2, CODE_FOR_sse2_comi, "__builtin_ia32_comisdlt", IX86_BUILTIN_COMILTSD, UNLT, 0 },
   { MASK_SSE2, CODE_FOR_sse2_comi, "__builtin_ia32_comisdle", IX86_BUILTIN_COMILESD, UNLE, 0 },
   { MASK_SSE2, CODE_FOR_sse2_comi, "__builtin_ia32_comisdgt", IX86_BUILTIN_COMIGTSD, GT, 0 },
   { MASK_SSE2, CODE_FOR_sse2_comi, "__builtin_ia32_comisdge", IX86_BUILTIN_COMIGESD, GE, 0 },
   { MASK_SSE2, CODE_FOR_sse2_comi, "__builtin_ia32_comisdneq", IX86_BUILTIN_COMINEQSD, LTGT, 0 },
-  { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdeq", IX86_BUILTIN_UCOMIEQSD, UNEQ, 0 },
-  { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdlt", IX86_BUILTIN_UCOMILTSD, UNLT, 0 },
-  { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdle", IX86_BUILTIN_UCOMILESD, UNLE, 0 },
+};
+static const struct builtin_description bdesc_ucomi[] =
+{
+  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomieq", IX86_BUILTIN_UCOMIEQSS, EQ, 0 },
+  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomilt", IX86_BUILTIN_UCOMILTSS, LT, 0 },
+  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomile", IX86_BUILTIN_UCOMILESS, LE, 0 },
+  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomigt", IX86_BUILTIN_UCOMIGTSS, GT, 0 },
+  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomige", IX86_BUILTIN_UCOMIGESS, GE, 0 },
+  { MASK_SSE, CODE_FOR_sse_ucomi, "__builtin_ia32_ucomineq", IX86_BUILTIN_UCOMINEQSS, LTGT, 0 },
+  { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdeq", IX86_BUILTIN_UCOMIEQSD, EQ, 0 },
+  { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdlt", IX86_BUILTIN_UCOMILTSD, LT, 0 },
+  { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdle", IX86_BUILTIN_UCOMILESD, LE, 0 },
   { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdgt", IX86_BUILTIN_UCOMIGTSD, GT, 0 },
   { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdge", IX86_BUILTIN_UCOMIGESD, GE, 0 },
   { MASK_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdneq", IX86_BUILTIN_UCOMINEQSD, LTGT, 0 },
 };
+/* APPLE LOCAL end 4299257 */
 
 /* APPLE LOCAL begin 5612787 mainline sse4 */
 static const struct builtin_description bdesc_ptest[] =
@@ -16709,13 +16713,23 @@
   def_builtin (MASK_SSE | MASK_3DNOW_A, "__builtin_ia32_pshufw", v4hi_ftype_v4hi_int, IX86_BUILTIN_PSHUFW);
   def_builtin (MASK_MMX, "__builtin_ia32_pmaddwd", v2si_ftype_v4hi_v4hi, IX86_BUILTIN_PMADDWD);
 
-  /* comi/ucomi insns.  */
+  /* APPLE LOCAL 4299257 */
+  /* comi insns.  */
   for (i = 0, d = bdesc_comi; i < ARRAY_SIZE (bdesc_comi); i++, d++)
     if (d->mask == MASK_SSE2)
       def_builtin (d->mask, d->name, int_ftype_v2df_v2df, d->code);
     else
       def_builtin (d->mask, d->name, int_ftype_v4sf_v4sf, d->code);
 
+  /* APPLE LOCAL begin 4299257 */
+  /* ucomi insns.  */
+  for (i = 0, d = bdesc_ucomi; i < ARRAY_SIZE (bdesc_ucomi); i++, d++)
+    if (d->mask == MASK_SSE2)
+      def_builtin (d->mask, d->name, int_ftype_v2df_v2df, d->code);
+    else
+      def_builtin (d->mask, d->name, int_ftype_v4sf_v4sf, d->code);
+  /* APPLE LOCAL end 4299257 */
+
   /* APPLE LOCAL begin 5612787 mainline sse4 */
   /* ptest insns.  */
   for (i = 0, d = bdesc_ptest; i < ARRAY_SIZE (bdesc_ptest); i++, d++)
@@ -17482,6 +17496,56 @@
   return SUBREG_REG (target);
 }
 
+/* APPLE LOCAL begin 4299257 */
+/* Subroutine of ix86_expand_builtin to take care of ucomi insns.  */
+
+static rtx
+ix86_expand_sse_ucomi (const struct builtin_description *d, tree arglist,
+		      rtx target)
+{
+  tree arg0 = TREE_VALUE (arglist);
+  tree arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+  rtx op0 = expand_normal (arg0);
+  rtx op1 = expand_normal (arg1);
+  enum machine_mode mode0 = insn_data[d->icode].operand[0].mode;
+  enum machine_mode mode1 = insn_data[d->icode].operand[1].mode;
+  enum machine_mode scalar_mode;
+  enum rtx_code comparison = d->comparison;
+
+  if (VECTOR_MODE_P (mode0))
+    op0 = safe_vector_operand (op0, mode0);
+  if (VECTOR_MODE_P (mode1))
+    op1 = safe_vector_operand (op1, mode1);
+
+  /* Swap operands if we have a comparison that isn't available in
+     hardware.  */
+  if (d->flag & BUILTIN_DESC_SWAP_OPERANDS)
+    {
+      rtx tmp = op1;
+      op1 = op0;
+      op0 = tmp;
+    }
+
+  target = gen_reg_rtx (SImode);
+  emit_move_insn (target, const0_rtx);
+  target = gen_rtx_SUBREG (QImode, target, 0);
+
+  gcc_assert (mode0 == V4SFmode || mode0 == V2DFmode);
+  gcc_assert (mode1 == V4SFmode || mode1 == V2DFmode);
+
+  scalar_mode = (mode0 == V4SFmode) ? SFmode : DFmode;
+  op0 = gen_rtx_SUBREG (scalar_mode, copy_to_mode_reg (mode0, op0), 0);
+  op1 = gen_rtx_SUBREG (scalar_mode, copy_to_mode_reg (mode1, op1), 0);
+
+  ix86_compare_op0 = op0;
+  ix86_compare_op1 = op1;
+  if (ix86_expand_setcc (comparison, target))
+    return SUBREG_REG (target);
+
+  return NULL_RTX;
+}
+/* APPLE LOCAL end 4299257 */
+
 /* APPLE LOCAL begin 5612787 mainline sse4 */
 /* Subroutine of ix86_expand_builtin to take care of ptest insns.  */
 
@@ -18632,6 +18696,12 @@
     if (d->code == fcode)
       return ix86_expand_sse_comi (d, arglist, target);
 
+  /* APPLE LOCAL begin 4299257 */
+  for (i = 0, d = bdesc_ucomi; i < ARRAY_SIZE (bdesc_ucomi); i++, d++)
+    if (d->code == fcode)
+      return ix86_expand_sse_ucomi (d, arglist, target);
+  /* APPLE LOCAL end 4299257 */
+
   /* APPLE LOCAL begin 5612787 mainline sse4 */
   for (i = 0, d = bdesc_ptest; i < ARRAY_SIZE (bdesc_ptest); i++, d++)
     if (d->code == fcode)

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/predicates.md
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/predicates.md?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/predicates.md (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/predicates.md Tue Nov 25 16:26:23 2008
@@ -464,8 +464,14 @@
   if (SYMBOL_REF_TLS_MODEL (op) != 0)
     return 0;
 
+/* APPLE LOCAL begin fix-and-continue 6358507 */
   if (SYMBOL_REF_LOCAL_P (op))
-    return 1;
+    {
+      if (!TARGET_FIX_AND_CONTINUE
+          || machopic_data_defined_p (op))  
+      return 1;
+    }
+/* APPLE LOCAL end fix-and-continue 6358507 */
 
   /* There is, however, a not insubstantial body of code in the rest of
      the compiler that assumes it can just stick the results of

Modified: llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple Tue Nov 25 16:26:23 2008
@@ -1,3 +1,23 @@
+008-11-07  Fariborz Jahanian <fjahanian at apple.com>
+
+        Radar 5847976
+	* decl.c (synth_block_byref_id_object_copy_func): Takes new 'flag' argument
+	and produces the new much simplified API.
+	(synth_block_byref_id_object_dispose_func): Ditto.
+	(new_block_byref_decl): Turn off -fobjc-gc so we don't get
+	bogus warning on field declared as __weak.
+	(init_byref_decl): Takes a new 'flag' argument and passes
+	it down to synth_block_byref_id_object_copy_func and
+	synth_block_byref_id_object_dispose_func.
+	(cp_finish_decl): Calculates the flag for the block 
+	variable declaration and passes it down to init_byref_decl.
+	* parser.c (build_block_struct_initlist): Removes call to	
+	copy_in_object (not needed).
+	(synth_copy_helper_block_func): Produce the new, simplified
+	API.
+	(synth_destroy_helper_block_func): Ditto.
+	(build_block_byref_decl): Copy over COPYABLE_WEAK_BLOCK flag.
+	
 2008-10-31  Fariborz Jahanian <fjahanian at apple.com>
 
         Radar 6175959

Modified: llvm-gcc-4.2/trunk/gcc/cp/cp-objcp-common.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/cp-objcp-common.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/cp-objcp-common.h (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/cp-objcp-common.h Tue Nov 25 16:26:23 2008
@@ -171,4 +171,10 @@
 #define LANG_HOOKS_VTABLE_P cp_vtable_p
 /* APPLE LOCAL end kext identify vtables */
 
+/* APPLE LOCAL begin radar 6353006  */
+#undef LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
+#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
+     c_build_generic_block_struct_type
+/* APPLE LOCAL end radar 6353006  */
+
 #endif /* GCC_CP_OBJCP_COMMON */

Modified: llvm-gcc-4.2/trunk/gcc/cp/decl.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/decl.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/decl.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/decl.c Tue Nov 25 16:26:23 2008
@@ -5298,14 +5298,16 @@
 
  void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
 				   struct Block_byref_id_object *src) {
-   dst->object = [src->object retain];
+   _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
+   _Block_object_assign(&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK])  //  blocks
  }  */
 static void
-synth_block_byref_id_object_copy_func (void)
+synth_block_byref_id_object_copy_func (int flag)
 {
   tree stmt;
   tree dst_arg, src_arg;
   tree dst_obj, src_obj;
+  tree call_exp;
 
   gcc_assert (block_byref_id_object_copy);
   /* Set up: (void* _dest, void*_src) parameters. */
@@ -5342,23 +5344,10 @@
   /* src_obj is: _src->object. */
   src_obj = build_indirect_object_id_exp (src_arg);
   /* APPLE LOCAL begin radar 6180456 */
-  if (c_dialect_objc ())
-    {
-      tree retain_exp = retain_block_component (src_obj);
-
-      /* dst->object = [src->object retain]; */
-      tree store = build_modify_expr (dst_obj, NOP_EXPR, retain_exp);
-      add_stmt (store);
-    }
-  else
-    {
-      /* _Block_byref_assign_copy(&_dest->object, _src->object) */
-      tree func_params = tree_cons (NULL_TREE, build_fold_addr_expr (dst_obj),
-                                    tree_cons (NULL_TREE, src_obj,
-                                               NULL_TREE));
-      tree call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
-      add_stmt (call_exp);
-    }
+  /* _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT) or:
+     _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK) */
+  call_exp = build_block_object_assign_call_exp (build_fold_addr_expr (dst_obj), src_obj, flag);
+  add_stmt (call_exp);
   /* APPLE LOCAL end radar 6180456 */
 
   finish_compound_stmt (stmt);
@@ -5371,10 +5360,10 @@
   This routine builds:
 
   void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
-    [_src->object release];  // objective-c++ or:
-    _Block_byref_release(_src->object) // c++ language
+    _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
+    _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // blocks
   }  */
-static void synth_block_byref_id_object_dispose_func (void)
+static void synth_block_byref_id_object_dispose_func (int flag)
 {
   tree stmt;
   tree src_arg, src_obj, rel_exp;
@@ -5403,15 +5392,9 @@
   src_obj = build_indirect_object_id_exp (src_arg);
 
   /* APPLE LOCAL begin radar 6180456 */
-  if (c_dialect_objc ())
-    /* [_src->object release]; */
-    rel_exp = release_block_component (src_obj);
-  else
-    {
-      /* _Block_byref_release(_src->object) */
-      tree func_params = tree_cons (NULL_TREE, src_obj, NULL_TREE);
-      rel_exp = build_function_call (build_block_byref_release_decl (), func_params);
-    }
+  /* _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT) or:
+     _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK) */
+  rel_exp = build_block_object_dispose_call_exp (src_obj, flag);
   /* APPLE LOCAL end radar 6180456 */
   add_stmt (rel_exp);
 
@@ -5471,6 +5454,8 @@
 new_block_byref_decl (tree decl)
 {
   static int unique_count;
+  /* APPLE LOCAL radar 5847976 */
+  int save_flag_objc_gc;
   tree Block_byref_type;
   tree fields = NULL_TREE, field;
   const char *prefix = "__Block_byref_";
@@ -5524,8 +5509,14 @@
   field = build_decl (FIELD_DECL, DECL_NAME (decl), TREE_TYPE (decl));
   chainon (fields, field);
 
+  /* APPLE LOCAL begin radar 5847976 */
+  /* Hack so we don't issue warning on a field_decl having __weak attribute */
+  save_flag_objc_gc = flag_objc_gc;
+  flag_objc_gc = 0;
   /* finish_struct (Block_byref_type, field_decl_chain, NULL_TREE); */
   block_finish_struct (Block_byref_type, fields);
+  flag_objc_gc = save_flag_objc_gc;
+  /* APPLE LOCAL end radar 5847976 */
   pop_from_top_level ();
 
   TREE_TYPE (decl) = Block_byref_type;
@@ -5550,7 +5541,7 @@
      &initializer-expr};
  */
 static tree
-init_byref_decl (tree decl, tree init)
+init_byref_decl (tree decl, tree init, int flag)
 {
   tree initlist;
   tree block_byref_type = TREE_TYPE (decl);
@@ -5563,7 +5554,8 @@
 
   fields = TYPE_FIELDS (block_byref_type);
   /* APPLE LOCAL begin radar 6244520 */
-  initlist = tree_cons (fields, fold_convert (ptr_type_node, integer_zero_node), 
+  initlist = tree_cons (fields, fold_convert (ptr_type_node, ((flag & BLOCK_FIELD_IS_WEAK) != 0) ? integer_one_node
+                                                                                : integer_zero_node), 
                         0);
   fields = TREE_CHAIN (fields);
   
@@ -5599,7 +5591,7 @@
 							       func_type);
 	  DECL_CONTEXT (block_byref_id_object_copy) = current_function_decl;
 	  /* Synthesize function definition. */
-	  synth_block_byref_id_object_copy_func ();
+	  synth_block_byref_id_object_copy_func (flag);
 	  pop_lang_context ();
 	}
       initlist = tree_cons (fields,
@@ -5621,7 +5613,7 @@
 								  func_type);
 	  DECL_CONTEXT (block_byref_id_object_dispose) = current_function_decl;
 	  /* Synthesize function definition. */
-	  synth_block_byref_id_object_dispose_func ();
+	  synth_block_byref_id_object_dispose_func (flag);
 	  pop_lang_context ();
 	}
       initlist = tree_cons (fields,
@@ -5786,10 +5778,23 @@
 	  }
         else
 	  {
+	    /* APPLE LOCAL begin radar 5847976 */
+	    int flag = 0;
+	    if (objc_is_gcable_type (TREE_TYPE (decl)) == -1)
+              flag = BLOCK_FIELD_IS_WEAK;
+            if (block_requires_copying (decl))
+            {
+              if (TREE_CODE (TREE_TYPE (decl)) == BLOCK_POINTER_TYPE)
+                flag |= BLOCK_FIELD_IS_BLOCK;
+              else
+                flag |= BLOCK_FIELD_IS_OBJECT;
+            }
 	    decl = new_block_byref_decl (decl);
 	    if (! flag_objc_gc_only)
 	      push_cleanup (decl, build_block_byref_release_exp (decl), false);
-	    init = init_byref_decl (decl, init);
+            COPYABLE_WEAK_BLOCK (decl) = ((flag & BLOCK_FIELD_IS_WEAK) != 0);
+            init = init_byref_decl (decl, init, flag);
+            /* APPLE LOCAL end radar 5847976 */
 	  }
       }
       /* APPLE LOCAL end blocks 6040305 (cq) */

Modified: llvm-gcc-4.2/trunk/gcc/cp/parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/parser.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/parser.c Tue Nov 25 16:26:23 2008
@@ -442,7 +442,8 @@
 
    /* Get a new token from the preprocessor.  */
   token->type
-    = c_lex_with_flags (&token->u.value, &token->location, &token->flags);
+    /* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+    = c_lex_with_flags (&token->u.value, &token->location, &token->flags, 1);
   token->input_file_stack_index = input_file_stack_tick;
   token->keyword = RID_MAX;
   token->pragma_kind = PRAGMA_NONE;
@@ -542,12 +543,15 @@
   /* APPLE LOCAL begin CW asm blocks */
  top:
   if (flag_ms_asms)
-    while (lexer->next_token->type == CPP_NUMBER
-	   && lexer->next_token->u.value == error_mark_node)
+    if (lexer->next_token->type == CPP_NUMBER
+	&& lexer->next_token->u.value == error_mark_node
+	&& (lexer->next_token->flags & ERROR_DEFERRED))
       {
+	cp_lexer_set_source_position_from_token (lexer->next_token);
+
 	/* This was previously deferred.  */
+      	lexer->next_token->flags ^=  ERROR_DEFERRED;
 	error ("invalid suffix on integer constant");
-	cp_lexer_consume_token (lexer);
       }
   if (!inside_iasm_block)
     {
@@ -20538,13 +20542,6 @@
 }
 /* APPLE LOCAL end radar 6214617 */
 
-/* APPLE LOCAL begin radar 6175959 */
-static GTY(()) tree block_copy_assign_decl;
-static GTY(()) tree block_object_assign_decl;
-static GTY(()) tree block_destroy_decl;
-static GTY(()) tree block_object_dispose_func_decl;
-/* APPLE LOCAL end radar 6175959 */
-
 /* APPLE LOCAL begin radar 5847213 - radar 6329245 */
 /** build_descriptor_block_decl -
   This routine builds a static block_descriptior variable of type:
@@ -20635,7 +20632,8 @@
 */
 
 tree
-build_generic_block_struct_type (void)
+/* APPLE LOCAL radar 6353006  */
+c_build_generic_block_struct_type (void)
 {
   tree fields = NULL_TREE;
   tree field;
@@ -20919,7 +20917,7 @@
     {
       tree y = TREE_VALUE (chain);
       TREE_USED (y) = 1;
-      CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, copy_in_object (y));
+      CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, y);
     }
   for (chain = block_impl->block_byref_decl_list; chain;
        chain = TREE_CHAIN (chain))
@@ -21093,7 +21091,7 @@
     if (cp_block_requires_copying (TREE_VALUE (chain)))
     {
       /* APPLE LOCAL begin radar 6175959 */
-      tree which_function_decl = NULL_TREE;
+      int flag = 0;
       tree p = TREE_VALUE (chain);
       tree dst_block_component, src_block_component;
       dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
@@ -21102,27 +21100,8 @@
 						 DECL_NAME (p));
 
       if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
-      {
-        /* _Block_copy_assign(&_dest->myImportedBlock, _src->myImportedClosure, 0) */
-        /* Build a: void _Block_copy_assign (void *, void *, int) if not done
-           already. */
-        /* APPLE LOCAL begin radar 6310599 */
-        if (!block_copy_assign_decl &&
-            !(block_copy_assign_decl = lookup_name (get_identifier ("_Block_copy_assign"))))
-        /* APPLE LOCAL end radar 6310599 */
-        {
-          tree func_type =
-            build_function_type (void_type_node,
-              tree_cons (NULL_TREE, ptr_type_node,
-                         tree_cons (NULL_TREE, ptr_type_node,
-                                    tree_cons (NULL_TREE, integer_type_node, void_list_node))));
-
-          block_copy_assign_decl = builtin_function ("_Block_copy_assign", func_type,
-                                                     0, NOT_BUILT_IN, 0, NULL_TREE);
-          TREE_NOTHROW (block_copy_assign_decl) = 0;
-        }
-        which_function_decl = block_copy_assign_decl;
-      }
+	/* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_BLOCK) */
+        flag = BLOCK_FIELD_IS_BLOCK;
       /* APPLE LOCAL begin radar 6214617 */
       else if (TYPE_HAS_CONSTRUCTOR (TREE_TYPE (p)) 
                || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
@@ -21133,48 +21112,27 @@
       }
       /* APPLE LOCAL end radar 6214617 */
       else
-      {
-        /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, 0) */
-        /* Build a: void _Block_object_assign (void *, void *, int) if not done
-           already. */
-        if (!block_object_assign_decl &&
-            !(block_object_assign_decl = lookup_name (get_identifier ("_Block_object_assign"))))
+        /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_OBJECT) */
+        flag = BLOCK_FIELD_IS_OBJECT;
+      if (flag)
         {
-          tree func_type =
-            build_function_type (void_type_node,
-              tree_cons (NULL_TREE, ptr_type_node,
-                         tree_cons (NULL_TREE, ptr_type_node,
-                                    tree_cons (NULL_TREE, integer_type_node, void_list_node))));
-
-          block_object_assign_decl = builtin_function ("_Block_object_assign", func_type,
-                                                     0, NOT_BUILT_IN, 0, NULL_TREE);
-          TREE_NOTHROW (block_object_assign_decl) = 0;
-      }
-      which_function_decl = block_object_assign_decl;
-    }
-    if (which_function_decl)
-    {
-      tree func_params, call_exp;
-      dst_block_component = build_fold_addr_expr (dst_block_component);
-      func_params = tree_cons (NULL_TREE, dst_block_component,
-                               tree_cons (NULL_TREE, src_block_component,
-                                          tree_cons (NULL_TREE,
-                                                     build_int_cst (integer_type_node, 0),
-                                                     NULL_TREE)));
-      call_exp = build_function_call (which_function_decl, func_params);
-      add_stmt (call_exp);
+	  tree call_exp;
+	  dst_block_component = build_fold_addr_expr (dst_block_component);
+          call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
+          add_stmt (call_exp);
+        }
+      /* APPLE LOCAL end radar 6175959 */
     }
-    /* APPLE LOCAL end radar 6175959 */
-  }
 
   /* For each __block declared variable used in |...| Must generate call to:
-     _Block_byref_assign_copy(&_dest->myImportedBlock, _src->myImportedBlock)
+     _Block_object_assign(&_dest->myImportedBlock, _src->myImportedBlock, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK])
   */
   for (chain = block_impl->block_byref_decl_list; chain;
          chain = TREE_CHAIN (chain))
     if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
       {
-	tree func_params, call_exp;
+	int flag = BLOCK_FIELD_IS_BYREF;
+        tree call_exp;
 	tree p = TREE_VALUE (chain);
 	tree dst_block_component, src_block_component;
 	dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
@@ -21182,12 +21140,12 @@
 	src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
 						   DECL_NAME (p));
 
-	/* _Block_byref_assign_copy(&_dest->myImportedClosure, _src->myImportedClosure) */
-	dst_block_component = build_fold_addr_expr (dst_block_component);
-	func_params = tree_cons (NULL_TREE, dst_block_component,
-				 tree_cons (NULL_TREE, src_block_component,
-					    NULL_TREE));
-	call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
+	/* _Block_object_assign(&_dest->myImportedClosure, _src->myImportedClosure, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK]) */
+        if (COPYABLE_WEAK_BLOCK (p))
+          flag |= BLOCK_FIELD_IS_WEAK;
+
+        dst_block_component = build_fold_addr_expr (dst_block_component);
+        call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
 	add_stmt (call_exp);
       }
 
@@ -21201,30 +21159,6 @@
   /* free (arg_info); */
 }
 
-/* APPLE LOCAL begin radar 6175959 */
-static tree
-block_object_dispose (tree src_block_component)
-{
-  tree func_params;
-  if (!block_object_dispose_func_decl &&
-      !(block_object_dispose_func_decl = lookup_name (get_identifier ("_Block_object_dispose"))))
-    {
-      tree func_type =
-      build_function_type (void_type_node,
-                           tree_cons (NULL_TREE, ptr_type_node,
-                                      tree_cons (NULL_TREE, integer_type_node, void_list_node)));
-
-      block_object_dispose_func_decl = builtin_function ("_Block_object_dispose", func_type,
-                                       0, NOT_BUILT_IN, 0, NULL_TREE);
-     TREE_NOTHROW (block_object_dispose_func_decl) = 0;
-    }
-    func_params = tree_cons (NULL_TREE, src_block_component,
-                             tree_cons (NULL_TREE,
-                                        build_int_cst (integer_type_node, 0), NULL_TREE));
-    return build_function_call (block_object_dispose_func_decl, func_params);
-}
-/* APPLE LOCAL end radar 6175959 */
-
 static void
 synth_destroy_helper_block_func (struct block_sema_info * block_impl)
 {
@@ -21263,37 +21197,16 @@
             && CLASSTYPE_DESTRUCTORS (TREE_TYPE (TREE_VALUE (chain)))))
     /* APPLE LOCAL end radar 6214617 */
     {
+      int flag = 0;
+      tree rel_exp;
       tree p = TREE_VALUE (chain);
       tree src_block_component;
       src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
 						 DECL_NAME (p));
 
       if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
-      {
-        tree func_params, call_exp;
-	/* APPLE LOCAL begin radar 6175959 */
-        /* _Block_destroy(_src->myImportedClosure); */
-        /* _Block_destroy (void *); */
-        /* Build a: void _Block_destroy (void *) if not done already. */
-        if (!block_destroy_decl &&
-            !(block_destroy_decl = lookup_name (get_identifier ("_Block_destroy"))))
-        {
-          tree func_type =
-          build_function_type (void_type_node,
-                               tree_cons (NULL_TREE, ptr_type_node,
-                                          tree_cons (NULL_TREE, integer_type_node, void_list_node)));
-
-          block_destroy_decl = builtin_function ("_Block_destroy", func_type,
-                                                 0, NOT_BUILT_IN, 0, NULL_TREE);
-          TREE_NOTHROW (block_destroy_decl) = 0;
-        }
-        func_params = tree_cons (NULL_TREE, src_block_component,
-                                 tree_cons (NULL_TREE,
-                                            build_int_cst (integer_type_node, 0), NULL_TREE));
-        call_exp = build_function_call (block_destroy_decl, func_params);
-        /* APPLE LOCAL end radar 6175959 */
-        add_stmt (call_exp);
-      }
+	/* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_BLOCK); */
+        flag = BLOCK_FIELD_IS_BLOCK;
       /* APPLE LOCAL begin radar 6214617 */
       else if (TREE_CODE (TREE_TYPE (p)) == RECORD_TYPE
                && CLASSTYPE_DESTRUCTORS (TREE_TYPE (p)))
@@ -21304,35 +21217,34 @@
       }
       /* APPLE LOCAL end radar 6214617 */
       else
-      {
-        tree rel_exp;
-        /* APPLE LOCAL begin radar 6175959 */
-        /* _Block_object_dispose(_src->imported_object_0, 0); */
-        rel_exp = block_object_dispose (src_block_component);
-        /* APPLE LOCAL end radar 6175959 */
-        add_stmt (rel_exp);
-      }
+ 	/* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_OBJECT); */
+        flag = BLOCK_FIELD_IS_OBJECT;
+      if (flag)
+       {
+         rel_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+	 add_stmt (rel_exp);
+       }
     }
 
   /* For each __block declared variable used in |...| Must generate call to:
-   _Block_byref_release(_src->myImportedClosure)
+     _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK])
    */
   for (chain = block_impl->block_byref_decl_list; chain;
        chain = TREE_CHAIN (chain))
     if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
       {
-	tree func_params, call_exp;
+	tree call_exp;
+	int flag = BLOCK_FIELD_IS_BYREF;
 	tree p = TREE_VALUE (chain);
 	tree src_block_component;
 
 	src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
 						   DECL_NAME (p));
-      /* _Block_byref_release(_src->myImportedClosure) */
-      /* Build a: void _Block_byref_release (void *) if not done
-	 already. */
-      func_params = tree_cons (NULL_TREE, src_block_component, NULL_TREE);
-      call_exp = build_function_call (build_block_byref_release_decl (), func_params);
-      add_stmt (call_exp);
+        if (COPYABLE_WEAK_BLOCK (p))
+          flag |= BLOCK_FIELD_IS_WEAK;
+        /* _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK]) */
+        call_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+        add_stmt (call_exp);
     }
 
   finish_compound_stmt (stmt);
@@ -21490,8 +21402,6 @@
   /* APPLE LOCAL radar 6160536 */
   block_helper_function_decl = build_helper_func_decl (build_block_helper_name (unique_count),
 						       ftype);
-  if (current_function_decl)
-    DECL_NO_STATIC_CHAIN (current_function_decl) = 0;
   DECL_CONTEXT (block_helper_function_decl) = current_function_decl;
   cur_block->helper_func_decl = block_helper_function_decl;
 
@@ -21713,6 +21623,8 @@
     {
       COPYABLE_BYREF_LOCAL_VAR (byref_decl) = 1;
       COPYABLE_BYREF_LOCAL_NONPOD (byref_decl) = COPYABLE_BYREF_LOCAL_NONPOD (decl);
+      /* APPLE LOCAL radar 5847976 */
+      COPYABLE_WEAK_BLOCK (byref_decl) = COPYABLE_WEAK_BLOCK (decl);
     }
 
   /* Current scope must be that of the main function body. */
@@ -21983,6 +21895,8 @@
   /* APPLE LOCAL radar 6172148 */
   BLOCK_SYNTHESIZED_FUNC (func_decl) = 1;
   retrofit_lang_decl (func_decl);
+  if (current_function_decl)
+    DECL_NO_STATIC_CHAIN (current_function_decl) = 0;
   return func_decl;
 }
 

Modified: llvm-gcc-4.2/trunk/gcc/langhooks-def.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/langhooks-def.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/langhooks-def.h (original)
+++ llvm-gcc-4.2/trunk/gcc/langhooks-def.h Tue Nov 25 16:26:23 2008
@@ -97,6 +97,10 @@
 extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 					       tree);
 
+/* APPLE LOCAL begin 6353006  */
+extern tree lhd_build_generic_block_struct_type (void);
+/* APPLE LOCAL end 6353006  */
+
 #define LANG_HOOKS_NAME			"GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
 #define LANG_HOOKS_INIT			hook_bool_void_false
@@ -145,6 +149,11 @@
 #define LANG_HOOKS_FUNCTION_LEAVE_NESTED lhd_do_nothing_f
 #define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P hook_bool_tree_true
 
+/* APPLE LOCAL begin radar 6353006  */
+#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
+  lhd_build_generic_block_struct_type
+/* APPLE LOCAL end radar 6353006  */
+
 /* Attribute hooks.  */
 #define LANG_HOOKS_ATTRIBUTE_TABLE		NULL
 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE	NULL
@@ -337,6 +346,8 @@
   LANG_HOOKS_BUILTIN_FUNCTION, \
   LANG_HOOKS_INIT_TS,          \
   LANG_HOOKS_EXPR_TO_DECL, \
+/* APPLE LOCAL radar 6353006  */ \
+  LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE, \
 }
 
 #endif /* GCC_LANG_HOOKS_DEF_H */

Modified: llvm-gcc-4.2/trunk/gcc/langhooks.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/langhooks.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/langhooks.c (original)
+++ llvm-gcc-4.2/trunk/gcc/langhooks.c Tue Nov 25 16:26:23 2008
@@ -613,3 +613,11 @@
 				   tree t ATTRIBUTE_UNUSED)
 {
 }
+
+/* APPLE LOCAL begin radar 6353006  */
+tree 
+lhd_build_generic_block_struct_type (void)
+{
+  return NULL_TREE;
+}
+/* APPLE LOCAL end radar 6353006  */

Modified: llvm-gcc-4.2/trunk/gcc/langhooks.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/langhooks.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/langhooks.h (original)
+++ llvm-gcc-4.2/trunk/gcc/langhooks.h Tue Nov 25 16:26:23 2008
@@ -468,6 +468,13 @@
      TREE_SIDE_EFFECTS need updating.  */
   tree (*expr_to_decl) (tree expr, bool *tc, bool *ti, bool *se);
 
+
+  /* APPLE LOCAL begin radar 6353006  */
+  /*  For c-based languages, builds a generic type for Blocks pointers (for
+      emitting debug information.  For other languages, returns NULL.  */
+  tree (*build_generic_block_struct_type) (void);
+  /* APPLE LOCAL end radar 6353006  */
+
   /* Whenever you add entries here, make sure you adjust langhooks-def.h
      and langhooks.c accordingly.  */
 };

Modified: llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple (original)
+++ llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple Tue Nov 25 16:26:23 2008
@@ -1,3 +1,39 @@
+2008-11-14  Fariborz Jahanian <fjahanian at apple.com>
+
+	Radar 6370136
+	* objc-act.c (objc_merge_protocol_methods): Merge copied
+	list of protocol's methods into class.
+
+2008-11-13  Fariborz Jahanian <fjahanian at apple.com>
+
+	Radar 6351990 (minor tweak).
+	* objc-act.c (build_protocol_list_address_table): Move couple
+	of variables out of the loop.
+
+2008-11-11  Fariborz Jahanian <fjahanian at apple.com>
+
+	Radar 6351990
+	* objc-act.c (build_protocollist_reference_decl): Builds
+	a weak visibility hidder symbol for protocol reference
+	meta-data symbols.
+	(objc_add_to_protocol_list_chain): Takes addition argument
+	and builds a tree using this argument.
+	(build_protocol_list_address_table): Now builds a list
+	of protocol label and address of generated protocol symbol.
+	
+2008-11-07  Fariborz Jahanian <fjahanian at apple.com>
+
+        Radar 5847976
+	* objc-act.c (objc_is_gcable_type): Made global.
+	(objc_build_weak_reference_tree): Quick return if
+	-fobjc-gc unspecified.
+	(objc_checkon_weak_attribute): Ditto.
+	(objc_generate_write_barrier): Generate write-barrier for
+	a __block variable declared as __weak.
+	(retain_block_component, release_block_component,
+	 copy_in_object): Removed.
+	(cast_to_pointer_to_id): Removed.
+
 2008-10-27  Fariborz Jahanian <fjahanian at apple.com>
 
         Radar 6231433

Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
+++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Nov 25 16:26:23 2008
@@ -224,7 +224,6 @@
 
 /* APPLE LOCAL begin objc new property */
 static bool objc_lookup_protocol (tree, tree, tree, bool);
-static int objc_is_gcable_type (tree);
 /* APPLE LOCAL radar 5277239 */
 static tree lookup_method_static (tree, tree, int, bool, bool);
 /* APPLE LOCAL radar 4817072 */
@@ -272,8 +271,8 @@
 static void init_UOBJC2_EHTYPE_decls (void);
 static void create_ivar_offset_name (char *, tree, tree);
 static void build_v2_category_template (void);
-/* APPLE LOCAL radar 4533974 - ObjC new protocol */
-static tree build_protocollist_reference_decl (void);
+/* APPLE LOCAL radar 4533974 - ObjC new protocol - radar 6351990 */
+static tree build_protocollist_reference_decl (tree);
 static void objc_add_to_category_list_chain (tree);
 static void objc_add_to_nonlazy_category_list_chain (tree);
 /* APPLE LOCAL begin radar 4441049 */
@@ -1081,7 +1080,6 @@
 
 void
 objc_continue_implementation (void)
-
 {
   objc_ivar_chain
     = continue_class (objc_implementation_context);
@@ -4531,6 +4529,8 @@
   tree type;
   enum debug_info_type save_write_symbols = write_symbols;
   const struct gcc_debug_hooks *const save_hooks = debug_hooks;
+  /* APPLE LOCAL 6348516 */
+  int save_warn_padded;
 
   /* Suppress outputting debug symbols, because
      dbxout_init hasn'r been called yet.  */
@@ -4871,12 +4871,18 @@
     }
   /* APPLE LOCAL end ObjC new abi */
   build_protocol_template ();
+  /* APPLE LOCAL begin 6348516 */
+  save_warn_padded = warn_padded;
+  warn_padded = 0;
+  /* APPLE LOCAL end 6348516 */
   build_category_template ();
   build_objc_exception_stuff ();
 
   if (flag_next_runtime)
     build_next_objc_exception_stuff ();
 
+  /* APPLE LOCAL 6348516 */
+  warn_padded = save_warn_padded;
   /* static SEL _OBJC_SELECTOR_TABLE[]; */
 
   if (! flag_next_runtime)
@@ -6775,7 +6781,8 @@
    they are pointers to types that are themselves GC-able.  */
 
 /* APPLE LOCAL end ObjC GC */
-static int
+/* APPLE LOCAL radar 5847976 */
+int
 /* APPLE LOCAL ObjC GC */
 objc_is_gcable_type (tree type)
 {
@@ -7049,6 +7056,10 @@
 tree
 objc_build_weak_reference_tree (tree expr)
 {
+  /* APPLE LOCAL begin radar 5847976 */
+  if (!flag_objc_gc)
+    return expr;
+  /* APPLE LOCAL end radar 5847976 */
   return objc_tree_is_weak_expr (expr) ?
          build1 (OBJC_WEAK_REFERENCE_EXPR, TREE_TYPE (expr), expr) : expr;
 }
@@ -7087,6 +7098,10 @@
 void
 objc_checkon_weak_attribute (tree decl)
 {
+  /* APPLE LOCAL begin radar 5747976 */
+  if (!flag_objc_gc)
+    return;
+  /* APPLE LOCAL end radar 5747976 */
   if (decl && DECL_P (decl))
     {
       if (objc_collecting_ivars
@@ -7094,7 +7109,8 @@
 	      && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))))
 	return;
 
-      if ((TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == VAR_DECL)
+      /* APPLE LOCAL radar 5847976 */
+      if ((TREE_CODE (decl) == FIELD_DECL || (TREE_CODE (decl) == VAR_DECL && !COPYABLE_BYREF_LOCAL_VAR (decl)))
 	  && objc_is_gcable_type (TREE_TYPE (decl)) == -1)
 	{
 	  location_t saved_location = input_location;
@@ -7448,7 +7464,20 @@
     }
   /* APPLE LOCAL begin radar 4426814 */
   if (strong == -1)
-    return NULL_TREE;
+    {
+      /* APPLE LOCAL begin radar 5847976 */
+      /* Must generate write barrier for __block objects which are __weak
+         and used in an assignment. */
+      if (TREE_CODE (outer) == COMPONENT_REF && TREE_OPERAND (outer, 0)
+	  && TREE_CODE (TREE_OPERAND (outer, 0)) == VAR_DECL)
+        {
+	  tree var_decl = TREE_OPERAND (outer, 0);
+	  if (COPYABLE_WEAK_BLOCK (var_decl))
+	    return objc_build_global_assignment (lhs, rhs, -1);
+        }
+      /* APPLE LOCAL end radar 5847976 */
+      return NULL_TREE;
+    }
   /* APPLE LOCAL end radar 4426814 */
 
   /* LLVM LOCAL - begin 5541393 */
@@ -12364,12 +12393,13 @@
    in the __protocol_list section. */
 
 static void
-objc_add_to_protocol_list_chain (tree protocol_decl)
+/* APPLE LOCAL begin radar 6351990 */
+objc_add_to_protocol_list_chain (tree protocol_interface_decl, tree protocol_decl)
 {
   tree *chain;
   for (chain = &protocol_list_chain; *chain; chain = &TREE_CHAIN (*chain))
     ;
-  *chain = tree_cons (NULL_TREE, protocol_decl, NULL_TREE);
+  *chain = tree_cons (protocol_interface_decl, protocol_decl, NULL_TREE);
 }
 
 /* Build the __protocol_list section table containing address of all generate protocol_t 
@@ -12379,34 +12409,34 @@
 build_protocol_list_address_table (void)
 {
   tree chain;
-  int count=0;
-  tree type;
-  tree initlist = NULL_TREE;
-  tree decl;
-  tree expr;
   tree list_chain = protocol_list_chain;
-  const char *label_name = "_OBJC_LABEL_PROTOCOL_$";
+  char *string = NULL;
+  unsigned int  buf_size = 0;
 
   for (chain = list_chain; chain; chain = TREE_CHAIN (chain))
     {
-      tree purpose = NULL_TREE;
-      expr = TREE_VALUE (chain);
+      tree decl = TREE_PURPOSE (chain);
+      tree expr = TREE_VALUE (chain);
+      gcc_assert (decl && TREE_CODE (decl) == PROTOCOL_INTERFACE_TYPE);
+      if ((strlen ("l_OBJC_LABEL_PROTOCOL_$_") + strlen (IDENTIFIER_POINTER (PROTOCOL_NAME (decl))) + 1) > buf_size)
+        {
+	  if (!buf_size)
+	    buf_size = BUFSIZE;
+	  else
+	    buf_size = strlen ("l_OBJC_LABEL_PROTOCOL_$_") + strlen (IDENTIFIER_POINTER (PROTOCOL_NAME (decl))) + 1;
+	  string = (char *)alloca (buf_size);
+	} 
+      sprintf (string,  "l_OBJC_LABEL_PROTOCOL_$_%s", IDENTIFIER_POINTER (PROTOCOL_NAME (decl)));
+      decl = create_hidden_decl (objc_protocol_type, string);
+      DECL_WEAK (decl) = 1;
+      set_user_assembler_name (decl, string);
       expr = convert (objc_protocol_type, build_fold_addr_expr (expr));
-#ifndef OBJCPLUS
-      purpose = build_int_cst (NULL_TREE, count);
-#endif
-      ++count;
-      initlist = tree_cons (purpose, expr, initlist);
+      /* APPLE LOCAL radar 4561192 */
+      objc_set_alignment_attribute (decl, objc_protocol_type);
+      finish_var_decl (decl, expr);
     }
-  gcc_assert (count > 0);
-  type = build_array_type (objc_protocol_type, 
-			   build_index_type (build_int_cst (NULL_TREE, count - 1)));
-  decl = start_var_decl (type, label_name);
-  expr = objc_build_constructor (type, nreverse (initlist));
-  /* APPLE LOCAL radar 4561192 */
-  objc_set_alignment_attribute (decl, objc_protocol_type);
-  finish_var_decl (decl, expr);
 }
+/* APPLE LOCAL end radar 6351990 */
 
 /* Build decl = initializer; for each protocol referenced in @protocol(MyProtole) expression. */
 
@@ -12480,33 +12510,39 @@
     if (TREE_VALUE (*chain) == ident)
       {
         if (! TREE_PURPOSE (*chain))
-          TREE_PURPOSE (*chain) = build_protocollist_reference_decl ();
+	  /* APPLE LOCAL radar 6351990 */
+          TREE_PURPOSE (*chain) = build_protocollist_reference_decl (ident);
 
         return TREE_PURPOSE (*chain);
       }
 
-  decl = build_protocollist_reference_decl ();
+  /* APPLE LOCAL radar 6351990 */
+  decl = build_protocollist_reference_decl (ident);
   *chain = tree_cons (decl, ident, NULL_TREE);
   return decl;
 }
 
-static GTY(()) int protocollist_reference_idx;
-
 /* This routine creates a static variable used to implement @protocol(MyProtocol) 
    expression. This variable will be initialized to global protocol_t meta-data
    pointer. */
 
+/* APPLE LOCAL begin radar 6351990 */
 static tree
-build_protocollist_reference_decl (void)
+build_protocollist_reference_decl (tree protocol)
 {
   tree decl;
-  char buf[BUFSIZE];
+  tree protocol_ident = PROTOCOL_NAME (protocol);
+  char *buf = (char *)alloca (strlen ("l_OBJC_PROTOCOL_REFERENCE_$_") + 
+	       		      IDENTIFIER_LENGTH (protocol_ident) + 1);
 
-  sprintf (buf, "_OBJC_PROTOCOL_REFERENCE_$_%d", protocollist_reference_idx++);
-  decl = start_var_decl (objc_protocol_type, buf);
+  sprintf (buf, "l_OBJC_PROTOCOL_REFERENCE_$_%s", IDENTIFIER_POINTER (protocol_ident));
+  decl = create_hidden_decl (objc_protocol_type, buf);
+  DECL_WEAK (decl) = 1;
+  set_user_assembler_name (decl, buf);
 
   return decl;
 }
+/* APPLE LOCAL end radar 6351990 */
 /* APPLE LOCAL end radar 4533974 - ObjC new protocol */
 
 /* Add the global class meta-data declaration to the list which later on ends up 
@@ -14214,8 +14250,8 @@
         reset_initializer_llvm(decl);
 #endif
       /* LLVM LOCAL end */
-      /* APPLE LOCAL radar 4533974 - ObjC new protocol */
-      objc_add_to_protocol_list_chain (decl);
+      /* APPLE LOCAL radar 4533974 - ObjC new protocol - radar 6351990 */
+      objc_add_to_protocol_list_chain (p, decl);
     }
 }
 
@@ -16878,8 +16914,13 @@
       tree p = TREE_VALUE (rproto);
       if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
         {
-	  objc_merge_methods (class, PROTOCOL_CLS_METHODS (p), '+');
-	  objc_merge_methods (class, PROTOCOL_NST_METHODS (p), '-');
+	  /* APPLE LOCAL begin radar 6370136 */
+	  /* Call objc_merge_methods on copied list of methods, as insertion
+	     of methods in class's method list has side-effect of modifying
+	     protocol's method list which must not change. */
+	  objc_merge_methods (class, copy_list (PROTOCOL_CLS_METHODS (p)), '+');
+	  objc_merge_methods (class, copy_list (PROTOCOL_NST_METHODS (p)), '-');
+	  /* APPLE LOCAL end radar 6370136 */
           /* Search in nested protocols also. */
           objc_merge_proto_properties_in_class (class, PROTOCOL_LIST (p));
         }
@@ -19324,7 +19365,7 @@
   DECL_CONTEXT (decl) = 0;
   DECL_ARTIFICIAL (decl) = 1;
   DECL_INITIAL (decl) = initlist;
-      /* APPLE LOCAL begin LLVM */
+  /* APPLE LOCAL begin LLVM */
 #ifdef ENABLE_LLVM
   /* Let optimizer know that this decl is not removable.  */
   set_user_assembler_name(decl, IDENTIFIER_POINTER (DECL_NAME(decl)));
@@ -20356,63 +20397,10 @@
 }
 /* APPLE LOCAL end radar 5376125 */
 /* APPLE LOCAL begin radar 5782740 - blocks */
-tree retain_block_component (tree exp)
-{
-  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
-  /* We do not want to warn on [id retain] message because we know what we
-   are doing. */
-  tree ret_exp;
-  donot_warn_missing_methods = 1;
-  ret_exp =  objc_finish_message_expr (exp, get_identifier ("retain"), NULL_TREE);
-  donot_warn_missing_methods = 0;
-  return ret_exp;
-  /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
-}
-
-tree release_block_component (tree exp)
-{
-  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
-  /* We do not want to warn on [id release] message because we know what we
-     are doing. */
-  tree ret_exp;
-  donot_warn_missing_methods = 1;
-  ret_exp =  objc_finish_message_expr (exp, get_identifier ("release"), NULL_TREE);
-  donot_warn_missing_methods = 0;
-  return ret_exp;
-  /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
-}
-
-/** copy_in_object - This routine for objective-c object pointers, returns
-    [ [EXP retain] autorelease ] expression which is used in initialization
-    of copied in variable used to set up a block literal struct.
-*/
-tree copy_in_object (tree exp)
-{
-/* APPLE LOCAL begin radar 5808305 */
-  return exp;
-#if 0
-  tree msg_exp;
-  tree type = TREE_TYPE (exp);  
-  if (!objc_is_object_ptr (type))
-    return exp;
-  msg_exp = retain_block_component (exp);
-  msg_exp = objc_finish_message_expr (msg_exp, get_identifier ("autorelease"), NULL_TREE);
-  return msg_exp;
-#endif
-/* APPLE LOCAL end radar 5808305 */
-}
-
 bool block_requires_copying (tree exp)
 {
   return TREE_CODE (TREE_TYPE (exp)) == BLOCK_POINTER_TYPE ||
 	 objc_is_object_ptr (TREE_TYPE (exp));
 }
 /* APPLE LOCAL end radar 5782740 - blocks */
-/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
-tree cast_to_pointer_to_id (tree exp)
-{
-  tree type = build_pointer_type (objc_object_type);
-  return build_c_cast (type, exp);
-}
-/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
 #include "gt-objc-objc-act.h"

Modified: llvm-gcc-4.2/trunk/gcc/stub-objc.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/stub-objc.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/stub-objc.c (original)
+++ llvm-gcc-4.2/trunk/gcc/stub-objc.c Tue Nov 25 16:26:23 2008
@@ -510,6 +510,13 @@
   return;
 }
 /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
+/* APPLE LOCAL begin radar 5847976 */
+int
+objc_is_gcable_type (tree ARG_UNUSED (type))
+{
+  return 0;
+}
+/* APPLE LOCAL end radar 5847976 */
 /* APPLE LOCAL begin radar 4592503 */
 void
 objc_checkon_weak_attribute (tree ARG_UNUSED (decl)) 
@@ -582,18 +589,6 @@
 /* APPLE LOCAL end radar 5202926 */
 
 /* APPLE LOCAL begin radar 5782740 - blocks */
-tree copy_in_object (tree exp)
-{
-  return exp;
-}
-tree retain_block_component (tree ARG_UNUSED (exp))
-{
-  return NULL_TREE;
-}
-tree release_block_component (tree ARG_UNUSED (exp))
-{
-  return NULL_TREE;
-}
 bool block_requires_copying (tree exp)
 {
   /* APPLE LOCAL begin radar 6175959 */
@@ -611,9 +606,3 @@
   return object;
 }
 /* APPLE LOCAL end radar 5802025 */
-/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
-tree cast_to_pointer_to_id (tree exp)
-{
-  return exp;
-}
-/* APPLE LOCAL end radar 5932809 - copyable byref blocks */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-block-67.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/asm-block-67.C?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-block-67.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-block-67.C Tue Nov 25 16:26:23 2008
@@ -0,0 +1,4 @@
+/* { dg-do compile } */ 
+/* { dg-options "-fasm-blocks" } */
+
+int i = 1st;	/* { dg-error "invalid suffix on integer constant" } */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblock.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-weakblock.C?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblock.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblock.C Tue Nov 25 16:26:23 2008
@@ -0,0 +1,54 @@
+/* APPLE LOCAL radar 5847976 */
+/* Test __weak attribute on __block objects. */
+/* { dg-options "-mmacosx-version-min=10.6 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+#import <Foundation/Foundation.h>
+
+// provide our own version for testing
+
+int GotCalled = 0;
+
+void _Block_object_assign(void *destAddr, const void *object, const int flags) {
+    printf("_Block_object_assign(dest %p, value %p, flags %x)\n", destAddr, object, flags);
+    ++GotCalled;
+}
+
+int recovered = 0;
+
+ at interface TestObject : NSObject {
+}
+ at end
+
+ at implementation TestObject
+- (id)retain {
+    printf("Whoops, retain called!\n");
+    exit(1);
+}
+- (void)finalize {
+    ++recovered;
+    [super finalize];
+}
+- (void)dealloc {
+    ++recovered;
+    [super dealloc];
+}
+ at end
+
+
+void testRR() {
+    // create test object
+    TestObject *to = [[TestObject alloc] init];
+    __block TestObject *__weak  testObject = to;    // iniitialization does NOT require support function
+}
+
+int main(int argc, char *argv[]) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    GotCalled = 0;
+    testRR();
+    if (GotCalled == 1) {
+        printf("called out to support function on initialization\n");
+        return 1;
+    }
+    printf("%s: Success\n", argv[0]);
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblockassign.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-weakblockassign.C?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblockassign.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-weakblockassign.C Tue Nov 25 16:26:23 2008
@@ -0,0 +1,61 @@
+/* APPLE LOCAL radar 5847976 */
+/* Test __weak attribute on __block objects. */
+/* { dg-options "-mmacosx-version-min=10.6 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+
+#import <Foundation/Foundation.h>
+
+// provide our own version for testing
+
+int GotCalled = 0;
+
+void objc_assign_weak(id value, id * location) {
+    ++GotCalled;
+    *location = value;
+}
+
+int recovered = 0;
+
+ at interface TestObject : NSObject {
+}
+ at end
+
+ at implementation TestObject
+- (id)retain {
+    printf("Whoops, retain called!\n");
+    exit(1);
+}
+- (void)finalize {
+    ++recovered;
+    [super finalize];
+}
+- (void)dealloc {
+    ++recovered;
+    [super dealloc];
+}
+ at end
+
+
+void testRR() {
+    // create test object
+    TestObject *to = [[TestObject alloc] init];
+    __block TestObject *__weak  testObject = to;    // initialization does NOT require support function
+    
+    // there could be a Block that references "testObject" and that block could have been copied to the
+    // heap and the Block_byref forwarding pointer aims at the heap object.
+    // Assigning to it should trigger, under GC, the objc_assign_weak call
+    testObject = [NSObject new];    // won't last long :-)
+}
+
+int main(int argc, char *argv[]) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    GotCalled = 0;
+    testRR();
+    if (GotCalled == 0) {
+        printf("didn't call out to support function on assignment\n");
+        return 1;
+    }
+    printf("%s: Success\n", argv[0]);
+    return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-67.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-67.c?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-67.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-67.c Tue Nov 25 16:26:23 2008
@@ -0,0 +1,4 @@
+/* { dg-do compile } */ 
+/* { dg-options "-fasm-blocks" } */
+
+int i = 1st;	/* { dg-error "invalid suffix \"st\" on integer constant" } */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblock.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblock.c?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblock.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblock.c Tue Nov 25 16:26:23 2008
@@ -0,0 +1,54 @@
+/* APPLE LOCAL radar 5847976 */
+/* Test __weak attribute on __block objects. */
+/* { dg-options "-mmacosx-version-min=10.6 -ObjC -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+#import <Foundation/Foundation.h>
+
+// provide our own version for testing
+
+int GotCalled = 0;
+
+void _Block_object_assign(void *destAddr, const void *object, const int flags) {
+    printf("_Block_object_assign(dest %p, value %p, flags %x)\n", destAddr, object, flags);
+    ++GotCalled;
+}
+
+int recovered = 0;
+
+ at interface TestObject : NSObject {
+}
+ at end
+
+ at implementation TestObject
+- (id)retain {
+    printf("Whoops, retain called!\n");
+    exit(1);
+}
+- (void)finalize {
+    ++recovered;
+    [super finalize];
+}
+- (void)dealloc {
+    ++recovered;
+    [super dealloc];
+}
+ at end
+
+
+void testRR() {
+    // create test object
+    TestObject *to = [[TestObject alloc] init];
+    __block TestObject *__weak  testObject = to;    // iniitialization does NOT require support function
+}
+
+int main(int argc, char *argv[]) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    GotCalled = 0;
+    testRR();
+    if (GotCalled == 1) {
+        printf("called out to support function on initialization\n");
+        return 1;
+    }
+    printf("%s: Success\n", argv[0]);
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblockassign.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblockassign.c?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblockassign.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-weakblockassign.c Tue Nov 25 16:26:23 2008
@@ -0,0 +1,61 @@
+/* APPLE LOCAL radar 5847976 */
+/* Test __weak attribute on __block objects. */
+/* { dg-options "-mmacosx-version-min=10.6 -ObjC -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+
+#import <Foundation/Foundation.h>
+
+// provide our own version for testing
+
+int GotCalled = 0;
+
+void objc_assign_weak(id value, id * location) {
+    ++GotCalled;
+    *location = value;
+}
+
+int recovered = 0;
+
+ at interface TestObject : NSObject {
+}
+ at end
+
+ at implementation TestObject
+- (id)retain {
+    printf("Whoops, retain called!\n");
+    exit(1);
+}
+- (void)finalize {
+    ++recovered;
+    [super finalize];
+}
+- (void)dealloc {
+    ++recovered;
+    [super dealloc];
+}
+ at end
+
+
+void testRR() {
+    // create test object
+    TestObject *to = [[TestObject alloc] init];
+    __block TestObject *__weak  testObject = to;    // initialization does NOT require support function
+    
+    // there could be a Block that references "testObject" and that block could have been copied to the
+    // heap and the Block_byref forwarding pointer aims at the heap object.
+    // Assigning to it should trigger, under GC, the objc_assign_weak call
+    testObject = [NSObject new];    // won't last long :-)
+}
+
+int main(int argc, char *argv[]) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    GotCalled = 0;
+    testRR();
+    if (GotCalled == 0) {
+        printf("didn't call out to support function on assignment\n");
+        return 1;
+    }
+    printf("%s: Success\n", argv[0]);
+    return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/4299257.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/4299257.c?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/4299257.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/4299257.c Tue Nov 25 16:26:23 2008
@@ -0,0 +1,10 @@
+/* APPLE LOCAL file 4299257 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target sse4 } */
+/* Require a test of the parity flag.  */
+/* { dg-final { scan-assembler "\t\(j|set\)n?p\t" } } */
+typedef float vFloat __attribute__((vector_size(16)));
+char *t(vFloat a, vFloat b)
+{
+  return __builtin_ia32_ucomieq(a, b) ? "y" : "n";
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-objc2-protocol-3.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc2-objc2-protocol-3.mm?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-objc2-protocol-3.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-objc2-protocol-3.mm Tue Nov 25 16:26:23 2008
@@ -0,0 +1,21 @@
+/* APPLE LOCAL file radar 6351990 */
+/* { dg-options "-mmacosx-version-min=10.6 -m32 -fobjc-abi-version=2" { target *-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+ at protocol PROTO
+ at end
+ at protocol PROTO1
+ at end
+ at protocol PROTO2
+ at end
+
+ at interface INTF <PROTO, PROTO1, PROTO2> @end
+
+ at implementation INTF @end
+
+int main()
+{
+	return (long) @protocol(PROTO); + (long) @protocol(PROTO1);
+}
+/* { dg-final { scan-assembler "l_OBJC_LABEL_PROTOCOL_\\\$_PROTO:\n\t.long\tl_OBJC_PROTOCOL_\\\$_PROTO" } } */
+/* { dg-final { scan-assembler "l_OBJC_PROTOCOL_REFERENCE_\\\$_PROTO:\n\t.long\tl_OBJC_PROTOCOL_\\\$_PROTO" } } */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/objc2-objc2-protocol-3.m
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/objc2-objc2-protocol-3.m?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/objc2-objc2-protocol-3.m (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/objc2-objc2-protocol-3.m Tue Nov 25 16:26:23 2008
@@ -0,0 +1,21 @@
+/* APPLE LOCAL file radar 6351990 */
+/* { dg-options "-mmacosx-version-min=10.6 -m32 -fobjc-abi-version=2" { target *-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+ at protocol PROTO
+ at end
+ at protocol PROTO1
+ at end
+ at protocol PROTO2
+ at end
+
+ at interface INTF <PROTO, PROTO1, PROTO2> @end
+
+ at implementation INTF @end
+
+int main()
+{
+	return (long) @protocol(PROTO); + (long) @protocol(PROTO1);
+}
+/* { dg-final { scan-assembler "l_OBJC_LABEL_PROTOCOL_\\\$_PROTO:\n\t.long\tl_OBJC_PROTOCOL_\\\$_PROTO" } } */
+/* { dg-final { scan-assembler "l_OBJC_PROTOCOL_REFERENCE_\\\$_PROTO:\n\t.long\tl_OBJC_PROTOCOL_\\\$_PROTO" } } */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/ok-unimplemented-anon-category.m
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/ok-unimplemented-anon-category.m?rev=60061&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/ok-unimplemented-anon-category.m (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/ok-unimplemented-anon-category.m Tue Nov 25 16:26:23 2008
@@ -0,0 +1,51 @@
+/* APPLE LOCAL file radar 6370136  */
+/* Fix regression caused by fix to radar 6017984 - Test must clean compile. */
+/* { dg-options "-Werror" } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#import <Cocoa/Cocoa.h>
+
+ at interface Foo : NSView <NSTextViewDelegate> {}
+ at end
+
+ at interface FooTextView : NSTextView {}
+ at end
+
+ at protocol FooTextViewDelegate <NSTextViewDelegate>
+- (void)bar:(FooTextView *)textView;
+- (void)bas:(FooTextView *)textView;
+- (void)bat:(FooTextView *)textView;
+ at end
+
+ at interface FooTextView() 
+- (void)setDelegate:(id <FooTextViewDelegate>)delegate;
+- (id <FooTextViewDelegate>)delegate;
+ at end
+
+ at interface Foo() <FooTextViewDelegate>
+ at end
+
+ at implementation Foo
+- (void)bar:(FooTextView *)textView {}
+
+- (void)bas:(FooTextView *)textView {}
+
+- (void)bat:(FooTextView *)textView {}
+ at end
+
+ at implementation FooTextView
+- (void)setDelegate:(id <FooTextViewDelegate>)delegate {
+    [super setDelegate:delegate];
+}
+
+- (id <FooTextViewDelegate>)delegate {
+    return (id <FooTextViewDelegate>)[super delegate];
+}
+
+- (void)jellyBean:(id)sender {
+    [[self delegate] bas:self];
+    [[self delegate] bat:self];
+    [[self delegate] bar:self];
+}
+
+ at end

Modified: llvm-gcc-4.2/trunk/gcc/tree.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.c (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.c Tue Nov 25 16:26:23 2008
@@ -69,10 +69,12 @@
   "expression",
 };
 
+/* APPLE LOCAL begin 6353006  */
+tree generic_block_literal_struct_type;
+/* APPLE LOCAL end 6353006  */
+
 /* obstack.[ch] explicitly declined to prototype this.  */
 extern int _obstack_allocated_p (struct obstack *h, void *obj);
-/* APPLE LOCAL radar 6300081  */
-tree generic_block_literal_struct_type = NULL;
 
 #ifdef GATHER_STATISTICS
 /* Statistics-gathering stuff.  */
@@ -5110,10 +5112,11 @@
 {
   tree t;
   
-  /* APPLE LOCAL begin radar 6300081  */
+  /* APPLE LOCAL begin radar 6300081 & 6353006 */
   if (!generic_block_literal_struct_type)
-    generic_block_literal_struct_type = build_generic_block_struct_type ();
-  /* APPLE LOCAL end radar 6300081  */
+    generic_block_literal_struct_type = 
+                                 lang_hooks.build_generic_block_struct_type ();
+  /* APPLE LOCAL end radar 6300081 & 6353006 */
 
   t = make_node (BLOCK_POINTER_TYPE);
 

Modified: llvm-gcc-4.2/trunk/gcc/tree.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.h (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.h Tue Nov 25 16:26:23 2008
@@ -3070,7 +3070,9 @@
  unsigned copyable_byref_local_nonpod : 1;
  /* APPLE LOCAL radar 6172148 */
  unsigned block_synthesized_function : 1;
- /* 6 unused bits. */
+ /* APPLE LOCAL radar 5847976 */
+ unsigned block_weak : 1;
+ /* 5 unused bits. */
  /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
  /* APPLE LOCAL end radar 5732232 - blocks */
 };
@@ -3127,6 +3129,8 @@
 /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
 #define COPYABLE_BYREF_LOCAL_VAR(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_var)
 #define COPYABLE_BYREF_LOCAL_NONPOD(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_nonpod)
+/* APPLE LOCAL radar 5847976 */
+#define COPYABLE_WEAK_BLOCK(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_weak)
 /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
 
 /* In a VAR_DECL, nonzero if the data should be allocated from
@@ -4853,7 +4857,6 @@
 /* APPLE LOCAL begin radar 6300081  */
 extern GTY(()) tree generic_block_literal_struct_type;
 
-extern tree build_generic_block_struct_type (void);
 /* APPLE LOCAL end radar 6300081  */
 
 #endif  /* GCC_TREE_H  */

Modified: llvm-gcc-4.2/trunk/gcc/version.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/version.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/version.c (original)
+++ llvm-gcc-4.2/trunk/gcc/version.c Tue Nov 25 16:26:23 2008
@@ -11,12 +11,12 @@
 /* APPLE LOCAL begin Apple version */
 #ifdef ENABLE_LLVM
 #ifdef LLVM_VERSION_INFO
-#define VERSUFFIX " (Based on Apple Inc. build 5627) (LLVM build " LLVM_VERSION_INFO ")"
+#define VERSUFFIX " (Based on Apple Inc. build 5628) (LLVM build " LLVM_VERSION_INFO ")"
 #else
-#define VERSUFFIX " (Based on Apple Inc. build 5627) (LLVM build)"
+#define VERSUFFIX " (Based on Apple Inc. build 5628) (LLVM build)"
 #endif
 #else
-#define VERSUFFIX " (Based on Apple Inc. build 5627)"
+#define VERSUFFIX " (Based on Apple Inc. build 5628)"
 #endif
 /* APPLE LOCAL end Apple version */
 

Modified: llvm-gcc-4.2/trunk/libcpp/expr.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libcpp/expr.c?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/libcpp/expr.c (original)
+++ llvm-gcc-4.2/trunk/libcpp/expr.c Tue Nov 25 16:26:23 2008
@@ -160,7 +160,8 @@
    floating point, or invalid), radix (decimal, octal, hexadecimal),
    and type suffixes.  */
 unsigned int
-cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
+/* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+cpp_classify_number (cpp_reader *pfile, const cpp_token *token, int defer)
 {
   const uchar *str = token->val.str.text;
   const uchar *limit;
@@ -293,8 +294,8 @@
 	  /* APPLE LOCAL begin CW asm blocks C++ comments 4248139 */
 	  /* Because we don't regonize inline asm comments during
 	     lexing, we have to avoid erroring out now.  */
-	  if (cpp_get_options (pfile)->h_suffix)
-	    return CPP_N_INVALID;
+	  if (defer && cpp_get_options (pfile)->h_suffix)
+	    return CPP_N_INVALID | CPP_N_DEFER;
 	  /* APPLE LOCAL end CW asm blocks C++ comments 4248139 */
 
 	  cpp_error (pfile, CPP_DL_ERROR,
@@ -569,7 +570,8 @@
   switch (token->type)
     {
     case CPP_NUMBER:
-      temp = cpp_classify_number (pfile, token);
+      /* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+      temp = cpp_classify_number (pfile, token, 0);
       switch (temp & CPP_N_CATEGORY)
 	{
 	case CPP_N_FLOATING:

Modified: llvm-gcc-4.2/trunk/libcpp/include/cpplib.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libcpp/include/cpplib.h?rev=60061&r1=60060&r2=60061&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/libcpp/include/cpplib.h (original)
+++ llvm-gcc-4.2/trunk/libcpp/include/cpplib.h Tue Nov 25 16:26:23 2008
@@ -184,6 +184,10 @@
 #define BOL		(1 << 6) /* Token at beginning of line.  */
 #define PURE_ZERO	(1 << 7) /* Single 0 digit, used by the C++ frontend,
 				    set in c-lex.c.  */
+/* APPLE LOCAL begin CW asm blocks C++ comments 6338079 */
+#define ERROR_DEFERRED  PURE_ZERO/* Set when an invalid suffix error is
+				    deferred out of cpp.  */
+/* APPLE LOCAL end CW asm blocks C++ comments 6338079 */
 
 /* Specify which field, if any, of the cpp_token union is used.  */
 
@@ -859,10 +863,13 @@
 #define CPP_N_UNSIGNED	0x1000	/* Properties.  */
 #define CPP_N_IMAGINARY	0x2000
 #define CPP_N_DFLOAT	0x4000
+/* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+#define CPP_N_DEFER	0x8000
 
 /* Classify a CPP_NUMBER token.  The return value is a combination of
    the flags from the above sets.  */
-extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *);
+/* APPLE LOCAL CW asm blocks C++ comments 6338079 */
+extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *, int);
 
 /* Evaluate a token classified as category CPP_N_INTEGER.  */
 extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,





More information about the llvm-commits mailing list