From f9bdfd5044849aebd8a5212e14ad83fb3cff8b2c Mon Sep 17 00:00:00 2001 From: davidxl Date: Tue, 17 Jun 2014 22:08:03 +0000 Subject: [PATCH] port 211605 from v17 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/google@211749 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc-4_9/gcc/cgraphclones.c | 7 ++++++- gcc-4_9/gcc/l-ipo.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc-4_9/gcc/cgraphclones.c b/gcc-4_9/gcc/cgraphclones.c index 5ed0184ef08..afd55c31d60 100644 --- a/gcc-4_9/gcc/cgraphclones.c +++ b/gcc-4_9/gcc/cgraphclones.c @@ -101,6 +101,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-utils.h" #include "lto-streamer.h" #include "except.h" +#include "l-ipo.h" /* Create clone of E in the node N represented by CALL_EXPR the callgraph. */ struct cgraph_edge * @@ -128,7 +129,11 @@ cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n, via cgraph_resolve_speculation and not here. */ && !e->speculative) { - struct cgraph_node *callee = cgraph_get_node (decl); + struct cgraph_node *callee; + if (L_IPO_COMP_MODE && cgraph_pre_profiling_inlining_done) + callee = cgraph_lipo_get_resolved_node (decl); + else + callee = cgraph_get_node (decl); gcc_checking_assert (callee); new_edge = cgraph_create_edge (n, callee, call_stmt, count, freq); } diff --git a/gcc-4_9/gcc/l-ipo.c b/gcc-4_9/gcc/l-ipo.c index 2a7734336a2..5a22ff83cd1 100644 --- a/gcc-4_9/gcc/l-ipo.c +++ b/gcc-4_9/gcc/l-ipo.c @@ -1553,6 +1553,18 @@ resolve_cgraph_node (struct cgraph_sym **slot, struct cgraph_node *node) gcc_assert (decl1_defined); add_define_module (*slot, decl2); + /* Pick the node that cannot be removed, to avoid a situation + where we remove the resolved node and later try to access + it for the remaining non-removable copy. E.g. one may be + extern and the other weak, only the extern copy can be removed. */ + if (cgraph_can_remove_if_no_direct_calls_and_refs_p ((*slot)->rep_node) + && !cgraph_can_remove_if_no_direct_calls_and_refs_p (node)) + { + (*slot)->rep_node = node; + (*slot)->rep_decl = decl2; + return; + } + has_prof1 = has_profile_info (decl1); if (has_prof1) return; -- 2.11.4.GIT