aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-01-27 11:16:43 +0100
committerJakub Jelinek <jakub@redhat.com>2023-01-27 11:16:43 +0100
commitbd246ac68239d944b01c213c39d6e212362c1b40 (patch)
treeaf4d0a9c45d7a7ec36a36f48cbbe2d1654c972ed /gcc/cgraph.cc
parent9b9a1ac14cdca6eef8dbcab0d33f3c03774a6c77 (diff)
downloadgcc-bd246ac68239d944b01c213c39d6e212362c1b40.zip
gcc-bd246ac68239d944b01c213c39d6e212362c1b40.tar.gz
gcc-bd246ac68239d944b01c213c39d6e212362c1b40.tar.bz2
cgraph: Adjust verify_corresponds_to_fndecl [PR106061]
IPA passes redirect some calls in what it determines to be unreachable code to builtin_decl_unreachable. But that function returns sometimes builtin_decl_explicit (BUILT_IN_UNREACHABLE) (which was what GCC 12 and earlier did always), or builtin_decl_explicit (BUILT_IN_TRAP) (e.g. for -funreachable-traps, -O0, -Og). Now the cgraph verification code has a code to verify cgraph edges and has there an exception for these redirections to BUILT_IN_UNREACHABLE, but doesn't have for BUILT_IN_TRAP, so e.g. the following testcase ICEs during that verification. The following patch just adds BUILT_IN_TRAP to those exceptions. 2023-01-27 Jakub Jelinek <jakub@redhat.com> PR ipa/106061 * cgraph.cc (cgraph_edge::verify_corresponds_to_fndecl): Allow redirection of calls to __builtin_trap in addition to redirection to __builtin_unreachable. * gcc.dg/pr106061.c: New test.
Diffstat (limited to 'gcc/cgraph.cc')
-rw-r--r--gcc/cgraph.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 5f72ace..b810237 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -3248,9 +3248,11 @@ cgraph_edge::verify_corresponds_to_fndecl (tree decl)
node = node->ultimate_alias_target ();
/* Optimizers can redirect unreachable calls or calls triggering undefined
- behavior to builtin_unreachable. */
+ behavior to __builtin_unreachable or __builtin_trap. */
- if (fndecl_built_in_p (callee->decl, BUILT_IN_UNREACHABLE))
+ if (fndecl_built_in_p (callee->decl, BUILT_IN_NORMAL)
+ && (DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE
+ || DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_TRAP))
return false;
if (callee->former_clone_of != node->decl