From 9929334ecabba70bce26430b39604247fd93a77a Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 10 Sep 2009 11:42:25 +0000 Subject: [PATCH] 2009-09-10 Richard Guenther PR middle-end/41257 * cgraphunit.c (cgraph_emit_thunks): Emit thunks only for reachable nodes. (cgraph_finalize_compilation_unit): Compute reachability before emitting thunks. Properly process aliases before possibly removing unreachable nodes. * g++.dg/torture/pr41257-2.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151592 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 9 +++++++++ gcc/cgraphunit.c | 27 +++++++++++++++++++-------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr41257-2.C | 16 ++++++++++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr41257-2.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e2d86d1f50..c85c486e6cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2009-09-10 Richard Guenther + PR middle-end/41257 + * cgraphunit.c (cgraph_emit_thunks): Emit thunks only for + reachable nodes. + (cgraph_finalize_compilation_unit): Compute reachability + before emitting thunks. Properly process aliases before + possibly removing unreachable nodes. + +2009-09-10 Richard Guenther + PR middle-end/41254 * tree.c (struct free_lang_data_d): Add worklist member. (find_decls_types_r): Push onto the worklist instead of recursing. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 0acc4723f07..5551c721762 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1036,7 +1036,8 @@ cgraph_emit_thunks (void) emitted, but we cannot know that until the inliner and other IPA passes have run (see the sequencing of the call to cgraph_mark_functions_to_output in cgraph_optimize). */ - if (!DECL_EXTERNAL (n->decl)) + if (n->reachable + && !DECL_EXTERNAL (n->decl)) lang_hooks.callgraph.emit_associated_thunks (n->decl); } } @@ -1047,35 +1048,45 @@ cgraph_emit_thunks (void) void cgraph_finalize_compilation_unit (void) { + timevar_push (TV_CGRAPH); + /* Do not skip analyzing the functions if there were errors, we miss diagnostics for following functions otherwise. */ /* Emit size functions we didn't inline. */ finalize_size_functions (); - /* Emit thunks, if needed. */ - if (lang_hooks.callgraph.emit_associated_thunks) - cgraph_emit_thunks (); - /* Call functions declared with the "constructor" or "destructor" attribute. */ cgraph_build_cdtor_fns (); + /* Mark alias targets necessary and emit diagnostics. */ + finish_aliases_1 (); + if (!quiet_flag) { fprintf (stderr, "\nAnalyzing compilation unit\n"); fflush (stderr); } + /* Gimplify and lower all functions, compute reachability and + remove unreachable nodes. */ + cgraph_analyze_functions (); + + /* Emit thunks for reachable nodes, if needed. */ + if (lang_hooks.callgraph.emit_associated_thunks) + cgraph_emit_thunks (); + /* Mark alias targets necessary and emit diagnostics. */ finish_aliases_1 (); - /* Gimplify and lower all functions. */ - timevar_push (TV_CGRAPH); + /* Gimplify and lower thunks. */ cgraph_analyze_functions (); - timevar_pop (TV_CGRAPH); + /* Finally drive the pass manager. */ cgraph_optimize (); + + timevar_pop (TV_CGRAPH); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e2266b6024..c3d6c52f9a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-09-10 Richard Guenther + + PR middle-end/41257 + * g++.dg/torture/pr41257-2.C: New testcase. + 2009-09-09 Paolo Carlini PR c++/28293 diff --git a/gcc/testsuite/g++.dg/torture/pr41257-2.C b/gcc/testsuite/g++.dg/torture/pr41257-2.C new file mode 100644 index 00000000000..230fa5dde49 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr41257-2.C @@ -0,0 +1,16 @@ +/* { dg-do link } */ + +struct A +{ + virtual ~A(); +}; + +struct B : virtual A +{ + virtual ~B() {} +}; + +int main() +{ + return 0; +} -- 2.11.4.GIT