diff mbox series

Simplify comparison of attrs in IPA ICF.

Message ID ea992a65-f9ba-94e2-618c-8ea485af1bbb@suse.cz
State New
Headers show
Series Simplify comparison of attrs in IPA ICF. | expand

Commit Message

Martin Liška Oct. 11, 2018, 11:48 a.m. UTC
Hi.

This is simplification in ICF where we can use attribute comparison
function from attrs.c instead of implementing our own.

Patch survives tests on x86_64-linux-gnu.
Ready for trunk?
Thanks,
Martin

gcc/ChangeLog:

2018-10-10  Martin Liska  <mliska@suse.cz>

	* ipa-icf.c (sem_item::compare_attributes): Remove.
	(sem_item::compare_referenced_symbol_properties): Use
	attribute_list_equal instead.
	(sem_function::equals_wpa): Likewise.
	* ipa-icf.h: Remove compare_attributes.
---
 gcc/ipa-icf.c | 59 ++++-----------------------------------------------
 gcc/ipa-icf.h |  3 ---
 2 files changed, 4 insertions(+), 58 deletions(-)

Comments

Jeff Law Oct. 12, 2018, 2:58 a.m. UTC | #1
On 10/11/18 5:48 AM, Martin Liška wrote:
> Hi.
> 
> This is simplification in ICF where we can use attribute comparison
> function from attrs.c instead of implementing our own.
> 
> Patch survives tests on x86_64-linux-gnu.
> Ready for trunk?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2018-10-10  Martin Liska  <mliska@suse.cz>
> 
> 	* ipa-icf.c (sem_item::compare_attributes): Remove.
> 	(sem_item::compare_referenced_symbol_properties): Use
> 	attribute_list_equal instead.
> 	(sem_function::equals_wpa): Likewise.
> 	* ipa-icf.h: Remove compare_attributes.
OK
jeff
diff mbox series

Patch

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 3c54f8d4b6d..ff313197f64 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -305,57 +305,6 @@  sem_function::get_hash (void)
   return m_hash;
 }
 
-/* Return ture if A1 and A2 represent equivalent function attribute lists.
-   Based on comp_type_attributes.  */
-
-bool
-sem_item::compare_attributes (const_tree a1, const_tree a2)
-{
-  const_tree a;
-  if (a1 == a2)
-    return true;
-  for (a = a1; a != NULL_TREE; a = TREE_CHAIN (a))
-    {
-      const struct attribute_spec *as;
-      const_tree attr;
-
-      as = lookup_attribute_spec (get_attribute_name (a));
-      /* TODO: We can introduce as->affects_decl_identity
-	 and as->affects_decl_reference_identity if attribute mismatch
-	 gets a common reason to give up on merging.  It may not be worth
-	 the effort.
-	 For example returns_nonnull affects only references, while
-	 optimize attribute can be ignored because it is already lowered
-	 into flags representation and compared separately.  */
-      if (!as)
-        continue;
-
-      attr = lookup_attribute (as->name, CONST_CAST_TREE (a2));
-      if (!attr || !attribute_value_equal (a, attr))
-        break;
-    }
-  if (!a)
-    {
-      for (a = a2; a != NULL_TREE; a = TREE_CHAIN (a))
-	{
-	  const struct attribute_spec *as;
-
-	  as = lookup_attribute_spec (get_attribute_name (a));
-	  if (!as)
-	    continue;
-
-	  if (!lookup_attribute (as->name, CONST_CAST_TREE (a1)))
-	    break;
-	  /* We don't need to compare trees again, as we did this
-	     already in first loop.  */
-	}
-      if (!a)
-        return true;
-    }
-  /* TODO: As in comp_type_attributes we may want to introduce target hook.  */
-  return false;
-}
-
 /* Compare properties of symbols N1 and N2 that does not affect semantics of
    symbol itself but affects semantics of its references from USED_BY (which
    may be NULL if it is unknown).  If comparsion is false, symbols
@@ -429,8 +378,8 @@  sem_item::compare_referenced_symbol_properties (symtab_node *used_by,
 	 variables just compare attributes for references - the codegen
 	 for constructors is affected only by those attributes that we lower
 	 to explicit representation (such as DECL_ALIGN or DECL_SECTION).  */
-      if (!compare_attributes (DECL_ATTRIBUTES (n1->decl),
-			       DECL_ATTRIBUTES (n2->decl)))
+      if (!attribute_list_equal (DECL_ATTRIBUTES (n1->decl),
+				 DECL_ATTRIBUTES (n2->decl)))
 	return return_false_with_msg ("different var decl attributes");
       if (comp_type_attributes (TREE_TYPE (n1->decl),
 				TREE_TYPE (n2->decl)) != 1)
@@ -716,8 +665,8 @@  sem_function::equals_wpa (sem_item *item,
   if (comp_type_attributes (TREE_TYPE (decl),
 			    TREE_TYPE (item->decl)) != 1)
     return return_false_with_msg ("different type attributes");
-  if (!compare_attributes (DECL_ATTRIBUTES (decl),
-			   DECL_ATTRIBUTES (item->decl)))
+  if (!attribute_list_equal (DECL_ATTRIBUTES (decl),
+			     DECL_ATTRIBUTES (item->decl)))
     return return_false_with_msg ("different decl attributes");
 
   /* The type of THIS pointer type memory location for
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index a64b3852efb..0359653d2f8 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -255,9 +255,6 @@  protected:
 					            symtab_node *n2,
 					            bool address);
 
-  /* Compare two attribute lists.  */
-  static bool compare_attributes (const_tree list1, const_tree list2);
-
   /* Hash properties compared by compare_referenced_symbol_properties.  */
   void hash_referenced_symbol_properties (symtab_node *ref,
 					  inchash::hash &hstate,