]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/101423 - internal calls do not trap
authorRichard Biener <rguenther@suse.de>
Mon, 12 Jul 2021 08:26:25 +0000 (10:26 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 13 Jul 2021 09:46:25 +0000 (11:46 +0200)
This adjusts gimple_could_trap_p to not consider internal function
calls to trap compared to indirect calls or calls to weak functions.

2021-07-12  Richard Biener  <rguenther@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.

(cherry picked from commit 123d0a597beb6d9865f808bf15b0d67f2a8fd5b2)

gcc/gimple.c
gcc/tree-eh.c

index 87864f3d0dd4fc892c5d9bde7f3e9cad4523ec3c..c6f7c2d49002a64b133f6c8d1f9d14e7ab84f60f 100644 (file)
@@ -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;
index a68778b980947b92bafcf08845bcbcc626331f70..08c973254840d969e6a44e21ffaa4f6bc9c2a17d 100644 (file)
@@ -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))