On Tue, Sep 27, 2016 at 4:01 PM, Pierre-Marie de Rodat
<dero...@adacore.com> wrote:
> On 09/07/2016 11:30 AM, Richard Biener wrote:
>>
>> That said, with the idea of early debug in place and thus giving
>> more responsibility to the frontends I wonder in what order the Ada
>> FE calls debug_hooks.early_global_decl ()? Maybe it's the middle-end
>> and it should arrange for a more natural order on function nests.  So
>> I'd appreciate if you can investigate this side of the issue a bit,
>> that is, simply avoid the bad ordering.
>
>
> I investigated this track: it’s not the Ada front-end’s calls to the
> debug_hooks.early_global_decl that matter, but actually the ones in
> cgraphunit.c (symbol_table::finalize_compilation_unit).
>
> The new patch attached tries to fix the call order. Bootstrapping and
> regtesting on x86_64-linux were clean except one testcase where the debug
> output changed legitimally (matcher updated). Ok to commit? Thank you in
> advance!

Hmm, interesting approach.  It might work reliably at this point of
the compilation
but we do actually recycle cgraph nodes.  So I wonder if given we do have
->origin / ->next_nested in the cgraph if we can simply perform a walk in the
appropriate order.

But then OTOH in my early LTO debug patchset I have

Index: early-lto-debug/gcc/dwarf2out.c
===================================================================
--- early-lto-debug.orig/gcc/dwarf2out.c        2016-09-26
15:51:37.666113699 +0200
+++ early-lto-debug/gcc/dwarf2out.c     2016-09-27 08:52:20.802507268 +0200
@@ -23837,6 +24261,16 @@ dwarf2out_early_global_decl (tree decl)
          if (!DECL_STRUCT_FUNCTION (decl))
            goto early_decl_exit;

+         /* Emit an abstract origin of a function first.  This happens
+            with C++ constructor clones for example and makes
+            dwarf2out_abstract_function happy which requires the early
+            DIE of the abstract instance to be present.  */
+         if (DECL_ABSTRACT_ORIGIN (decl))
+           {
+             current_function_decl = DECL_ABSTRACT_ORIGIN (decl);
+             dwarf2out_decl (DECL_ABSTRACT_ORIGIN (decl));
+           }
+
          current_function_decl = decl;
        }
       dwarf2out_decl (decl);

which is not 100% equivalent (looking at the abstract origin) but it
sounds like a
similar issue.  So I wonder if doing the same for DECL_CONTEXT being a function
makes sense here and would also fix your particular issue in a more
reliable way.

Thanks,
Richard.

> --
> Pierre-Marie de Rodat

Reply via email to