[Bug ada/83765] New: LTO bootstrap with Ada fails

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 10 09:01:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83765

            Bug ID: 83765
           Summary: LTO bootstrap with Ada fails
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-*-*

At the moment it ICEs for me with

> /abuild/rguenther/obj/./prev-gcc/lto1 -quiet -dumpdir ./ -dumpbase gnat1.ltrans0 -mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase-strip gnat1.ltrans0.ltrans.o -g -g -O2 -O2 -O2 -Wextra -Wpedantic -version -fno-openmp -fno-openacc -frandom-seed=1 -fno-exceptions -fasynchronous-unwind-tables -fno-common -frandom-seed=1 -fltrans gnat1.ltrans0.o -o gnat1.ltrans0.s
GNU GIMPLE (GCC) version 8.0.0 20180109 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2,
MPC version 1.0.2, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU GIMPLE (GCC) version 8.0.0 20180109 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2,
MPC version 1.0.2, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
/space/rguenther/src/svn/trunk/gcc/ada/exp_ch4.adb: In function
‘exp_ch4__expand_n_reduction_expression’:
/space/rguenther/src/svn/trunk/gcc/ada/exp_ch4.adb:10117: warning: ‘actual’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
       Reduction_Par := Expression (Actual);

/space/rguenther/src/svn/trunk/gcc/ada/exp_ch4.adb:10092: note: ‘actual’ was
declared here
       Actual        : Node_Id;

/space/rguenther/src/svn/trunk/gcc/ada/exp_ch3.adb: In function
‘exp_ch3__expand_n_full_type_declaration’:
/space/rguenther/src/svn/trunk/gcc/ada/atree.adb:5952:38: warning: ‘m_id’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
          Nodes.Table (N + 2).Field10 := Union_Id (Val);
                                      ^
/space/rguenther/src/svn/trunk/gcc/ada/exp_ch3.adb:5483: note: ‘m_id’ was
declared here
             M_Id  : Entity_Id;

during RTL pass: final
/space/rguenther/src/svn/trunk/gcc/ada/exp_spark.adb: In function
‘exp_spark__expand_spark_potential_renaming’:
/space/rguenther/src/svn/trunk/gcc/ada/exp_spark.adb:498: internal compiler
error: in add_dwarf_attr, at dwarf2out.c:4168
    end Expand_SPARK_Potential_Renaming;

0x981cc7 add_dwarf_attr
        /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:4168
0x981dbc add_AT_flag
        /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:4207
0x9b0cb9 gen_subprogram_die
        /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:22243
0x9ba815 gen_decl_die
        /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:25490
0x9b9175 process_scope_var


where the issue is IMHO that in get_subprogram_die we have

(gdb) p decl
$7 = <function_decl 0x7ffff6006400
sem_util__reset_analyzed_flags__clear_analyzed>
$8 = <function_decl 0x7ffff6006400
sem_util__reset_analyzed_flags__clear_analyzed>
(gdb) p decl->decl_common.abstract_origin 
$9 = <function_decl 0x7ffff6006400
sem_util__reset_analyzed_flags__clear_analyzed>
(gdb) p decl->decl_common.abstract_flag 
$10 = 0

and thus we get origin == decl and also old_die.  declaration == 1 but
due to the above we run into the if instead of the else if branch:

  /* A concrete instance, tag a new DIE with DW_AT_abstract_origin.  */
  if (origin != NULL)
    {   
...
    }
  /* A cached copy, possibly from early dwarf generation.  Reuse as
     much as possible.  */
  else if (old_die)
    {
      /* A declaration that has been previously dumped needs no
         additional information.  */
      if (declaration)
        return;

and end up adding DW_AT_declaration a second time (we come here multiple
times because it looks like a function with this declaration in its
scopes was inlined multiple times into exp_ch2__expand_entity_reference).

Now the interesting part is who sets this origin to self, quite likely
set_decl_origin_self (tried to get rid of that with no success...).
And it is set this way already in the LTO bytecode for the LTRANS stage.
Of course when coming along this in a declaration context via processing
BLOCK_NONLOCALIZED_VARS this confuses the machinery :/  Note how
set_block_origin_self does _not_ recurse into BLOCK_NONLOCALIZED_VARS!
Note we "properly" pass down NULL as origin but the passing down stops
at gen_decl_die -> gen_subprogram_die who recomputes it.

So

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c     (revision 256378)
+++ gcc/dwarf2out.c     (working copy)
@@ -21954,9 +21954,8 @@ gen_call_site_die (tree decl, dw_die_ref
    block-local).  */

 static void
-gen_subprogram_die (tree decl, dw_die_ref context_die)
+gen_subprogram_die (tree decl, tree origin, dw_die_ref context_die)
 {
-  tree origin = decl_ultimate_origin (decl);
   dw_die_ref subr_die;
   dw_die_ref old_die = lookup_decl_die (decl);

@@ -25199,7 +25198,7 @@ force_decl_die (tree decl)
             declaration die.  */
          save_fn = current_function_decl;
          current_function_decl = NULL_TREE;
-         gen_subprogram_die (decl, context_die);
+         gen_subprogram_die (decl, decl_ultimate_origin (decl), context_die);
          current_function_decl = save_fn;
          break;

@@ -25487,7 +25486,7 @@ gen_decl_die (tree decl, tree origin, st

       /* Now output a DIE to represent the function itself.  */
       if (decl)
-        gen_subprogram_die (decl, context_die);
+        gen_subprogram_die (decl, origin, context_die);
       break;

     case TYPE_DECL:

looks appealling... (testing that now)


More information about the Gcc-bugs mailing list