aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-03-17 13:14:49 +0100
committerRichard Biener <rguenther@suse.de>2023-04-27 14:59:01 +0200
commit65369ab62cee68eb7f6ef65e3d12d1969a9e20ee (patch)
treef4d1ab60b57cefc0d225e852668740c07b27a2bf /gcc/builtins.cc
parentb5f04a4db59f61f416f23801902cbf4d0f50dc15 (diff)
downloadgcc-upstream-65369ab62cee68eb7f6ef65e3d12d1969a9e20ee.tar.gz
tree-optimization/109170 - bogus use-after-free with __builtin_expect
The following generalizes the range-op for __builtin_expect by using the fnspec machinery. PR tree-optimization/109170 * gimple-range-op.cc (gimple_range_op_handler::maybe_builtin_call): Handle __builtin_expect and similar via cfn_pass_through_arg1 and inspecting the calls fnspec. * builtins.cc (builtin_fnspec): Handle BUILT_IN_EXPECT and BUILT_IN_EXPECT_WITH_PROBABILITY.
Diffstat (limited to 'gcc/builtins.cc')
-rw-r--r--gcc/builtins.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 878596c240a..bd07873a80e 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -11718,6 +11718,8 @@ builtin_fnspec (tree callee)
case BUILT_IN_RETURN_ADDRESS:
return ".c";
case BUILT_IN_ASSUME_ALIGNED:
+ case BUILT_IN_EXPECT:
+ case BUILT_IN_EXPECT_WITH_PROBABILITY:
return "1cX ";
/* But posix_memalign stores a pointer into the memory pointed to
by its first argument. */