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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> Can reproduce.  The best thing would be to place some strategic asserts in
> dwarf2out.c that trigger when we output "relocations" during early dwarf out.
> I'll see to that tomorrow.
> 
> Note there are some related acats FAILs that might be easier to analyze.

Respective, c330001, c390011, c731001, c854002, cc50a01 and cc50a02 FAIL
with unresolved symbols at link time when you edit
gcc/testsuite/ada/acats/run_all.sh to have -O2 -flto -g in gccflags.

Didn't succeed in quickly finding spots to assert on in the dwarf2out
or dwarf2asm assembly emission to track those issues down earlier and
more reliable.  Help with that appreciated.

It looks like that c330001_0-c330001_1.ads produces an invalid reference
here:

 <3><32e>: Abbrev Number: 6 (DW_TAG_array_type)
    <32f>   DW_AT_name        : (indirect string, offset: 0xb3a):
c330001_0__c33
0001_1__T5s__T8s__T9s
    <333>   DW_AT_GNAT_descriptive_type: <0x351>
    <337>   DW_AT_type        : <0x15b>
    <33b>   DW_AT_sibling     : <0x351>
 <4><33f>: Abbrev Number: 24 (DW_TAG_subrange_type)
    <340>   DW_AT_type        : <0x23>
    <344>   DW_AT_upper_bound : 11 byte block: 3 0 0 0 0 0 0 0 0 94 4  
(DW_OP_addr: 0; DW_OP_deref_size: 4)
 <4><350>: Abbrev Number: 0

resulting in

    23: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND
c330001_0__c330001_1__T5s
    24: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND
c330001_0__c330001_1__Tpr

c330001_0-c330001_1.ads:(.debug_info+0x9c3): undefined reference to
`c330001_0__c330001_1__Tprivatechild_obj_02S__T19s__TT20sP1_(unsigned)'
c330001_0-c330001_1.ads:(.debug_info+0x9eb): undefined reference to
`c330001_0__c330001_1__Tprivatechild_obj_02S__T19s__TT20sP1_(unsigned)'

added by

#0  add_dwarf_attr (die=0x7ffff63ce730, attr=0x7fffffffc240)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:4361
#1  0x0000000000f5adcb in add_AT_loc (die=0x7ffff63ce730, 
    attr_kind=DW_AT_upper_bound, loc=0x7ffff63ce820)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:4820
#2  0x0000000000f84b61 in add_scalar_info (die=0x7ffff63ce730, 
    attr=DW_AT_upper_bound, value=0x7ffff6393000, forms=7, context=0x0)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:20652
#3  0x0000000000f84de5 in add_bound_info (subrange_die=0x7ffff63ce730, 
    bound_attr=DW_AT_upper_bound, bound=0x7ffff6393000, context=0x0)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:20758
#4  0x0000000000f6cf1c in subrange_type_die (type=0x7ffff638fbd0, 
    low=0x7ffff67c8f90, high=0x7ffff6393000, bias=0x0, 
    context_die=0x7ffff63ce690)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:12950
#5  0x0000000000f6e06e in modified_type_die (type=0x7ffff638fbd0, cv_quals=0, 
    reverse=false, context_die=0x7ffff63ce690)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:13316

in this case the value we want to record for the upper bound is

 <var_decl 0x7ffff6393000 c330001_0__c330001_1__T5s__T8s__TT9sP1___U
    type <integer_type 0x7ffff6363690 c330001_0__sub_type___XDLU_1__20
        type <integer_type 0x7ffff67dc5e8 integer sizes-gimplified asm_written
public visited SI
...

and that didn't get a DIE (yet?).  We do have

        rtl = rtl_for_decl_location (loc);
        if (rtl == NULL_RTX)
          {
            if (TREE_CODE (loc) != FUNCTION_DECL
                && early_dwarf
                && current_function_decl
                && want_address != 1
                && ! DECL_IGNORED_P (loc)
                && (INTEGRAL_TYPE_P (TREE_TYPE (loc))
                    || POINTER_TYPE_P (TREE_TYPE (loc)))
                && DECL_CONTEXT (loc) == current_function_decl
                && (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (loc)))
                    <= DWARF2_ADDR_SIZE))
              {
                dw_die_ref ref = lookup_decl_die (loc);
                ret = new_loc_descr (DW_OP_GNU_variable_value, 0, 0);
...

but rtl_for_decl_location returns non-NULL here and lookup_decl_die
wouldn't succeed yet.  I can "force" things like the following:

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c     (revision 258720)
+++ gcc/dwarf2out.c     (working copy)
@@ -18204,6 +18204,7 @@ loc_list_from_tree_1 (tree loc, int want
        rtl = rtl_for_decl_location (loc);
        if (rtl == NULL_RTX)
          {
+force:
            if (TREE_CODE (loc) != FUNCTION_DECL
                && early_dwarf
                && current_function_decl
@@ -18249,6 +18250,11 @@ loc_list_from_tree_1 (tree loc, int want
           ret = new_addr_loc_descr (rtl, dtprel_false);
        else
          {
+           if (early_dwarf)
+             {
+               force_decl_die (loc);
+               goto force;
+             }
            machine_mode mode, mem_mode;

            /* Certain constructs can only be represented at top-level.  */

but not sure if that's reliable enough.

Ada folks, can you extract a LTO testcase for the above for gnat.dg?

Reply via email to