aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-10-22 09:05:38 -0700
committerAndrew Pinski <quic_apinski@quicinc.com>2024-10-23 16:33:35 -0700
commit36e3e68250bf54909218298d1141138579803631 (patch)
tree852ca0036ded90923f50765b8b462f3e66465772 /gcc
parent5467f5b5ca6f2302573649b4a4f897793a9a6e7f (diff)
downloadgcc-36e3e68250bf54909218298d1141138579803631.zip
gcc-36e3e68250bf54909218298d1141138579803631.tar.gz
gcc-36e3e68250bf54909218298d1141138579803631.tar.bz2
match: Reject non-const internal functions [PR117260]
When internal functions support was added to match (r6-4979-gc9e926ce2bdc8b), the check for ECF_CONST was the builtin function side. Though before r15-4503-g8d6d6d537fdc, there was no use of maybe_push_res_to_seq with non-const internal functions so the check would not make a difference. This adds the check for internal functions just as there is a check for builtins. Note I didn't add a testcase because there was no non-const internal function which could be used on x86_64 in a decent manor. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR tree-optimization/117260 * gimple-match-exports.cc (maybe_push_res_to_seq): Reject non-const internal functions. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-match-exports.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc
index d3e626a..77d2258 100644
--- a/gcc/gimple-match-exports.cc
+++ b/gcc/gimple-match-exports.cc
@@ -522,6 +522,11 @@ maybe_push_res_to_seq (gimple_match_op *res_op, gimple_seq *seq, tree res)
{
/* Generate the given function if we can. */
internal_fn ifn = as_internal_fn (fn);
+
+ /* We can't and should not emit calls to non-const functions. */
+ if (!(internal_fn_flags (ifn) & ECF_CONST))
+ return NULL_TREE;
+
new_stmt = build_call_internal (ifn, res_op);
if (!new_stmt)
return NULL_TREE;