diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-04-20 13:02:52 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-04-20 13:02:52 +0200 |
commit | 1edcb2ea0eb29f1a85cd9ba7bb933c4a260cba44 (patch) | |
tree | 34426eb7fc8b51b2ced92257bd5a2c5e1c8abfae /gcc/tree.h | |
parent | 705b0d2b62318b3935214f08a1cf023b1117acb8 (diff) | |
download | gcc-1edcb2ea0eb29f1a85cd9ba7bb933c4a260cba44.zip gcc-1edcb2ea0eb29f1a85cd9ba7bb933c4a260cba44.tar.gz gcc-1edcb2ea0eb29f1a85cd9ba7bb933c4a260cba44.tar.bz2 |
tree: Add 3+ argument fndecl_built_in_p
On Wed, Feb 22, 2023 at 09:52:06AM +0000, Richard Biener wrote:
> > The following testcase ICEs because we still have some spots that
> > treat BUILT_IN_UNREACHABLE specially but not BUILT_IN_UNREACHABLE_TRAP
> > the same.
This patch uses (fndecl_built_in_p (node, BUILT_IN_UNREACHABLE)
|| fndecl_built_in_p (node, BUILT_IN_UNREACHABLE_TRAP))
a lot and from grepping around, we do something like that in lots of
other places, or in some spots instead as
(fndecl_built_in_p (node, BUILT_IN_NORMAL)
&& (DECL_FUNCTION_CODE (node) == BUILT_IN_WHATEVER1
|| DECL_FUNCTION_CODE (node) == BUILT_IN_WHATEVER2))
The following patch adds an overload for this case, so we can write
it in a shorter way, using C++11 argument packs so that it supports
as many codes as one needs.
2023-04-20 Jakub Jelinek <jakub@redhat.com>
Jonathan Wakely <jwakely@redhat.com>
* tree.h (built_in_function_equal_p): New helper function.
(fndecl_built_in_p): Turn into variadic template to support
1 or more built_in_function arguments.
* builtins.cc (fold_builtin_expect): Use 3 argument fndecl_built_in_p.
* gimplify.cc (goa_stabilize_expr): Likewise.
* cgraphclones.cc (cgraph_node::create_clone): Likewise.
* ipa-fnsummary.cc (compute_fn_summary): Likewise.
* omp-low.cc (setjmp_or_longjmp_p): Likewise.
* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee,
cgraph_update_edges_for_call_stmt_node,
cgraph_edge::verify_corresponds_to_fndecl,
cgraph_node::verify_node): Likewise.
* tree-stdarg.cc (optimize_va_list_gpr_fpr_size): Likewise.
* gimple-ssa-warn-access.cc (matching_alloc_calls_p): Likewise.
* ipa-prop.cc (try_make_edge_direct_virtual_call): Likewise.
Diffstat (limited to 'gcc/tree.h')
-rw-r--r-- | gcc/tree.h | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -6585,6 +6585,24 @@ type_has_mode_precision_p (const_tree t) return known_eq (TYPE_PRECISION (t), GET_MODE_PRECISION (TYPE_MODE (t))); } +/* Helper functions for fndecl_built_in_p. */ + +inline bool +built_in_function_equal_p (built_in_function name0, built_in_function name1) +{ + return name0 == name1; +} + +/* Recursive case for two or more names. */ + +template <typename... F> +inline bool +built_in_function_equal_p (built_in_function name0, built_in_function name1, + built_in_function name2, F... names) +{ + return name0 == name1 || built_in_function_equal_p (name0, name2, names...); +} + /* Return true if a FUNCTION_DECL NODE is a GCC built-in function. Note that it is different from the DECL_IS_UNDECLARED_BUILTIN @@ -6616,13 +6634,16 @@ fndecl_built_in_p (const_tree node, unsigned int name, built_in_class klass) } /* Return true if a FUNCTION_DECL NODE is a GCC built-in function - of BUILT_IN_NORMAL class with name equal to NAME. */ + of BUILT_IN_NORMAL class with name equal to NAME1 (or other mentioned + NAMES). */ +template <typename... F> inline bool -fndecl_built_in_p (const_tree node, built_in_function name) +fndecl_built_in_p (const_tree node, built_in_function name1, F... names) { return (fndecl_built_in_p (node, BUILT_IN_NORMAL) - && DECL_FUNCTION_CODE (node) == name); + && built_in_function_equal_p (DECL_FUNCTION_CODE (node), + name1, names...)); } /* A struct for encapsulating location information about an operator |