diff gcc/ipa.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/ipa.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/ipa.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* Basic IPA optimizations and utilities.
-   Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   Copyright (C) 2003-2018 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -130,9 +130,11 @@
 		     constant folding.  Keep references alive so partitioning
 		     knows about potential references.  */
 		  || (VAR_P (node->decl)
-		      && flag_wpa
-		      && ctor_for_folding (node->decl)
-		         != error_mark_node))))
+		      && (flag_wpa
+			  || flag_incremental_link
+			 	 == INCREMENTAL_LINK_LTO)
+		      && dyn_cast <varpool_node *> (node)
+		      	   ->ctor_useable_for_folding_p ()))))
 	{
 	  /* Be sure that we will not optimize out alias target
 	     body.  */
@@ -223,13 +225,8 @@
 		       (builtin_decl_implicit (BUILT_IN_UNREACHABLE));
 
 	  if (dump_enabled_p ())
-            {
-	      location_t locus;
-	      if (edge->call_stmt)
-		locus = gimple_location (edge->call_stmt);
-	      else
-		locus = UNKNOWN_LOCATION;
-	      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus,
+	    {
+	      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, edge->call_stmt,
 			       "devirtualizing call in %s to %s\n",
 			       edge->caller->dump_name (),
 			       target->dump_name ());
@@ -238,13 +235,7 @@
 	  if (ipa_fn_summaries)
 	    ipa_update_overall_fn_summary (node);
 	  else if (edge->call_stmt)
-	    {
-	      edge->redirect_call_stmt_to_callee ();
-
-	      /* Call to __builtin_unreachable shouldn't be instrumented.  */
-	      if (!targets.length ())
-		gimple_call_set_with_bounds (edge->call_stmt, false);
-	    }
+	    edge->redirect_call_stmt_to_callee ();
 	}
     }
 }
@@ -460,20 +451,6 @@
 	      if (cnode->global.inlined_to)
 	        body_needed_for_clonning.add (cnode->decl);
 
-	      /* For instrumentation clones we always need original
-		 function node for proper LTO privatization.  */
-	      if (cnode->instrumentation_clone
-		  && cnode->definition)
-		{
-		  gcc_assert (cnode->instrumented_version || in_lto_p);
-		  if (cnode->instrumented_version)
-		    {
-		      enqueue_node (cnode->instrumented_version, &first,
-				    &reachable);
-		      reachable.add (cnode->instrumented_version);
-		    }
-		}
-
 	      /* For non-inline clones, force their origins to the boundary and ensure
 		 that body is not removed.  */
 	      while (cnode->clone_of)
@@ -622,7 +599,7 @@
 	    fprintf (file, " %s", vnode->dump_name ());
           vnext = next_variable (vnode);
 	  /* Signal removal to the debug machinery.  */
-	  if (! flag_wpa)
+	  if (! flag_wpa || flag_incremental_link == INCREMENTAL_LINK_LTO)
 	    {
 	      vnode->definition = false;
 	      (*debug_hooks->late_global_decl) (vnode->decl);
@@ -640,8 +617,8 @@
 	      changed = true;
 	    }
 	  /* Keep body if it may be useful for constant folding.  */
-	  if ((init = ctor_for_folding (vnode->decl)) == error_mark_node
-	      && !POINTER_BOUNDS_P (vnode->decl))
+	  if ((flag_wpa || flag_incremental_link == INCREMENTAL_LINK_LTO)
+	      || ((init = ctor_for_folding (vnode->decl)) == error_mark_node))
 	    vnode->remove_initializer ();
 	  else
 	    DECL_INITIAL (vnode->decl) = init;
@@ -666,10 +643,7 @@
 	&& !node->used_from_other_partition)
       {
 	if (!node->call_for_symbol_and_aliases
-	    (has_addr_references_p, NULL, true)
-	    && (!node->instrumentation_clone
-		|| !node->instrumented_version
-		|| !node->instrumented_version->address_taken))
+	    (has_addr_references_p, NULL, true))
 	  {
 	    if (file)
 	      fprintf (file, " %s", node->name ());
@@ -737,8 +711,6 @@
 	process_references (dyn_cast<varpool_node *> (ref->referring), written,
 			    address_taken, read, explicit_refs);
 	break;
-      case IPA_REF_CHKP:
-	gcc_unreachable ();
       }
 }
 
@@ -844,9 +816,8 @@
 }
 
 /* Generate and emit a static constructor or destructor.  WHICH must
-   be one of 'I' (for a constructor), 'D' (for a destructor), 'P'
-   (for chp static vars constructor) or 'B' (for chkp static bounds
-   constructor).  BODY is a STATEMENT_LIST containing GENERIC
+   be one of 'I' (for a constructor), 'D' (for a destructor).
+   BODY is a STATEMENT_LIST containing GENERIC
    statements.  PRIORITY is the initialization priority for this
    constructor or destructor.
 
@@ -909,20 +880,6 @@
       DECL_STATIC_CONSTRUCTOR (decl) = 1;
       decl_init_priority_insert (decl, priority);
       break;
-    case 'P':
-      DECL_STATIC_CONSTRUCTOR (decl) = 1;
-      DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("chkp ctor"),
-					  NULL,
-					  NULL_TREE);
-      decl_init_priority_insert (decl, priority);
-      break;
-    case 'B':
-      DECL_STATIC_CONSTRUCTOR (decl) = 1;
-      DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("bnd_legacy"),
-					  NULL,
-					  NULL_TREE);
-      decl_init_priority_insert (decl, priority);
-      break;
     case 'D':
       DECL_STATIC_DESTRUCTOR (decl) = 1;
       decl_fini_priority_insert (decl, priority);
@@ -940,9 +897,8 @@
 }
 
 /* Generate and emit a static constructor or destructor.  WHICH must
-   be one of 'I' (for a constructor), 'D' (for a destructor), 'P'
-   (for chkp static vars constructor) or 'B' (for chkp static bounds
-   constructor).  BODY is a STATEMENT_LIST containing GENERIC
+   be one of 'I' (for a constructor) or 'D' (for a destructor).
+   BODY is a STATEMENT_LIST containing GENERIC
    statements.  PRIORITY is the initialization priority for this
    constructor or destructor.  */