public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] middle-end: Fix ICE in tree-ssa-forwprop
@ 2022-07-12 10:36 Alex Coplan
0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2022-07-12 10:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:587fdc0303ff883a899e474f20c42cc96997c7b6
commit 587fdc0303ff883a899e474f20c42cc96997c7b6
Author: Alex Coplan <alex.coplan@arm.com>
Date: Mon Jun 20 17:52:10 2022 +0100
middle-end: Fix ICE in tree-ssa-forwprop
This fixes an ICE in tree-ssa-forwprop.c:forward_propagate_addr_expr_1
which was due to a case of TYPE_PRECISION not being updated to one of
TYPE_[NON]CAP_PRECISION. Here we assert that for capability types, the
two types must have the same precision. For non-capability types, we
preserve the behaviour of the existing code (recursing on widening or
equal-precision conversions), but use TYPE_NONCAP_PRECISION to avoid
tripping the check when we handle capability types.
gcc/ChangeLog:
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Update
TYPE_PRECISION check to handle capability types.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/morello/forwprop-ice.c: New test.
Diff:
---
gcc/testsuite/gcc.target/aarch64/morello/forwprop-ice.c | 7 +++++++
gcc/tree-ssa-forwprop.c | 11 +++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/gcc.target/aarch64/morello/forwprop-ice.c b/gcc/testsuite/gcc.target/aarch64/morello/forwprop-ice.c
new file mode 100644
index 00000000000..901caec9356
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/morello/forwprop-ice.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* This test would ICE in the tree-ssa-forwprop pass due to the
+ conversion between two distinct capability types. */
+typedef int (*T)();
+void *p;
+void f(T);
+void g() { f((T)(p + 1)); }
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 6dee66a5322..ff4b81ea237 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -701,13 +701,20 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
return true;
}
+ /* If we have a conversion between two capability types, they should have
+ the same precision. */
+ gcc_assert (!capability_type_p (TREE_TYPE (lhs))
+ || !capability_type_p (TREE_TYPE (def_rhs))
+ || TYPE_CAP_PRECISION (TREE_TYPE (lhs))
+ == TYPE_CAP_PRECISION (TREE_TYPE (def_rhs)));
+
/* Else recurse if the conversion preserves the address value. */
if ((INTEGRAL_TYPE_P (TREE_TYPE (lhs))
|| POINTER_TYPE_P (TREE_TYPE (lhs)))
&& (capability_type_p (TREE_TYPE (lhs))
== capability_type_p (TREE_TYPE (def_rhs)))
- && (TYPE_PRECISION (TREE_TYPE (lhs))
- >= TYPE_PRECISION (TREE_TYPE (def_rhs))))
+ && (TYPE_NONCAP_PRECISION (TREE_TYPE (lhs))
+ >= TYPE_NONCAP_PRECISION (TREE_TYPE (def_rhs))))
return forward_propagate_addr_expr (lhs, def_rhs, single_use_p);
return false;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-12 10:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 10:36 [gcc(refs/vendors/ARM/heads/morello)] middle-end: Fix ICE in tree-ssa-forwprop Alex Coplan
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).