public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [LTO] free_language_specifics crashes C++ pretty-printer
@ 2008-10-09  7:06 Doug Kwan (關振德)
  2008-10-09  7:57 ` Richard Guenther
  0 siblings, 1 reply; 9+ messages in thread
From: Doug Kwan (關振德) @ 2008-10-09  7:06 UTC (permalink / raw)
  To: gcc-patches

I am working on a bug where free_language_specifics caused the C++
pretty-printer crash because it clears all TYPE_CONTEXT.  I can add a
band-aid in dump_typename but that does not look like the right fix to
me.  Is there a better solution?

-Doug

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  7:06 [LTO] free_language_specifics crashes C++ pretty-printer Doug Kwan (關振德)
@ 2008-10-09  7:57 ` Richard Guenther
  2008-10-09  8:21   ` Doug Kwan (關振德)
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Guenther @ 2008-10-09  7:57 UTC (permalink / raw)
  To: Doug Kwan (關振德); +Cc: gcc-patches

On Thu, Oct 9, 2008 at 8:35 AM, Doug Kwan (關振紱) <dougkwan@google.com> wrote:
> I am working on a bug where free_language_specifics caused the C++
> pretty-printer crash because it clears all TYPE_CONTEXT.  I can add a
> band-aid in dump_typename but that does not look like the right fix to
> me.  Is there a better solution?

How do we end up calling the pretty-printer?

Richard.

>
> -Doug
>

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  7:57 ` Richard Guenther
@ 2008-10-09  8:21   ` Doug Kwan (關振德)
  2008-10-09  8:24     ` Richard Guenther
  0 siblings, 1 reply; 9+ messages in thread
From: Doug Kwan (關振德) @ 2008-10-09  8:21 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

Without -quiet, cc1plus prints out declaration of functions inside
cgraph_expand_function.

-Doug

in cgraphunit.c ...

static void
cgraph_expand_function (struct cgraph_node *node)
{
  tree decl = node->decl;

  /* We ought to not compile any inline clones.  */
  gcc_assert (!node->global.inlined_to);

  announce_function (decl);
  ^^^^^^^^^^^^^^^^^^^^^^^^

... in toplev.c

/* Called when the start of a function definition is parsed,
   this function prints on stderr the name of the function.  */
void
announce_function (tree decl)
{
  if (!quiet_flag)
    {
      if (rtl_dump_and_exit)
        fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
      else
        fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
      fflush (stderr);
      pp_needs_newline (global_dc->printer) = true;
      diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
    }
}


2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
> On Thu, Oct 9, 2008 at 8:35 AM, Doug Kwan (關振德) <dougkwan@google.com> wrote:
>> I am working on a bug where free_language_specifics caused the C++
>> pretty-printer crash because it clears all TYPE_CONTEXT.  I can add a
>> band-aid in dump_typename but that does not look like the right fix to
>> me.  Is there a better solution?
>
> How do we end up calling the pretty-printer?
>
> Richard.
>
>>
>> -Doug
>>
>

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  8:21   ` Doug Kwan (關振德)
@ 2008-10-09  8:24     ` Richard Guenther
  2008-10-09  8:27       ` Doug Kwan (關振德)
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Guenther @ 2008-10-09  8:24 UTC (permalink / raw)
  To: Doug Kwan (關振德); +Cc: gcc-patches

2008/10/9 Doug Kwan (關振德) <dougkwan@google.com>:
> Without -quiet, cc1plus prints out declaration of functions inside
> cgraph_expand_function.

Ah, I see.  I think it would be better to dump the mangled
name in this case, DECL_ASSEMBLER_NAME.  So maybe
just add a flag to announce_function whether the mangled
or unmangled name is to be printed.

Richard.

> -Doug
>
> in cgraphunit.c ...
>
> static void
> cgraph_expand_function (struct cgraph_node *node)
> {
>  tree decl = node->decl;
>
>  /* We ought to not compile any inline clones.  */
>  gcc_assert (!node->global.inlined_to);
>
>  announce_function (decl);
>  ^^^^^^^^^^^^^^^^^^^^^^^^
>
> ... in toplev.c
>
> /* Called when the start of a function definition is parsed,
>   this function prints on stderr the name of the function.  */
> void
> announce_function (tree decl)
> {
>  if (!quiet_flag)
>    {
>      if (rtl_dump_and_exit)
>        fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
>      else
>        fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
>      fflush (stderr);
>      pp_needs_newline (global_dc->printer) = true;
>      diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
>    }
> }
>
>
> 2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
>> On Thu, Oct 9, 2008 at 8:35 AM, Doug Kwan (關振德) <dougkwan@google.com> wrote:
>>> I am working on a bug where free_language_specifics caused the C++
>>> pretty-printer crash because it clears all TYPE_CONTEXT.  I can add a
>>> band-aid in dump_typename but that does not look like the right fix to
>>> me.  Is there a better solution?
>>
>> How do we end up calling the pretty-printer?
>>
>> Richard.
>>
>>>
>>> -Doug
>>>
>>
>

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  8:24     ` Richard Guenther
@ 2008-10-09  8:27       ` Doug Kwan (關振德)
  2008-10-09  8:32         ` Richard Guenther
  0 siblings, 1 reply; 9+ messages in thread
From: Doug Kwan (關振德) @ 2008-10-09  8:27 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

The error happens during output of a qualified typename.   Do we store
strings of fully qualified type names

-Doug

2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
> 2008/10/9 Doug Kwan (關振德) <dougkwan@google.com>:
>> Without -quiet, cc1plus prints out declaration of functions inside
>> cgraph_expand_function.
>
> Ah, I see.  I think it would be better to dump the mangled
> name in this case, DECL_ASSEMBLER_NAME.  So maybe
> just add a flag to announce_function whether the mangled
> or unmangled name is to be printed.
>
> Richard.
>
>> -Doug
>>
>> in cgraphunit.c ...
>>
>> static void
>> cgraph_expand_function (struct cgraph_node *node)
>> {
>>  tree decl = node->decl;
>>
>>  /* We ought to not compile any inline clones.  */
>>  gcc_assert (!node->global.inlined_to);
>>
>>  announce_function (decl);
>>  ^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> ... in toplev.c
>>
>> /* Called when the start of a function definition is parsed,
>>   this function prints on stderr the name of the function.  */
>> void
>> announce_function (tree decl)
>> {
>>  if (!quiet_flag)
>>    {
>>      if (rtl_dump_and_exit)
>>        fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
>>      else
>>        fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
>>      fflush (stderr);
>>      pp_needs_newline (global_dc->printer) = true;
>>      diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
>>    }
>> }
>>
>>
>> 2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
>>> On Thu, Oct 9, 2008 at 8:35 AM, Doug Kwan (關振德) <dougkwan@google.com> wrote:
>>>> I am working on a bug where free_language_specifics caused the C++
>>>> pretty-printer crash because it clears all TYPE_CONTEXT.  I can add a
>>>> band-aid in dump_typename but that does not look like the right fix to
>>>> me.  Is there a better solution?
>>>
>>> How do we end up calling the pretty-printer?
>>>
>>> Richard.
>>>
>>>>
>>>> -Doug
>>>>
>>>
>>
>

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  8:27       ` Doug Kwan (關振德)
@ 2008-10-09  8:32         ` Richard Guenther
  2008-10-09  9:38           ` Doug Kwan (關振德)
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Guenther @ 2008-10-09  8:32 UTC (permalink / raw)
  To: Doug Kwan (關振德); +Cc: gcc-patches

On Thu, Oct 9, 2008 at 10:24 AM, Doug Kwan (關振德) <dougkwan@google.com> wrote:
> The error happens during output of a qualified typename.   Do we store
> strings of fully qualified type names

No, but I don't see how this matters here.  announce_function
is a debugging thing, and in the end we shouldn't emit new
diagnostics from the link-time run of LTO.

Richard.

> -Doug
>
> 2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
>> 2008/10/9 Doug Kwan (關振德) <dougkwan@google.com>:
>>> Without -quiet, cc1plus prints out declaration of functions inside
>>> cgraph_expand_function.
>>
>> Ah, I see.  I think it would be better to dump the mangled
>> name in this case, DECL_ASSEMBLER_NAME.  So maybe
>> just add a flag to announce_function whether the mangled
>> or unmangled name is to be printed.
>>
>> Richard.
>>
>>> -Doug
>>>
>>> in cgraphunit.c ...
>>>
>>> static void
>>> cgraph_expand_function (struct cgraph_node *node)
>>> {
>>>  tree decl = node->decl;
>>>
>>>  /* We ought to not compile any inline clones.  */
>>>  gcc_assert (!node->global.inlined_to);
>>>
>>>  announce_function (decl);
>>>  ^^^^^^^^^^^^^^^^^^^^^^^^
>>>
>>> ... in toplev.c
>>>
>>> /* Called when the start of a function definition is parsed,
>>>   this function prints on stderr the name of the function.  */
>>> void
>>> announce_function (tree decl)
>>> {
>>>  if (!quiet_flag)
>>>    {
>>>      if (rtl_dump_and_exit)
>>>        fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
>>>      else
>>>        fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
>>>      fflush (stderr);
>>>      pp_needs_newline (global_dc->printer) = true;
>>>      diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
>>>    }
>>> }
>>>
>>>
>>> 2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
>>>> On Thu, Oct 9, 2008 at 8:35 AM, Doug Kwan (關振德) <dougkwan@google.com> wrote:
>>>>> I am working on a bug where free_language_specifics caused the C++
>>>>> pretty-printer crash because it clears all TYPE_CONTEXT.  I can add a
>>>>> band-aid in dump_typename but that does not look like the right fix to
>>>>> me.  Is there a better solution?
>>>>
>>>> How do we end up calling the pretty-printer?
>>>>
>>>> Richard.
>>>>
>>>>>
>>>>> -Doug
>>>>>
>>>>
>>>
>>
>

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  8:32         ` Richard Guenther
@ 2008-10-09  9:38           ` Doug Kwan (關振德)
  2008-10-09 13:09             ` Richard Guenther
  0 siblings, 1 reply; 9+ messages in thread
From: Doug Kwan (關振德) @ 2008-10-09  9:38 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

2008/10/9 Richard Guenther <richard.guenther@gmail.com>:

> No, but I don't see how this matters here.  announce_function
> is a debugging thing, and in the end we shouldn't emit new
> diagnostics from the link-time run of LTO.

This happens before the link-time run of the LTO. In the C/C++
frontends, we strip all language specifics before writing out the IR.

I think we still want LTO to emit new diagnostics.  If a user tried to
combine objects with inconsistent function declarations, LTO should
detect this and emit an error message.  Note that this situation
cannot be detected when individual source files are compiled prior to
LTO.

-Doug

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09  9:38           ` Doug Kwan (關振德)
@ 2008-10-09 13:09             ` Richard Guenther
  2008-10-09 13:59               ` Diego Novillo
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Guenther @ 2008-10-09 13:09 UTC (permalink / raw)
  To: Doug Kwan (關振德); +Cc: gcc-patches

On Thu, Oct 9, 2008 at 10:36 AM, Doug Kwan (關振紱) <dougkwan@google.com> wrote:
> 2008/10/9 Richard Guenther <richard.guenther@gmail.com>:
>
>> No, but I don't see how this matters here.  announce_function
>> is a debugging thing, and in the end we shouldn't emit new
>> diagnostics from the link-time run of LTO.
>
> This happens before the link-time run of the LTO. In the C/C++
> frontends, we strip all language specifics before writing out the IR.
>
> I think we still want LTO to emit new diagnostics.  If a user tried to
> combine objects with inconsistent function declarations, LTO should
> detect this and emit an error message.  Note that this situation
> cannot be detected when individual source files are compiled prior to
> LTO.

Ok.  Still as this is a debugging/diagnostic function only, maybe
the simplest thing is to just not use the langhook but use
DECL_NAME always.  Or DECL_ASSEMBLER_NAME, as this is more specific in
the C++ case?

Richard.

> -Doug
>

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

* Re: [LTO] free_language_specifics crashes C++ pretty-printer
  2008-10-09 13:09             ` Richard Guenther
@ 2008-10-09 13:59               ` Diego Novillo
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Novillo @ 2008-10-09 13:59 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Doug Kwan (關振德), gcc-patches

2008/10/9 Richard Guenther <richard.guenther@gmail.com>:

> Ok.  Still as this is a debugging/diagnostic function only, maybe
> the simplest thing is to just not use the langhook but use
> DECL_NAME always.  Or DECL_ASSEMBLER_NAME, as this is more specific in
> the C++ case?

Agreed.  Unconditionally emitting DECL_NAME/DECL_ASSEMBLER_NAME is
what we should do here.  For future diagnostics, we will probably need
to use the demangler or store demangled names in the lto output.


Diego.

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

end of thread, other threads:[~2008-10-09 13:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-09  7:06 [LTO] free_language_specifics crashes C++ pretty-printer Doug Kwan (關振德)
2008-10-09  7:57 ` Richard Guenther
2008-10-09  8:21   ` Doug Kwan (關振德)
2008-10-09  8:24     ` Richard Guenther
2008-10-09  8:27       ` Doug Kwan (關振德)
2008-10-09  8:32         ` Richard Guenther
2008-10-09  9:38           ` Doug Kwan (關振德)
2008-10-09 13:09             ` Richard Guenther
2008-10-09 13:59               ` Diego Novillo

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