Re: Improve pure/const propagation across interposable function with non-interposable aliases

2016-05-05 Thread Rainer Orth
Hi Jan,

>   * gcc.dg/ipa/pure-const-3.c: New testcase.

the testcase FAILs:

UNRESOLVED: gcc.dg/ipa/pure-const-3.c scan-ipa-dump pure-const "found to be 
const"

The log shows

gcc.dg/ipa/pure-const-3.c: dump file does not exist

The following patch fixes this.  Tested with the appropriate runtest
invocation on i386-pc-solaris2.12.  I guess this is obvious?

Rainer


2016-05-05  Rainer Orth  

* gcc.dg/ipa/pure-const-3.c: Scan local-pure-const1 dump.

# HG changeset patch
# Parent  d39b4a1eb735ab8dd6f6029ab882650de945f341
Fix gcc.dg/ipa/pure-const-3.c scan

diff --git a/gcc/testsuite/gcc.dg/ipa/pure-const-3.c b/gcc/testsuite/gcc.dg/ipa/pure-const-3.c
--- a/gcc/testsuite/gcc.dg/ipa/pure-const-3.c
+++ b/gcc/testsuite/gcc.dg/ipa/pure-const-3.c
@@ -21,4 +21,4 @@ main()
 __builtin_abort ();
   return 0;
 }
-/* { dg-final { scan-ipa-dump "found to be const" "pure-const"} } */
+/* { dg-final { scan-tree-dump "found to be const" "local-pure-const1"} } */

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Improve pure/const propagation across interposable function with non-interposable aliases

2016-05-04 Thread Jan Hubicka
Hi,
the API dealing with aliases is somewhow flawed by fact it makes difference 
between
the main symbol (defining function) and its aliases. There is nothing special 
about
the main symbol. This is fixed by this patch.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

Honza

* cgraph.c (cgraph_node::call_for_symbol_thunks_and_aliases):
Check availability on NODE, too.
* cgraph.h (symtab_node::call_for_symbol_and_aliases): Likewise.
(cgraph_node::call_for_symbol_and_aliases): Likewise.
(varpool_node::call_for_symbol_and_aliase): Likewise.
* ipa-pure-const.c (add_new_function): Analyze all bodies.
(propagate_pure_const): Propagate across interposable functions, too.
(skip_function_for_local_pure_const): Do not skip interposable bodies
with aliases.
(pass_local_pure_const::execute): Update.

* gcc.dg/ipa/pure-const-3.c: New testcase.
Index: cgraph.c
===
--- cgraph.c(revision 235839)
+++ cgraph.c(working copy)
@@ -2289,7 +2289,7 @@ cgraph_node::can_be_local_p (void)
 }
 
 /* Call callback on cgraph_node, thunks and aliases associated to cgraph_node.
-   When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
+   When INCLUDE_OVERWRITABLE is false, overwritable symbols are
skipped.  When EXCLUDE_VIRTUAL_THUNKS is true, virtual thunks are
skipped.  */
 bool
@@ -2301,9 +2301,14 @@ cgraph_node::call_for_symbol_thunks_and_
 {
   cgraph_edge *e;
   ipa_ref *ref;
+  enum availability avail = AVAIL_AVAILABLE;
 
-  if (callback (this, data))
-return true;
+  if (include_overwritable
+  || (avail = get_availability ()) > AVAIL_INTERPOSABLE)
+{
+  if (callback (this, data))
+return true;
+}
   FOR_EACH_ALIAS (this, ref)
 {
   cgraph_node *alias = dyn_cast  (ref->referring);
@@ -2314,7 +2319,7 @@ cgraph_node::call_for_symbol_thunks_and_
 exclude_virtual_thunks))
  return true;
 }
-  if (get_availability () <= AVAIL_INTERPOSABLE)
+  if (avail <= AVAIL_INTERPOSABLE)
 return false;
   for (e = callers; e; e = e->next_caller)
 if (e->caller->thunk.thunk_p
Index: cgraph.h
===
--- cgraph.h(revision 235837)
+++ cgraph.h(working copy)
@@ -3096,8 +3096,7 @@ symtab_node::get_availability (symtab_no
 }
 
 /* Call calback on symtab node and aliases associated to this node.
-   When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
-   skipped. */
+   When INCLUDE_OVERWRITABLE is false, overwritable symbols are skipped. */
 
 inline bool
 symtab_node::call_for_symbol_and_aliases (bool (*callback) (symtab_node *,
@@ -3105,15 +3104,19 @@ symtab_node::call_for_symbol_and_aliases
  void *data,
  bool include_overwritable)
 {
-  if (callback (this, data))
-return true;
+  if (include_overwritable
+  || get_availability () > AVAIL_INTERPOSABLE)
+{
+  if (callback (this, data))
+return true;
+}
   if (has_aliases_p ())
 return call_for_symbol_and_aliases_1 (callback, data, 
include_overwritable);
   return false;
 }
 
 /* Call callback on function and aliases associated to the function.
-   When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
+   When INCLUDE_OVERWRITABLE is false, overwritable symbols are
skipped.  */
 
 inline bool
@@ -3122,15 +3125,19 @@ cgraph_node::call_for_symbol_and_aliases
  void *data,
  bool include_overwritable)
 {
-  if (callback (this, data))
-return true;
+  if (include_overwritable
+  || get_availability () > AVAIL_INTERPOSABLE)
+{
+  if (callback (this, data))
+return true;
+}
   if (has_aliases_p ())
 return call_for_symbol_and_aliases_1 (callback, data, 
include_overwritable);
   return false;
 }
 
 /* Call calback on varpool symbol and aliases associated to varpool symbol.
-   When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
+   When INCLUDE_OVERWRITABLE is false, overwritable symbols are
skipped. */
 
 inline bool
@@ -3139,8 +3146,12 @@ varpool_node::call_for_symbol_and_aliase
   void *data,
   bool include_overwritable)
 {
-  if (callback (this, data))
-return true;
+  if (include_overwritable
+  || get_availability () > AVAIL_INTERPOSABLE)
+{
+  if (callback (this, data))
+return true;
+}
   if (has_aliases_p ())
 return call_for_symbol_and_aliases_1 (callback, data, 
include_overwritable);
   return false;
Index: ipa-pure-const.c
===
--- ipa-pure-const.c(revision