Re: [PATCH 2/4] Enhancement of call graph API

2014-06-02 Thread Martin Liška


On 05/30/2014 06:42 PM, Jeff Law wrote:

On 05/30/14 00:47, Martin Liška wrote:

Hello,
this patch enhances callgraph API to enable more precise control of
expand_thunk; another function becomes global.

Bootstrapped and tested on x86_64-linux.
OK for trunk?

Thanks,
Martin

2014-05-29  Martin Liska  mli...@suse.cz

 * cgraph.h (expand_thunk): New argument added.
 (address_taken_from_non_vtable_p): New global function.
 * ipa-visibility.c (address_taken_from_non_vtable_p): Likewise.
 * cgraphclones.c (duplicate_thunk_for_node): Argument added to call.
 * cgraphunit.c (analyze_function): Likewise.
 (assemble_thunks_and_aliases): Argument added to call.
 (expand_thunk): New argument forces to produce GIMPLE thunk.

Only concern here is the location of the prototype for 
address_taken_from_non_vtable_p.  Though I guess other things form 
ipa-visibility.c are prototyped in cgraph.h.

Can you put the prototype here in cgraph.h:


/* In ipa-visibility.c */
bool cgraph_local_node_p (struct cgraph_node *);

Otherwise OK.

Real curious to see the meat of the optimization now :-)


Hello,
   thanks too. It was really a wrong place for the declaration.

Yeah, the optimization will be juicy :)

Martin



jeff





[PATCH 2/4] Enhancement of call graph API

2014-05-30 Thread Martin Liška

Hello,
   this patch enhances callgraph API to enable more precise control of 
expand_thunk; another function becomes global.

Bootstrapped and tested on x86_64-linux.
OK for trunk?

Thanks,
Martin

2014-05-29  Martin Liska  mli...@suse.cz

* cgraph.h (expand_thunk): New argument added.
(address_taken_from_non_vtable_p): New global function.
* ipa-visibility.c (address_taken_from_non_vtable_p): Likewise.
* cgraphclones.c (duplicate_thunk_for_node): Argument added to call.
* cgraphunit.c (analyze_function): Likewise.
(assemble_thunks_and_aliases): Argument added to call.
(expand_thunk): New argument forces to produce GIMPLE thunk.

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index e5aa833..bfd3d91 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -911,7 +911,7 @@ void fixup_same_cpp_alias_visibility (symtab_node *, 
symtab_node *target, tree);
 IN_SSA is true if the gimple is in SSA.  */
 basic_block init_lowered_empty_function (tree, bool);
 void cgraph_reset_node (struct cgraph_node *);
-bool expand_thunk (struct cgraph_node *, bool);
+bool expand_thunk (struct cgraph_node *, bool, bool);
 
 /* In cgraphclones.c  */
 
@@ -956,6 +956,7 @@ void ipa_record_stmt_references (struct cgraph_node *, gimple);
 
 /* In ipa.c  */

 bool symtab_remove_unreachable_nodes (bool, FILE *);
+bool address_taken_from_non_vtable_p (symtab_node *node);
 cgraph_node_set cgraph_node_set_new (void);
 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
   struct cgraph_node *);
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 4387b99..75eba6d 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -353,7 +353,7 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node 
*node,
  CGRAPH_FREQ_BASE);
   e-call_stmt_cannot_inline_p = true;
   cgraph_call_edge_duplication_hooks (thunk-callees, e);
-  if (!expand_thunk (new_thunk, false))
+  if (!expand_thunk (new_thunk, false, false))
 new_thunk-analyzed = true;
   cgraph_call_node_duplication_hooks (thunk, new_thunk);
   return new_thunk;
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index e19b0a2..55bf378 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -610,7 +610,7 @@ analyze_function (struct cgraph_node *node)
 {
   cgraph_create_edge (node, cgraph_get_node (node-thunk.alias),
  NULL, 0, CGRAPH_FREQ_BASE);
-  if (!expand_thunk (node, false))
+  if (!expand_thunk (node, false, false))
{
  node-thunk.alias = NULL;
  node-analyzed = true;
@@ -1466,11 +1466,13 @@ thunk_adjust (gimple_stmt_iterator * bsi,
 }
 
 /* Expand thunk NODE to gimple if possible.

+   When FORCE_GIMPLE_THUNK is true, gimple thunk is created and
+   no assembler is produced.
When OUTPUT_ASM_THUNK is true, also produce assembler for
thunks that are not lowered.  */
 
 bool

-expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
+expand_thunk (struct cgraph_node *node, bool output_asm_thunks, bool 
force_gimple_thunk)
 {
   bool this_adjusting = node-thunk.this_adjusting;
   HOST_WIDE_INT fixed_offset = node-thunk.fixed_offset;
@@ -1481,7 +1483,7 @@ expand_thunk (struct cgraph_node *node, bool 
output_asm_thunks)
   tree a;
 
 
-  if (this_adjusting

+  if (!force_gimple_thunk  this_adjusting
targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,
  virtual_value, alias))
 {
@@ -1719,7 +1721,7 @@ assemble_thunks_and_aliases (struct cgraph_node *node)
 
 	e = e-next_caller;

assemble_thunks_and_aliases (thunk);
-expand_thunk (thunk, true);
+expand_thunk (thunk, true, false);
   }
 else
   e = e-next_caller;
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index dc22b2e..7886722 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -115,7 +115,7 @@ cgraph_local_node_p (struct cgraph_node *node)
 }
 
 /* Return true when there is a reference to node and it is not vtable.  */

-static bool
+bool
 address_taken_from_non_vtable_p (symtab_node *node)
 {
   int i;
--
1.8.4.5




Re: [PATCH 2/4] Enhancement of call graph API

2014-05-30 Thread Jeff Law

On 05/30/14 00:47, Martin Liška wrote:

Hello,
this patch enhances callgraph API to enable more precise control of
expand_thunk; another function becomes global.

Bootstrapped and tested on x86_64-linux.
OK for trunk?

Thanks,
Martin

2014-05-29  Martin Liska  mli...@suse.cz

 * cgraph.h (expand_thunk): New argument added.
 (address_taken_from_non_vtable_p): New global function.
 * ipa-visibility.c (address_taken_from_non_vtable_p): Likewise.
 * cgraphclones.c (duplicate_thunk_for_node): Argument added to call.
 * cgraphunit.c (analyze_function): Likewise.
 (assemble_thunks_and_aliases): Argument added to call.
 (expand_thunk): New argument forces to produce GIMPLE thunk.
Only concern here is the location of the prototype for 
address_taken_from_non_vtable_p.  Though I guess other things form 
ipa-visibility.c are prototyped in cgraph.h.


Can you put the prototype here in cgraph.h:


/* In ipa-visibility.c */
bool cgraph_local_node_p (struct cgraph_node *);

Otherwise OK.

Real curious to see the meat of the optimization now :-)

jeff