public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthew Malcomson <matmal01@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] varasm: Fix ICE in initializer_constant_valid_p_1 Date: Mon, 14 Mar 2022 10:35:22 +0000 (GMT) [thread overview] Message-ID: <20220314103522.6F45B3857405@sourceware.org> (raw) https://gcc.gnu.org/g:b0775d04a58ac8b5a69251ae902c9306f785fcec commit b0775d04a58ac8b5a69251ae902c9306f785fcec Author: Alex Coplan <alex.coplan@arm.com> Date: Fri Mar 4 12:36:15 2022 +0000 varasm: Fix ICE in initializer_constant_valid_p_1 This patch fixes ICEs in initializer_constant_valid_p_1 where the initializer value has a capability type. Note that for code such as: char c; char *p = &c - 1; long l = (long)(&c - 1); int i = (int)(&c - 1); even on capability targets, both p and l are valid, but i is invalid. The key observation here is that it doesn't matter if the entire capability fits in the integer type `endtype`, only whether its address value fits in. E.g. for l above we can just emit a normal xword directive with a relocation to obtain the address value. Hence, we change TYPE_PRECISION to TYPE_NONCAP_PRECISION when performing this check on TREE_TYPE (value) in initializer_constant_valid_p_1 for the POINTER_{PLUS,DIFF}_EXPR cases. Diff: --- gcc/varasm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/varasm.c b/gcc/varasm.c index 0301966f484..48a880d4f66 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4868,8 +4868,9 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) return NULL_TREE; if (cache && cache[0] == value) return cache[1]; + if (! INTEGRAL_TYPE_P (endtype) - || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value))) + || TYPE_PRECISION (endtype) >= TYPE_NONCAP_PRECISION (TREE_TYPE (value))) { tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE }; tree valid0 @@ -4905,7 +4906,7 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) if (cache && cache[0] == value) return cache[1]; if (! INTEGRAL_TYPE_P (endtype) - || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value))) + || TYPE_PRECISION (endtype) >= TYPE_NONCAP_PRECISION (TREE_TYPE (value))) { tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE }; tree valid0
reply other threads:[~2022-03-14 10:35 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220314103522.6F45B3857405@sourceware.org \ --to=matmal01@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).