This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH PR 43061: check DECL_PRESERVE_P in the midend


On Feb 19, 2010, at 1:43 AM, Richard Guenther wrote:
Your first guess is certainly safe, but I'd like to remove the
explicit attribute checks.  Grepping shows that only
config/sol2.c and config/sol2-c.c need adjustment.

Thus, please adjust that and remove the superfluous checks.

Ok, done.


The patch is ok with that change.

And below is the updated version that was checked in. Thanks for the review.


Index: objc/objc-act.c
===================================================================
--- objc/objc-act.c (revision 156906)
+++ objc/objc-act.c (working copy)
@@ -1527,11 +1527,6 @@
/* We reserve the right for the runtime to use/modify these variables
in ways that are opaque to us. */
DECL_PRESERVE_P (var) = 1;
- /* ipa*.c/cgraphunit.c use lookup attribute rather than testing
- DECL_PRESERVE_P. Once they switch to testing DECL_PRESERVE_P,
- this can be removed. */
- DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("used"), NULL,
- DECL_ATTRIBUTES (var)) ;
}


/* Find the decl for the constant string class reference. This is only
Index: ipa-reference.c
===================================================================
--- ipa-reference.c (revision 156906)
+++ ipa-reference.c (working copy)
@@ -306,7 +306,7 @@
{
/* If the variable has the "used" attribute, treat it as if it had a
been touched by the devil. */
- if (lookup_attribute ("used", DECL_ATTRIBUTES (t)))
+ if (DECL_PRESERVE_P (t))
return false;


   /* Do not want to do anything with volatile except mark any
Index: cgraphunit.c
===================================================================
--- cgraphunit.c        (revision 156906)
+++ cgraphunit.c        (working copy)
@@ -885,7 +885,7 @@
   for (node = cgraph_nodes; node != first; node = node->next)
     {
       tree decl = node->decl;
-      if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
+      if (DECL_PRESERVE_P (decl))
        {
          mark_decl_referenced (decl);
          if (node->local.finalized)
@@ -904,7 +904,7 @@
   for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next)
     {
       tree decl = vnode->decl;
-      if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
+      if (DECL_PRESERVE_P (decl))
        {
          mark_decl_referenced (decl);
          vnode->force_output = true;
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 156906)
+++ ChangeLog   (working copy)
@@ -1,3 +1,16 @@
+2010-02-19  Mike Stump  <mikestump@comcast.net>
+
+       PR objc/43061
+       * cgraphunit.c (process_function_and_variable_attributes): Check
+       DECL_PRESERVE_P instead of looking up attribute "used".
+       * ipa-pure-const.c (check_decl): Likewise.
+       * ipa-reference.c (has_proper_scope_for_analysis): Likewise.
+       * ipa-type-escape.c (has_proper_scope_for_analysis): Likewise.
+       * config/sol2.c (solaris_insert_attributes): Set DECL_PRESERVE_P
+       instead of attribute "used".
+       * config/sol2-c.c (solaris_pragma_init): Likewise.
+       (solaris_pragma_fini): Likewise.
+
 2010-02-19  Jakub Jelinek  <jakub@redhat.com>

* ipa-struct-reorg.c (make_field_acc_node, gen_cluster, peel_field):
Index: ipa-pure-const.c
===================================================================
--- ipa-pure-const.c (revision 156906)
+++ ipa-pure-const.c (working copy)
@@ -159,7 +159,7 @@


   /* If the variable has the "used" attribute, treat it as if it had a
      been touched by the devil.  */
-  if (lookup_attribute ("used", DECL_ATTRIBUTES (t)))
+  if (DECL_PRESERVE_P (t))
     {
       local->pure_const_state = IPA_NEITHER;
       if (dump_file)
Index: ipa-type-escape.c
===================================================================
--- ipa-type-escape.c   (revision 156906)
+++ ipa-type-escape.c   (working copy)
@@ -1072,7 +1072,7 @@
   tree type = get_canon_type (TREE_TYPE (t), false, false);
   if (!type) return;

- if (lookup_attribute ("used", DECL_ATTRIBUTES (t)))
+ if (DECL_PRESERVE_P (t))
{
mark_interesting_type (type, FULL_ESCAPE);
return;
Index: config/sol2.c
===================================================================
--- config/sol2.c (revision 156906)
+++ config/sol2.c (working copy)
@@ -70,8 +70,8 @@
{
*attributes = tree_cons (get_identifier ("init"), NULL,
*attributes);
- *attributes = tree_cons (get_identifier ("used"), NULL,
- *attributes);
+ TREE_USED (decl) = 1;
+ DECL_PRESERVE_P (decl) = 1;
next = TREE_CHAIN (*x);
ggc_free (*x);
*x = next;
@@ -87,8 +87,8 @@
{
*attributes = tree_cons (get_identifier ("fini"), NULL,
*attributes);
- *attributes = tree_cons (get_identifier ("used"), NULL,
- *attributes);
+ TREE_USED (decl) = 1;
+ DECL_PRESERVE_P (decl) = 1;
next = TREE_CHAIN (*x);
ggc_free (*x);
*x = next;
Index: config/sol2-c.c
===================================================================
--- config/sol2-c.c (revision 156906)
+++ config/sol2-c.c (working copy)
@@ -170,9 +170,10 @@
tree decl = identifier_global_value (t);
if (decl && DECL_P (decl))
{
- tree init_list = build_tree_list (get_identifier ("init"),
- NULL);
- tree attrs = tree_cons (get_identifier ("used"), NULL, init_list);
+ tree attrs = build_tree_list (get_identifier ("init"),
+ NULL);
+ TREE_USED (decl) = 1;
+ DECL_PRESERVE_P (decl) = 1;
decl_attributes (&decl, attrs, 0);
}
else
@@ -228,9 +229,10 @@
tree decl = identifier_global_value (t);
if (decl && DECL_P (decl))
{
- tree fini_list = build_tree_list (get_identifier ("fini"),
- NULL);
- tree attrs = tree_cons (get_identifier ("used"), NULL, fini_list);
+ tree attrs = build_tree_list (get_identifier ("fini"),
+ NULL);
+ TREE_USED (decl) = 1;
+ DECL_PRESERVE_P (decl) = 1;
decl_attributes (&decl, attrs, 0);
}
else




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]