public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9443] expand: Fix up LTO ICE with COMPOUND_LITERAL_EXPR [PR99849] Date: Tue, 20 Apr 2021 23:34:27 +0000 (GMT) [thread overview] Message-ID: <20210420233427.04F803839C5C@sourceware.org> (raw) https://gcc.gnu.org/g:49a7e7d0fc5fcc28ed13b6d67faf99a5dfe03f65 commit r9-9443-g49a7e7d0fc5fcc28ed13b6d67faf99a5dfe03f65 Author: Jakub Jelinek <jakub@redhat.com> Date: Sat Apr 10 12:49:01 2021 +0200 expand: Fix up LTO ICE with COMPOUND_LITERAL_EXPR [PR99849] The gimplifier optimizes away COMPOUND_LITERAL_EXPRs, but they can remain in the form of ADDR_EXPR of COMPOUND_LITERAL_EXPRs in static initializers. By the TREE_STATIC check I meant to check that the underlying decl of the compound literal is a global rather than automatic variable which obviously can't be referenced in static initializers, but unfortunately with LTO it might end up in another partition and thus be DECL_EXTERNAL instead. 2021-04-10 Jakub Jelinek <jakub@redhat.com> PR lto/99849 * expr.c (expand_expr_addr_expr_1): Test is_global_var rather than just TREE_STATIC on COMPOUND_LITERAL_EXPR_DECLs. * gcc.dg/lto/pr99849_0.c: New test. (cherry picked from commit 2e57bc7eedb084869d17fe07b538d907b8fee819) Diff: --- gcc/expr.c | 2 +- gcc/testsuite/gcc.dg/lto/pr99849_0.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/expr.c b/gcc/expr.c index fa15b7eceae..1ac5faec67c 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7967,7 +7967,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, scalar_int_mode tmode, array with address of COMPOUND_LITERAL_EXPR in DECL_INITIAL; the initializers aren't gimplified. */ if (COMPOUND_LITERAL_EXPR_DECL (exp) - && TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (exp))) + && is_global_var (COMPOUND_LITERAL_EXPR_DECL (exp))) return expand_expr_addr_expr_1 (COMPOUND_LITERAL_EXPR_DECL (exp), target, tmode, modifier, as); /* FALLTHRU */ diff --git a/gcc/testsuite/gcc.dg/lto/pr99849_0.c b/gcc/testsuite/gcc.dg/lto/pr99849_0.c new file mode 100644 index 00000000000..d489cee0f52 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr99849_0.c @@ -0,0 +1,23 @@ +/* PR lto/99849 */ +/* { dg-lto-do link } */ +/* { dg-require-effective-target fpic } */ +/* { dg-require-effective-target shared } */ +/* { dg-extra-ld-options { -shared } } */ +/* { dg-lto-options { { -flto -flto-partition=1to1 -O2 -Wno-incompatible-pointer-types -Wno-discarded-qualifiers -fPIC } } } */ + +struct { struct A *a; } *b; +struct B { int *b; }; +struct C { int *c; }; +const struct D { struct C d; } d; +struct A { struct { struct C e; }; }; +struct E { void *e; } e = { &( &(const struct D) { (void *) &d })->d }; +struct C f = { &( &(const struct D) { (void *) &d })->d }; +struct A g[] = { &e, &f }; +void foo () { b->a = g; } +struct E h = { foo }; +void bar (); +int baz () { bar (h); } +struct B i = { (int *) baz }; +void qux (); +void corge () { qux (i); } +void *j __attribute__((__used__)) = corge;
reply other threads:[~2021-04-20 23:34 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=20210420233427.04F803839C5C@sourceware.org \ --to=jakub@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).