public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Late SIMPLE_IPA_PASS, DECL_INITIAL and error mark nodes
@ 2021-06-11 10:06 Erick Ochoa
  2021-06-11 11:47 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Erick Ochoa @ 2021-06-11 10:06 UTC (permalink / raw)
  To: gcc

Hi,

I am looking for a small clarification. I understand that during late
SIMPLE_IPA_PASSes some statically initialized global variables might
have error_mark_node trees in their DECL_INITIAL field.

I believe that I read something similar in the past about how to get
the tree expressions in these situations, and I believe it said one
had to stream in those symbols from the .gnu.lto_.decl section.

However, on the GCC Internals there is also the following mention: "If
the DECL_INITIAL is the error_mark_node, there is an initializer, but
it is given by an explicit statement later in the code; no bitwise
copy is required. " [0]

What (if any) is the correct way to get these expressions?

As a note, when running this pass as an IPA_PASS I am able to see the
DECL_INITIAL node of the variable of interest during LGEN.

Thanks!

[0] https://gcc.gnu.org/onlinedocs/gccint/Working-with-declarations.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Late SIMPLE_IPA_PASS, DECL_INITIAL and error mark nodes
  2021-06-11 10:06 Late SIMPLE_IPA_PASS, DECL_INITIAL and error mark nodes Erick Ochoa
@ 2021-06-11 11:47 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-06-11 11:47 UTC (permalink / raw)
  To: Erick Ochoa; +Cc: GCC Development

On Fri, Jun 11, 2021 at 12:07 PM Erick Ochoa via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi,
>
> I am looking for a small clarification. I understand that during late
> SIMPLE_IPA_PASSes some statically initialized global variables might
> have error_mark_node trees in their DECL_INITIAL field.
>
> I believe that I read something similar in the past about how to get
> the tree expressions in these situations, and I believe it said one
> had to stream in those symbols from the .gnu.lto_.decl section.
>
> However, on the GCC Internals there is also the following mention: "If
> the DECL_INITIAL is the error_mark_node, there is an initializer, but
> it is given by an explicit statement later in the code; no bitwise
> copy is required. " [0]
>
> What (if any) is the correct way to get these expressions?

Use ctor_for_folding (decl) to access a known initializer.  error_mark_node
is returned when there is no known constant initializer, NULL for
zero-init and an actual value otherwise.

> As a note, when running this pass as an IPA_PASS I am able to see the
> DECL_INITIAL node of the variable of interest during LGEN.
>
> Thanks!
>
> [0] https://gcc.gnu.org/onlinedocs/gccint/Working-with-declarations.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-11 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 10:06 Late SIMPLE_IPA_PASS, DECL_INITIAL and error mark nodes Erick Ochoa
2021-06-11 11:47 ` Richard Biener

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).