summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-09-12 16:52:24 +0000
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-09-12 16:52:24 +0000
commit6166bf807eff8344448ed811326c52090db8af0f (patch)
tree2b36936b9e996a342f6b6e571427691b2e5a58e5
parentda937817e9c49a9f20c719bc086b166505ac9196 (diff)
downloadgcc-6166bf807eff8344448ed811326c52090db8af0f.tar.gz
2014-09-12 Martin Jambor <mjambor@suse.cz>
PR ipa/61654 * cgraph.h (cgraph_analyze_function): Declare. * cgraphunit.c: (analyze_function): Remove forward declaration, rename to cgraph_analyze_function, made external. * cgraphclones.c (duplicate_thunk_for_node): Copy arguments of the new decl properly. Analyze the new thunk if it is expanded. gcc/testsuite/ * g++.dg/ipa/pr61654.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@215228 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cgraph.h1
-rw-r--r--gcc/cgraphclones.c21
-rw-r--r--gcc/cgraphunit.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr61654.C40
6 files changed, 81 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 79a67d8fff6..14a23d66280 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2014-09-12 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/61654
+ * cgraph.h (cgraph_analyze_function): Declare.
+ * cgraphunit.c: (analyze_function): Remove forward declaration,
+ rename to cgraph_analyze_function, made external.
+ * cgraphclones.c (duplicate_thunk_for_node): Copy arguments of the
+ new decl properly. Analyze the new thunk if it is expanded.
+
2014-09-11 H.J. Lu <hongjiu.lu@intel.com>
Backport from mainline
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 6c3be6d7508..0d13ebe9a21 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -797,6 +797,7 @@ void cgraph_unnest_node (struct cgraph_node *);
enum availability cgraph_function_body_availability (struct cgraph_node *);
void cgraph_add_new_function (tree, bool);
+void cgraph_analyze_function (struct cgraph_node *);
const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
cgraph_inline_failed_type_t cgraph_inline_failed_type (cgraph_inline_failed_t);
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 972ca0708c4..9ad76dd518b 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -334,6 +334,22 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
node->clone.args_to_skip,
false);
}
+
+ tree *link = &DECL_ARGUMENTS (new_decl);
+ int i = 0;
+ for (tree pd = DECL_ARGUMENTS (thunk->decl); pd; pd = DECL_CHAIN (pd), i++)
+ {
+ if (!node->clone.args_to_skip
+ || !bitmap_bit_p (node->clone.args_to_skip, i))
+ {
+ tree nd = copy_node (pd);
+ DECL_CONTEXT (nd) = new_decl;
+ *link = nd;
+ link = &DECL_CHAIN (nd);
+ }
+ }
+ *link = NULL_TREE;
+
gcc_checking_assert (!DECL_STRUCT_FUNCTION (new_decl));
gcc_checking_assert (!DECL_INITIAL (new_decl));
gcc_checking_assert (!DECL_RESULT (new_decl));
@@ -358,6 +374,11 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
cgraph_call_edge_duplication_hooks (thunk->callees, e);
if (!expand_thunk (new_thunk, false))
new_thunk->analyzed = true;
+ else
+ {
+ new_thunk->thunk.thunk_p = false;
+ cgraph_analyze_function (new_thunk);
+ }
cgraph_call_node_duplication_hooks (thunk, new_thunk);
return new_thunk;
}
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 8abdc5d3f8e..f4860552eca 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -219,7 +219,6 @@ cgraph_node_set cgraph_new_nodes;
static void expand_all_functions (void);
static void mark_functions_to_output (void);
static void expand_function (struct cgraph_node *);
-static void analyze_function (struct cgraph_node *);
static void handle_alias_pairs (void);
FILE *cgraph_dump_file;
@@ -331,7 +330,7 @@ cgraph_process_new_functions (void)
gimple_register_cfg_hooks ();
if (!node->analyzed)
- analyze_function (node);
+ cgraph_analyze_function (node);
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
if (cgraph_state == CGRAPH_STATE_IPA_SSA
&& !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
@@ -541,7 +540,7 @@ cgraph_add_new_function (tree fndecl, bool lowered)
if (lowered)
node->lowered = true;
node->definition = true;
- analyze_function (node);
+ cgraph_analyze_function (node);
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
gimple_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
@@ -598,8 +597,8 @@ output_asm_statements (void)
}
/* Analyze the function scheduled to be output. */
-static void
-analyze_function (struct cgraph_node *node)
+void
+cgraph_analyze_function (struct cgraph_node *node)
{
tree decl = node->decl;
location_t saved_loc = input_location;
@@ -1014,7 +1013,7 @@ analyze_functions (void)
}
if (!cnode->analyzed)
- analyze_function (cnode);
+ cgraph_analyze_function (cnode);
for (edge = cnode->callees; edge; edge = edge->next_callee)
if (edge->callee->definition)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3278af6502f..246aea53b0d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-12 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/61654
+ * g++.dg/ipa/pr61654.C: New test.
+
2014-09-11 Alan Lawrence <alan.lawrence@arm.com>
Backport r214953 from mainline
diff --git a/gcc/testsuite/g++.dg/ipa/pr61654.C b/gcc/testsuite/g++.dg/ipa/pr61654.C
new file mode 100644
index 00000000000..d07e4586bdb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr61654.C
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+/* The bug only presented itself on a 32 bit i386 but in theory it might also
+ pop up elsewhere and we do not want to put -m32 options to testcase
+ options. */
+
+struct A
+{
+ virtual int a (int, int = 0) = 0;
+ void b ();
+ void c ();
+ int d;
+};
+
+struct B : virtual A
+{
+ int a (int, int);
+ int e;
+};
+
+int f;
+
+void
+A::b ()
+{
+ a (0);
+}
+
+void
+A::c ()
+{
+ a (f);
+}
+
+int
+B::a (int, int)
+{
+ return e;
+}