From 7e49f1a172817c56fbf317a3553b3fe715b7896b Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 5 Jul 2011 18:43:04 +0000 Subject: [PATCH] PR tree-optimization/49618 * tree-eh.c (tree_could_trap_p) : For DECL_WEAK t recurse on the decl. : For DECL_WEAK decls return true if expr isn't known to be defined in current TU or some other LTO partition. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175884 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 9 +++++++++ gcc/tree-eh.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 184ea83bf11..d4d1c48036f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2011-07-05 Jakub Jelinek + + PR tree-optimization/49618 + * tree-eh.c (tree_could_trap_p) : For DECL_WEAK + t recurse on the decl. + : For DECL_WEAK decls + return true if expr isn't known to be defined in current + TU or some other LTO partition. + 2011-07-05 Michael Meissner * params.def (PARAM_CASE_VALUES_THRESHOLD): New parameter to diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 5831d34826c..f10d72d1d68 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2449,8 +2449,42 @@ tree_could_trap_p (tree expr) case CALL_EXPR: t = get_callee_fndecl (expr); /* Assume that calls to weak functions may trap. */ - if (!t || !DECL_P (t) || DECL_WEAK (t)) + if (!t || !DECL_P (t)) return true; + if (DECL_WEAK (t)) + return tree_could_trap_p (t); + return false; + + case FUNCTION_DECL: + /* Assume that accesses to weak functions may trap, unless we know + they are certainly defined in current TU or in some other + LTO partition. */ + if (DECL_WEAK (expr)) + { + struct cgraph_node *node; + if (!DECL_EXTERNAL (expr)) + return false; + node = cgraph_function_node (cgraph_get_node (expr), NULL); + if (node && node->in_other_partition) + return false; + return true; + } + return false; + + case VAR_DECL: + /* Assume that accesses to weak vars may trap, unless we know + they are certainly defined in current TU or in some other + LTO partition. */ + if (DECL_WEAK (expr)) + { + struct varpool_node *node; + if (!DECL_EXTERNAL (expr)) + return false; + node = varpool_variable_node (varpool_get_node (expr), NULL); + if (node && node->in_other_partition) + return false; + return true; + } return false; default: -- 2.11.0