[llvm-commits] [llvm-gcc-4.2] r54307 - in /llvm-gcc-4.2/trunk/gcc: c-decl.c c-parser.c c-pragma.c cp/call.c cp/method.c cp/semantics.c cp/typeck.c gimplify.c print-tree.c toplev.c tree.c

Bill Wendling isanbard at gmail.com
Sat Aug 2 21:42:46 PDT 2008


Author: void
Date: Sat Aug  2 23:42:46 2008
New Revision: 54307

URL: http://llvm.org/viewvc/llvm-project?rev=54307&view=rev
Log:
Update to Apple GCC's 4.2 mainline. This patch mostly includes fixes for the
"blocks" stuff.

Modified:
    llvm-gcc-4.2/trunk/gcc/c-decl.c
    llvm-gcc-4.2/trunk/gcc/c-parser.c
    llvm-gcc-4.2/trunk/gcc/c-pragma.c
    llvm-gcc-4.2/trunk/gcc/cp/call.c
    llvm-gcc-4.2/trunk/gcc/cp/method.c
    llvm-gcc-4.2/trunk/gcc/cp/semantics.c
    llvm-gcc-4.2/trunk/gcc/cp/typeck.c
    llvm-gcc-4.2/trunk/gcc/gimplify.c
    llvm-gcc-4.2/trunk/gcc/print-tree.c
    llvm-gcc-4.2/trunk/gcc/toplev.c
    llvm-gcc-4.2/trunk/gcc/tree.c

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=54307&r1=54306&r2=54307&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-decl.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-decl.c Sat Aug  2 23:42:46 2008
@@ -326,13 +326,13 @@
   tree blocks;
   tree blocks_last;
 
-  /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
+  /* APPLE LOCAL begin radar 6083129 -  byref escapes */
   /* None-zero if outermost block of a statement which can have a 
      break/continue stmt; such as while, switch, etc. This cannot be
      a boolen field because the same scope can be used for a nested
      while/for statement; as in, while(...) while (...). */
   unsigned int  bc_stmt_body;
-  /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
+  /* APPLE LOCAL end radar 6083129 -  byref escapes */
 
   /* The depth of this scope.  Used to keep the ->shadowed chain of
      bindings sorted innermost to outermost.  */
@@ -360,11 +360,11 @@
   /* True means make a BLOCK for this scope no matter what.  */
   BOOL_BITFIELD keep : 1;
 
-  /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
-  /* When true, current scope has at least one local __block variable
+  /* APPLE LOCAL begin radar 6083129 -  byref escapes */
+  /* When true, current scope has at least one local __byref variable
      in its scope. This flag is used for compile-time performance. */
   BOOL_BITFIELD byref_in_current_scope : 1;
-  /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
+  /* APPLE LOCAL end radar 6083129 -  byref escapes */
 };
 
 /* The scope currently in effect.  */
@@ -688,10 +688,10 @@
       scope->keep          = keep_next_level_flag;
       scope->outer         = current_scope;
       scope->depth	   = current_scope ? (current_scope->depth + 1) : 0;
-      /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
+      /* APPLE LOCAL begin radar 6083129 -  byref escapes */
       scope->byref_in_current_scope = 
         current_scope ? current_scope->byref_in_current_scope : false;
-      /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
+      /* APPLE LOCAL end radar 6083129 -  byref escapes */
 
       /* Check for scope depth overflow.  Unlikely (2^28 == 268,435,456) but
 	 possible.  */
@@ -716,7 +716,7 @@
     TYPE_CONTEXT (type) = context;
 }
 
-/* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
+/* APPLE LOCAL begin radar 6083129 -  byref escapes */
 /* This routine is called at the begining of parsing of a while/for, etc.
    statement and sets bc_stmt_body in current scope to say that outer scope 
    is for such a statement. */
@@ -753,19 +753,20 @@
     {
       tree p = b->decl;
       if (p && TREE_CODE (p) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (p))
-	gen_block_byref_release_exp (p);
+        gen_block_byref_release_exp (p);
     }
+    /* APPLE LOCAL begin radar 6083129 */
     /* Release up to scope of the block. */
     if (cur_block && cur_block->the_scope == scope)
       break;
+    /* APPLE LOCAL end radar 6083129 */
     scope = scope->outer;
   }
 }
 
-/* This routine issues a diagnostic if a __block variable is seen in
-   the current scope.  This is for now called from a goto statement.  */
-void
-diagnose_byref_var_in_current_scope (void)
+/* This routine issues a diagnostic if a __byref variable is seen in
+   current scope. This is for now called from a goto statement. */
+void diagnose_byref_var_in_current_scope (void)
 {
   struct c_scope *scope;
   struct c_binding *b;
@@ -789,9 +790,8 @@
     scope = scope->outer;
   }
 }
-
 /* This routine generates call to _Block_byref_release(VAR_DECL.forwarding);
-   for all __block variables which go out of scope when 'break' is executed.
+   for all __byref variables which go out of scope when 'break' is executed.
 */
 void release_local_byrefs_at_break (void)
 {
@@ -809,13 +809,13 @@
     {
       tree p = b->decl;
       if (p && TREE_CODE (p) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (p))
-	gen_block_byref_release_exp (p);
+        gen_block_byref_release_exp (p);
     }
     scope = scope->outer;
   }
 }
 
-/* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
+/* APPLE LOCAL end radar 6083129 -  byref escapes */
 
 /* Exit a scope.  Restore the state of the identifier-decl mappings
    that were in effect when this scope was entered.  Return a BLOCK
@@ -947,10 +947,10 @@
 	  goto common_symbol;
 
 	case VAR_DECL:
-         /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
+         /* APPLE LOCAL begin radar 6083129 -  byref escapes */
             if (!flag_objc_gc_only && COPYABLE_BYREF_LOCAL_VAR (p))
               gen_block_byref_release_exp (p);
-         /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
+         /* APPLE LOCAL end radar 6083129 -  byref escapes */
 
 	  /* Warnings for unused variables.  */
 	  if (!TREE_USED (p)
@@ -1875,12 +1875,13 @@
       DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
       DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
       DECL_MODE (newdecl) = DECL_MODE (olddecl);
-      if (TREE_CODE (olddecl) != FUNCTION_DECL)
-	if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
-	  {
-	    DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
-	    DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl);
-	  }
+      /* APPLE LOCAL begin mainline aligned functions 5933878 */
+      if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
+	{
+	  DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
+	  DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl);
+	}
+      /* APPLE LOCAL end mainline aligned functions 5933878 */
     }
 
 
@@ -3707,13 +3708,12 @@
 build_indirect_object_id_exp (tree exp)
 {
   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
    of the object passed offset by: void* + int + int + void* + void *
    This must match definition of Block_byref structs. */
-  offset = GET_MODE_SIZE (Pmode) + sizeof (unsigned_type_node) +
-           sizeof (unsigned_type_node) + GET_MODE_SIZE (Pmode) +
+  offset = GET_MODE_SIZE (Pmode) + int_size + int_size + GET_MODE_SIZE (Pmode) +
            GET_MODE_SIZE (Pmode);
   dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
                     build_int_cst (NULL_TREE, offset));
@@ -3833,8 +3833,8 @@
  struct Block_byref_x *forwarding;
  int32_t flags;
  int32_t size;
- void *ByrefKeepFuncPtr;    // Only if variable is __block ObjC object
- void *ByrefDestroyFuncPtr; // Only if variable is __block ObjC object
+ void *ByrefKeepFuncPtr;    // Only if variable is __byref ObjC object
+ void *ByrefDestroyFuncPtr; // Only if variable is __byref ObjC object
  typex x;
  } x;
 */
@@ -3905,7 +3905,7 @@
    { &x, 0, sizeof(struct __Block_byref_x)};
    when INIT is NULL_TREE
 
-   For __block ObjC objects, it also adds "byref_keep" and "byref_destroy"
+   For __byref ObjC objects, it also adds "byref_keep" and "byref_destroy"
    Funtion pointers. So the most general initializers would be:
 
    { &x, 0, sizeof(struct __Block_byref_x), &byref_keep, &byref_destroy,
@@ -4016,14 +4016,14 @@
   if (TREE_CODE (decl) == PARM_DECL)
     init = 0;
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
-  /* We build a new type for each local variable declared as __block
+  /* We build a new type for each local variable declared as __byref
      and initialize it to a list of initializers. */
   else if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
     {
       if (DECL_EXTERNAL (decl) || TREE_STATIC (decl))
 	{
 	  warning (0,
-		   "__block attribute is only allowed on local variables - ignored");
+		   "__byref attribute is only allowed on local variables - ignored");
 	  COPYABLE_BYREF_LOCAL_VAR (decl) = 0;
 	  COPYABLE_BYREF_LOCAL_NONPOD (decl) = 0;
 	}
@@ -4031,7 +4031,7 @@
 	{
 	  decl = new_block_byref_decl (decl);
 	  init = init_byref_decl (decl, init);
-          /* Mark that current scope has a __block local variable. */
+          /* Mark that current scope has a __byref local variable. */
           current_scope->byref_in_current_scope = true;
 	}
     }
@@ -7957,7 +7957,6 @@
   tree ptr_type = (TREE_CODE (decl) == VAR_DECL && BLOCK_DECL_BYREF (decl))
                    ? TREE_TYPE (decl) : build_pointer_type (TREE_TYPE (decl));
   tree byref_decl = build_decl (VAR_DECL, name, ptr_type);
-  DECL_CONTEXT (byref_decl) = current_function_decl;
   BLOCK_DECL_BYREF (byref_decl) = 1;
 
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ch) */
@@ -7979,8 +7978,6 @@
   return byref_decl;
 }
 
-#define BINDING_VALUE(b) ((b)->decl)
-
 /**
   build_block_ref_decl - This routine inserts a copied-in variable (a variable
   referenced in the block but whose scope is outside the block) in helper
@@ -7993,78 +7990,55 @@
   struct c_scope *scope = current_scope;
   tree ref_decl;
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ch) */
-  /* 'decl' was previously declared as __block.  Simply, copy the value
+  /* 'decl' was previously declared as __byref. Simply, copy the value
      embedded in the above variable. */
   if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
     decl = build_byref_local_var_access (decl, DECL_NAME (decl));
   else {
-    /* APPLE LOCAL begin radar 5988451 (C++ ch) */
+    /* APPLE LOCAL begin radar 5988451 */
     if (cur_block->prev_block_info) {
       /* Traverse enclosing blocks. Insert a copied-in variable in each
          enclosing block which has no declaration of this variable. This is
          to ensure that the current (inner) block has the 'frozen' value of the
          copied-in variable; which means the value of the copied in variable
          is at the point of the block declaration and *not* when the inner block
-         is invoked.
+         is envoked.
       */
       struct block_sema_info *cb = cur_block->prev_block_info;
       while (cb) {
         struct c_binding *b = I_SYMBOL_BINDING (name);
-        gcc_assert (b);
-	gcc_assert (BINDING_VALUE (b));
-	gcc_assert (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
-		    || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL);
-	gcc_assert ((b->depth >= cur_block->the_scope->depth)
-		    == (DECL_CONTEXT (BINDING_VALUE (b)) == cur_block->helper_func_decl));
         /* Find the first declaration not in current block. */
-        while (b && BINDING_VALUE (b)
-               && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL 
-                   || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL)
-               && DECL_CONTEXT (BINDING_VALUE (b)) == cur_block->helper_func_decl)
-	  {
-	    /* FIXME: This can't happen?!  */
-	    abort ();
-	    b = b->shadowed;
-	  }
+        while (b && b->decl 
+               && (TREE_CODE (b->decl) == VAR_DECL 
+                   || TREE_CODE (b->decl) == PARM_DECL)
+               && b->depth >= cur_block->the_scope->depth)
+          b = b->shadowed;
         
-	gcc_assert (b);
-	gcc_assert (BINDING_VALUE (b));
-	gcc_assert (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL 
-		    || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL);
-	gcc_assert ((b->depth < cb->the_scope->depth)
-		    == (DECL_CONTEXT (BINDING_VALUE (b)) != cb->helper_func_decl));
-
-        /* Is the next declaration not in the enclosing block? */
-        if (b && BINDING_VALUE (b)
-            && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL 
-                || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL)
-            && DECL_CONTEXT (BINDING_VALUE (b)) != cb->helper_func_decl)
-	  {
-	    /* No declaration of variable seen in the block. Must
-	       insert one, so it 'freezes' the variable in this
-	       block. */
-	    struct c_scope *save_scope = current_scope;
-	    struct block_sema_info *save_current_block = cur_block;
-	    tree save_current_function_decl = current_function_decl;
-	    current_scope = cb->the_scope;
-	    cur_block = cb;
-	    current_function_decl = cb->helper_func_decl;
-	    decl = build_block_ref_decl (name, decl);
-	    cur_block = save_current_block;
-	    current_scope = save_scope;
-	    current_function_decl = save_current_function_decl;
-	  }
+        /* Is the next declaration not in enclosing block? */
+        if (b && b->decl 
+            && (TREE_CODE (b->decl) == VAR_DECL 
+                || TREE_CODE (b->decl) == PARM_DECL)
+            && b->depth < cb->the_scope->depth) {
+          /* No declaration of variable seen in the block. Must insert one,
+             so it 'freezes' the variable in this block. */
+          struct c_scope *save_scope = current_scope;
+          struct block_sema_info *save_current_block = cur_block;
+          current_scope = cb->the_scope;
+          cur_block = cb;
+          decl = build_block_ref_decl (name, decl);
+          cur_block = save_current_block;
+          current_scope = save_scope;
+        }
         cb = cb->prev_block_info; 
       }
     }
-    /* APPLE LOCAL end radar 5988451 (C++ ch) */
+    /* APPLE LOCAL end radar 5988451 */
   }
   /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
 
   ref_decl = build_decl (VAR_DECL, name,
                          build_qualified_type (TREE_TYPE (decl),
                                                TYPE_QUAL_CONST));
-  DECL_CONTEXT (ref_decl) = current_function_decl;
   DECL_INITIAL (ref_decl) = error_mark_node;
   /* APPLE LOCAL radar 5805175 - blocks (C++ ch) */
   c_apply_type_quals_to_decl (TYPE_QUAL_CONST, ref_decl);
@@ -8201,22 +8175,20 @@
   return (cur_block && cur_block->the_scope == current_scope);
 }
 
-/* This routine returns 'true' if 'name' has a declaration inside the
-   current block, 'false' otherwise.  If 'name' has no declaration in
-   the current block, it returns in DECL the user declaration for
-   'name' found in the enclosing scope.  Note that if it is declared
-   in current declaration, it can be either a user declaration or a
-   byref/copied-in declaration added in current block's scope by the
-   compiler.  */
+/* This routine returns 'true' if 'name' has a declaration inside
+   block, 'false' otherwise. If 'name' has no declaration in current
+   block, it returns in DECL the user declaration for 'name' found in
+   the enclosing scope. Note that if it is declared in current
+   declaration, it can be either a user declaration or a
+   byref/copied-in declaration added in current block's scope by
+   the compiler.  */
 bool
 lookup_name_in_block (tree name, tree *decl)
 {
   if (cur_block)
     {
       struct c_binding *b = I_SYMBOL_BINDING (name);
-      gcc_assert ((b->depth >= cur_block->the_scope->depth)
-		  == (DECL_CONTEXT (BINDING_VALUE (b)) == current_function_decl));
-      if (DECL_CONTEXT (BINDING_VALUE (b)) == current_function_decl)
+      if (b->depth >= cur_block->the_scope->depth)
 	return true;
 
       /* Check for common case of block nested inside a non-block. */
@@ -8232,13 +8204,13 @@
          enclosing block is found, it must be returned as this is
          where the variable in current (nested block) will have to get
          its value. */
-      while (b && BINDING_VALUE (b) 
-	     && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL)
-             && BLOCK_DECL_BYREF (BINDING_VALUE (b)))
+      while (b && b->decl 
+	     && (TREE_CODE (b->decl) == VAR_DECL)
+             && BLOCK_DECL_BYREF (b->decl))
         b = b->shadowed;
 	/* APPLE LOCAL end radar 5988451 (C++ ch) */
-      if (b && BINDING_VALUE (b))
-	*decl = BINDING_VALUE (b);
+      if (b && b->decl)
+	*decl = b->decl;
     }
   return false;
 }

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=54307&r1=54306&r2=54307&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-parser.c Sat Aug  2 23:42:46 2008
@@ -9465,7 +9465,7 @@
     }
 
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
-  /* Further check to see that we have __block variables which require
+  /* Further check to see that we have __byref variables which require
      Copy/Dispose helpers. */
   for (chain = block_impl->block_byref_decl_list; chain;
        chain = TREE_CHAIN (chain))
@@ -9791,7 +9791,7 @@
     }
 
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
-  /* For each __block declared variable used in |...| Must generate call to:
+  /* For each __byref declared variable used in |...| Must generate call to:
      _Block_byref_assign_copy(&_dest->myImportedBlock, _src->myImportedBlock)
   */
   for (chain = block_impl->block_byref_decl_list; chain;
@@ -9904,7 +9904,7 @@
     }
 
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
-  /* For each __block declared variable used in |...| Must generate call to:
+  /* For each __byref declared variable used in |...| Must generate call to:
    _Block_byref_release(_src->myImportedClosure)
    */
   for (chain = block_impl->block_byref_decl_list; chain;

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-pragma.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-pragma.c Sat Aug  2 23:42:46 2008
@@ -54,7 +54,8 @@
 static GTY(()) struct align_stack * alignment_stack;
 
 /* LLVM LOCAL begin */
-#ifndef TARGET_OVERRIDE_PRAGMA_PACK_HANDLER
+/* APPLE LOCAL Macintosh alignment (disable) */
+#if defined(ENABLE_LLVM) && !defined(TARGET_OVERRIDE_PRAGMA_PACK_HANDLER)
 /* LLVM LOCAL end */
 
 #ifdef HANDLE_PRAGMA_PACK
@@ -250,7 +251,7 @@
 #endif  /* HANDLE_PRAGMA_PACK */
 
 /* LLVM LOCAL begin */
-#endif /* TARGET_OVERRIDE_PRAGMA_PACK_HANDLER */
+#endif /* ENABLE_LLVM && !TARGET_OVERRIDE_PRAGMA_PACK_HANDLER */
 /* LLVM LOCAL end */
 
 static GTY(()) tree pending_weaks;
@@ -821,7 +822,11 @@
 				PRAGMA_GCC_PCH_PREPROCESS, false, false);
 
 /* LLVM LOCAL begin */
-#ifndef TARGET_OVERRIDE_PRAGMA_PACK_HANDLER
+/* APPLE LOCAL begin Macintosh alignment (disable section) 2002-1-22 --ff */
+  /* Remove the handling of pragma pack here because it is handled
+     in config/darwin-c.c.  */
+#if defined(ENABLE_LLVM) && !defined(TARGET_OVERRIDE_PRAGMA_PACK_HANDLER)
+/* APPLE LOCAL end Macintosh alignment (disable section) 2002-1-22 --ff */
 /* LLVM LOCAL end */
 #ifdef HANDLE_PRAGMA_PACK
 #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION
@@ -830,9 +835,8 @@
   c_register_pragma (0, "pack", handle_pragma_pack);
 #endif
 #endif
-/* LLVM LOCAL begin */
-#endif
-/* LLVM LOCAL end */
+/* LLVM LOCAL */
+#endif /* ENABLE_LLVM && !TARGET_OVERRIDE_PRAGMA_PACK_HANDLER */
 #ifdef HANDLE_PRAGMA_WEAK
   c_register_pragma (0, "weak", handle_pragma_weak);
 #endif

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/call.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/call.c Sat Aug  2 23:42:46 2008
@@ -684,6 +684,10 @@
     {
       conv = build_conv (ck_ptr, to, conv);
     }
+  else if (tcode == BLOCK_POINTER_TYPE && objc_is_id (from))
+    {
+      conv = build_conv (ck_ptr, to, conv);
+    }
   /* APPLE LOCAL end blocks (ck) */
   else if ((tcode == POINTER_TYPE && fcode == POINTER_TYPE)
 	   || (TYPE_PTRMEM_P (to) && TYPE_PTRMEM_P (from)))

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/method.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/method.c Sat Aug  2 23:42:46 2008
@@ -1118,6 +1118,16 @@
   TREE_CHAIN (this_parm) = DECL_ARGUMENTS (fn);
   DECL_ARGUMENTS (fn) = this_parm;
 
+  /* APPLE LOCAL begin mainline aligned functions 5933878 */
+  /* If pointers to member functions use the least significant bit to
+     indicate whether a function is virtual, ensure a pointer
+     to this function will have that bit clear.  */
+  if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
+      && TREE_CODE (fn_type) == METHOD_TYPE
+      && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT)
+    DECL_ALIGN (fn) = 2 * BITS_PER_UNIT;
+  /* APPLE LOCAL end mainline aligned functions 5933878 */
+
   grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL);
   set_linkage_according_to_type (type, fn);
   rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/semantics.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/semantics.c Sat Aug  2 23:42:46 2008
@@ -774,6 +774,12 @@
 
   expr = check_return_expr (expr, &no_warning);
 
+  /* APPLE LOCAL begin radar 6040305 - blocks */
+  if (current_function_decl && BLOCK_HELPER_FUNC (current_function_decl)
+      && !cur_block)
+    return expr;
+  /* APPLE LOCAL end radar 6040305 - blocks */
+
   if (flag_openmp && !check_omp_return ())
     return error_mark_node;
   if (!processing_template_decl)

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/typeck.c Sat Aug  2 23:42:46 2008
@@ -1376,7 +1376,12 @@
     {
       pedwarn ("ISO C++ forbids applying %<__alignof%> to an expression of "
 	       "function type");
-      t = size_one_node;
+      /* APPLE LOCAL begin mainline aligned functions 5933878 */
+      if (TREE_CODE (e) == FUNCTION_DECL)
+	t = size_int (DECL_ALIGN_UNIT (e));
+      else
+	t = size_one_node;
+      /* APPLE LOCAL end mainline aligned functions 5933878 */
     }
   else if (type_unknown_p (e))
     {
@@ -2742,6 +2747,42 @@
   return function;
 }
 
+/* APPLE LOCAL begin blocks 6040305 */
+/**
+ build_block_call - Routine to build a block call; as in:
+ ((double(*)(struct invok_impl *, int))(BLOCK_PTR_VAR->FuncPtr))(I, 42);
+ FNTYPE is the original function type derived from the syntax.
+ FUNCTION is the4 block pointer variable.
+ PARAMS is the parameter list.
+ */
+static tree
+build_block_call (tree fntype, tree function, tree params)
+{
+  tree block_ptr_exp;
+  tree function_ptr_exp;
+  tree typelist;
+  
+  /* (struct invok_impl *)BLOCK_PTR_VAR */
+  /* First convert it to 'void *'. */
+  block_ptr_exp = convert (ptr_type_node, function);
+  gcc_assert (invoke_impl_ptr_type);
+  block_ptr_exp = convert (invoke_impl_ptr_type, block_ptr_exp);
+  params = tree_cons (NULL_TREE, block_ptr_exp, params);
+  /* BLOCK_PTR_VAR->FuncPtr */
+  function_ptr_exp =
+  finish_class_member_access_expr (build_indirect_ref (block_ptr_exp, "->"),
+                       get_identifier ("FuncPtr"), false);
+  
+  /* Build: result_type(*)(struct invok_impl *, function-arg-type-list) */
+  typelist = TYPE_ARG_TYPES (fntype);
+  typelist = tree_cons (NULL_TREE, invoke_impl_ptr_type, typelist);
+  fntype = build_function_type (TREE_TYPE (fntype), typelist);
+  function_ptr_exp = convert (build_pointer_type (fntype), function_ptr_exp);
+  return  build3 (CALL_EXPR, TREE_TYPE (fntype),
+                  function_ptr_exp, params, NULL_TREE);
+}
+/* APPLE LOCAL end blocks 6040305 */
+
 tree
 build_function_call (tree function, tree params)
 {
@@ -2830,7 +2871,11 @@
 
   check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params,
 			    TYPE_ARG_TYPES (fntype));
-
+  /* APPLE LOCAL begin blocks 6040305 */
+  if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
+    return build_block_call (fntype, function, coerced_params);
+  /* APPLE LOCAL end blocks 6040305 */
+  
   return build_cxx_call (function, coerced_params);
 }
 
@@ -6860,42 +6905,6 @@
 {
   return comptypes (t1, t2, COMPARE_STRICT);
 }
-
-#if 0
-/**
- build_block_call - Routine to build a block call; as in:
-  ((double(*)(struct invok_impl *, int))(BLOCK_PTR_VAR->FuncPtr))(I, 42);
- FNTYPE is the original function type derived from the syntax.
- FUNCTION is the4 block pointer variable.
- PARAMS is the parameter list.
-*/
-static tree
-build_block_call (tree fntype, tree function, tree params)
-{
-  tree block_ptr_exp;
-  tree function_ptr_exp;
-  tree typelist;
-
-  /* (struct invok_impl *)BLOCK_PTR_VAR */
-  /* First convert it to 'void *'. */
-  block_ptr_exp = convert (ptr_type_node, function);
-  gcc_assert (invoke_impl_ptr_type);
-  block_ptr_exp = convert (invoke_impl_ptr_type, block_ptr_exp);
-  params = tree_cons (NULL_TREE, block_ptr_exp, params);
-  /* BLOCK_PTR_VAR->FuncPtr */
-  function_ptr_exp =
-    build_component_ref (build_indirect_ref (block_ptr_exp, "->"),
-                         get_identifier ("FuncPtr"));
-
-  /* Build: result_type(*)(struct invok_impl *, function-arg-type-list) */
-  typelist = TYPE_ARG_TYPES (fntype);
-  typelist = tree_cons (NULL_TREE, invoke_impl_ptr_type, typelist);
-  fntype = build_function_type (TREE_TYPE (fntype), typelist);
-  function_ptr_exp = convert (build_pointer_type (fntype), function_ptr_exp);
-  return fold_build3 (CALL_EXPR, TREE_TYPE (fntype),
-                      function_ptr_exp, params, NULL_TREE);
-}
-#endif
 /* APPLE LOCAL end blocks 6040305 (cm) */
 
 /* Check that returning RETVAL from the current function is valid.
@@ -6968,7 +6977,7 @@
 	  if (retval)
 	    {
 	      error ("void block should not return a value");
-	      retval = NULL_TREE;
+	      retval = error_mark_node;
 	    }
 	  return retval;
 	}
@@ -6976,7 +6985,7 @@
       if (!retval)
 	{
 	  error ("non-void block should return a value");
-	  return retval;
+	  return error_mark_node;
 	}
   
       /* We have a non-void block with an expression, continue checking.  */
@@ -6985,8 +6994,11 @@
       /* For now, restrict multiple return statements in a block to have 
 	 strict compatible types only. */
       if (!types_are_block_compatible (cur_block->return_type, valtype))
-	error ("incompatible type returning %qT, expected %qT", 
-	       valtype, cur_block->return_type);
+	{
+	  error ("incompatible type returning %qT, expected %qT",
+		 valtype, cur_block->return_type);
+	  retval = error_mark_node;
+	}
       return retval;
     }
   /* APPLE LOCAL end blocks 6040305 (cm) */
@@ -7524,3 +7536,17 @@
 
   return win;
 }
+
+/* APPLE LOCAL begin radar 6040305 - blocks */
+tree c_finish_return (tree exp)
+{
+  /* Unlike c front-end, genericize gets called in the middle of
+     block parsing. Must not convert the expression tree at that
+     time. */
+  if (cur_block)
+    return exp;
+  gcc_assert (current_function_decl
+              && BLOCK_HELPER_FUNC (current_function_decl));
+  return finish_return_stmt (exp);
+}
+/* APPLE LOCAL end radar 6040305 - blocks */

Modified: llvm-gcc-4.2/trunk/gcc/gimplify.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gimplify.c?rev=54307&r1=54306&r2=54307&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/gimplify.c (original)
+++ llvm-gcc-4.2/trunk/gcc/gimplify.c Sat Aug  2 23:42:46 2008
@@ -1148,7 +1148,8 @@
   tree result_decl, result;
 
   if (!ret_expr || TREE_CODE (ret_expr) == RESULT_DECL
-      || ret_expr == error_mark_node)
+      /* APPLE LOCAL begin radar 6040305 - blocks */
+      || ret_expr == error_mark_node || cur_block)
     return GS_ALL_DONE;
 
   if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/print-tree.c (original)
+++ llvm-gcc-4.2/trunk/gcc/print-tree.c Sat Aug  2 23:42:46 2008
@@ -455,17 +455,17 @@
 	      || DECL_INLINE (node) || DECL_BUILT_IN (node))
 	    indent_to (file, indent + 3);
 	  
-	  if (TREE_CODE (node) != FUNCTION_DECL)
-	    {
-	      if (DECL_USER_ALIGN (node))
-		fprintf (file, " user");
-	      
-	      fprintf (file, " align %d", DECL_ALIGN (node));
-	      if (TREE_CODE (node) == FIELD_DECL)
-		fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
-			 DECL_OFFSET_ALIGN (node));
-	    }
-	  else if (DECL_BUILT_IN (node))
+	  /* APPLE LOCAL begin mainline aligned functions 5933878 */
+	  if (DECL_USER_ALIGN (node))
+	    fprintf (file, " user");
+
+	  fprintf (file, " align %d", DECL_ALIGN (node));
+	  if (TREE_CODE (node) == FIELD_DECL)
+	    fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
+		     DECL_OFFSET_ALIGN (node));
+
+	  if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
+	  /* APPLE LOCAL end mainline aligned functions 5933878 */
 	    {
 	      if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
 		fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));

Modified: llvm-gcc-4.2/trunk/gcc/toplev.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/toplev.c?rev=54307&r1=54306&r2=54307&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/toplev.c (original)
+++ llvm-gcc-4.2/trunk/gcc/toplev.c Sat Aug  2 23:42:46 2008
@@ -2013,6 +2013,12 @@
   if (flag_cx_limited_range)
     flag_complex_method = 0;
 
+  /* APPLE LOCAL begin stack-protector default 5095227 */
+  /* Unless the target chooses otherwise, default stack protection to off.  */
+  if (flag_stack_protect == -1)
+    flag_stack_protect = 0;
+  /* APPLE LOCAL end stack-protector default 5095227 */
+
   /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */
   cl_pf_opts_cooked = cl_pf_opts;
   /* APPLE LOCAL end optimization pragmas 3124235/3420242 */

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=54307&r1=54306&r2=54307&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.c (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.c Sat Aug  2 23:42:46 2008
@@ -6823,12 +6823,21 @@
   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
-  /* LLVM local begin */
+  /* LLVM LOCAL begin */
   ftype = build_function_type (ptr_type_node, tmp);
   local_define_builtin ("__builtin_init_trampoline", ftype,
 			BUILT_IN_INIT_TRAMPOLINE,
 			"__builtin_init_trampoline", ECF_NOTHROW);
-  /* LLVM local end */
+
+#ifndef ENABLE_LLVM
+  tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
+  ftype = build_function_type (ptr_type_node, tmp);
+  local_define_builtin ("__builtin_adjust_trampoline", ftype,
+			BUILT_IN_ADJUST_TRAMPOLINE,
+			"__builtin_adjust_trampoline",
+			ECF_CONST | ECF_NOTHROW);
+#endif
+  /* LLVM LOCAL end */
 
   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);





More information about the llvm-commits mailing list