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]

[PATCH] ICF is more strict about non-common function and var, attributes.


Hello.

Following patch is guard for special non-common function attributes that can be spotted by ICF
machinery. Tested on x86_64-linux.

Ready for trunk?
Thanks,
Martin
>From 13e8c55b6317bf4e2c21ef04305cb3a20ad51255 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Fri, 27 Feb 2015 21:49:46 +0100
Subject: [PATCH 1/4] ICF is more strict about non-common function and var
 attributes.

gcc/ChangeLog:

2015-02-28  Martin Liska  <mliska@suse.cz>
	    Jan Hubicka   <hubicka@ucw.cz>

	* ipa-icf-gimple.c (func_checker::compare_variable_decl):
	Validate variable alignment.
	* ipa-icf.c (sem_function::equals_private): Be more precise
	about non-common function attributes.
	(sem_variable::equals): Likewise.
---
 gcc/ipa-icf-gimple.c |  3 +++
 gcc/ipa-icf.c        | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 53d2c38..cbeb795 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -575,6 +575,9 @@ func_checker::compare_variable_decl (tree t1, tree t2)
   if (t1 == t2)
     return true;
 
+  if (DECL_ALIGN (t1) != DECL_ALIGN (t2))
+    return return_false_with_msg ("alignments are different");
+
   if (DECL_HARD_REGISTER (t1) != DECL_HARD_REGISTER (t2))
     return return_false_with_msg ("DECL_HARD_REGISTER are different");
 
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 5d50b6f..92133fc 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -619,6 +619,30 @@ sem_function::equals_private (sem_item *item,
     if (!compare_phi_node (bb_sorted[i]->bb, m_compared_func->bb_sorted[i]->bb))
       return return_false_with_msg ("PHI node comparison returns false");
 
+  /* Compare special function DECL attributes.  */
+  if (DECL_FUNCTION_PERSONALITY (decl) != DECL_FUNCTION_PERSONALITY (item->decl))
+    return return_false_with_msg ("function personalities are different");
+
+  if (DECL_DISREGARD_INLINE_LIMITS (decl) != DECL_DISREGARD_INLINE_LIMITS (item->decl))
+    return return_false_with_msg ("DECL_DISREGARD_INLINE_LIMITS are different");
+
+  if (DECL_DECLARED_INLINE_P (decl) != DECL_DECLARED_INLINE_P (item->decl))
+    return return_false_with_msg ("inline attributes are different");
+
+  if (DECL_IS_OPERATOR_NEW (decl) != DECL_IS_OPERATOR_NEW (item->decl))
+    return return_false_with_msg ("operator new flags are different");
+
+  if (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl)
+       != DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (item->decl))
+    return return_false_with_msg ("intrument function entry exit "
+				  "attributes are different");
+
+  if (DECL_NO_LIMIT_STACK (decl) != DECL_NO_LIMIT_STACK (item->decl))
+    return return_false_with_msg ("no stack limit attributes are different");
+
+  if (flags_from_decl_or_type (decl) != flags_from_decl_or_type (item->decl))
+    return return_false_with_msg ("decl_or_type flags are different");
+
   return result;
 }
 
@@ -1280,6 +1304,17 @@ sem_variable::equals (sem_item *item,
   if (!ctor || !v->ctor)
     return return_false_with_msg ("ctor is missing for semantic variable");
 
+  if (DECL_IN_CONSTANT_POOL (decl)
+      && (DECL_IN_CONSTANT_POOL (item->decl)
+	  || item->node->address_matters_p ()))
+    return return_false_with_msg ("constant pool");
+
+  if (DECL_IN_TEXT_SECTION (decl) != DECL_IN_TEXT_SECTION (item->decl))
+    return return_false_with_msg ("text section");
+
+  if (DECL_TLS_MODEL (decl) || DECL_TLS_MODEL (item->decl))
+    return return_false_with_msg ("TLS model");
+
   return sem_variable::equals (ctor, v->ctor);
 }
 
-- 
2.1.2



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