public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1654] aarch64: Don't return invalid GIMPLE assign statements
@ 2022-07-13 8:02 Richard Sandiford
0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2022-07-13 8:02 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e9cad1e582950d129aba3465b65c2231f94bb6c0
commit r13-1654-ge9cad1e582950d129aba3465b65c2231f94bb6c0
Author: Andrew Carlotti <andrew.carlotti@arm.com>
Date: Wed Jul 13 09:01:51 2022 +0100
aarch64: Don't return invalid GIMPLE assign statements
aarch64_general_gimple_fold_builtin doesn't check whether the LHS of a
function call is null before converting it to an assign statement. To avoid
returning an invalid GIMPLE statement in this case, we instead assign the
expression result to a new (unused) variable.
This change only affects code that:
1) Calls an intrinsic function that has no side effects;
2) Does not use or store the value returned by the intrinsic;
3) Uses parameters that prevent the front-end eliminating the call prior to
gimplification.
The ICE is unlikely to have occurred in the wild, as it relies on the presence
of a redundant intrinsic call.
gcc/ChangeLog:
* config/aarch64/aarch64-builtins.cc
(aarch64_general_gimple_fold_builtin): Add fixup for invalid GIMPLE.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c: New test.
Diff:
---
gcc/config/aarch64/aarch64-builtins.cc | 10 ++++++++++
.../gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c | 9 +++++++++
2 files changed, 19 insertions(+)
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index adfddb8b215..4621c6d43da 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -2907,6 +2907,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt,
default:
break;
}
+
+ /* GIMPLE assign statements (unlike calls) require a non-null lhs. If we
+ created an assign statement with a null lhs, then fix this by assigning
+ to a new (and subsequently unused) variable. */
+ if (new_stmt && is_gimple_assign (new_stmt) && !gimple_assign_lhs (new_stmt))
+ {
+ tree new_lhs = make_ssa_name (gimple_call_return_type (stmt));
+ gimple_assign_set_lhs (new_stmt, new_lhs);
+ }
+
return new_stmt;
}
diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c
new file mode 100644
index 00000000000..345307456b1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c
@@ -0,0 +1,9 @@
+/* { dg-do compile { target { aarch64*-*-* } } } */
+
+#include <arm_neon.h>
+
+int8_t *bar();
+
+void foo() {
+ __builtin_aarch64_ld1v16qi(bar());
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-13 8:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 8:02 [gcc r13-1654] aarch64: Don't return invalid GIMPLE assign statements Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).