This adjusts gimple_could_trap_p to not consider internal function calls to trap compared to indirect calls or calls to weak functions.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-07-12 Richard Biener <rguent...@suse.de> PR middle-end/101423 * gimple.c (gimple_could_trap_p_1): Internal function calls do not trap. * tree-eh.c (tree_could_trap_p): Likewise. --- gcc/gimple.c | 4 +++- gcc/tree-eh.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/gimple.c b/gcc/gimple.c index 60a90667e4b..cc464547e34 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -2149,8 +2149,10 @@ gimple_could_trap_p_1 (gimple *s, bool include_mem, bool include_stores) return gimple_asm_volatile_p (as_a <gasm *> (s)); case GIMPLE_CALL: + if (gimple_call_internal_p (s)) + return false; t = gimple_call_fndecl (s); - /* Assume that calls to weak functions may trap. */ + /* Assume that indirect and calls to weak functions may trap. */ if (!t || !DECL_P (t) || DECL_WEAK (t)) return true; return false; diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 601285c401c..57ce8f04a43 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2723,8 +2723,11 @@ tree_could_trap_p (tree expr) return TREE_THIS_VOLATILE (expr); case CALL_EXPR: + /* Internal function calls do not trap. */ + if (CALL_EXPR_FN (expr) == NULL_TREE) + return false; t = get_callee_fndecl (expr); - /* Assume that calls to weak functions may trap. */ + /* Assume that indirect and calls to weak functions may trap. */ if (!t || !DECL_P (t)) return true; if (DECL_WEAK (t)) -- 2.26.2