Don't drop DECL_INITIAL if -g for DWARF2+ (PR fortran/55395)

Message ID 2566667.Dv0IlRhJMA@polaris
State New
Headers show

Commit Message

Eric Botcazou Dec. 8, 2012, 3:51 p.m.
> > OK.  How we want to handle this with LTO streaming?
> Don't know.  From debug info quality POV right now, LTO has lots of other
> more important issues first.  And from the invalid error POV, that only
> matters if the initializer changes in between RTL expansion of some function
> and end of compilation, so could be fine for now.  If not C++-style const,
> the DECL_INITIAL is used only in the CUs where the definition of the symbol
> is emitted or would be emitted anyway.

This breaks LTO bootstrap with Ada enabled though, because the following 
DECL_IN_CONSTANT_POOL variable has had its DECL_INITIAL wrongly reset:

(gdb) p debug_tree(decl)
 <var_decl 0x7ffff6b79260 *.LC27
    type <record_type 0x7ffff6e46bd0 string___XUB readonly asm_written DI
        size <integer_cst 0x7ffff6d09d20 constant 64>
        unit size <integer_cst 0x7ffff6d09d40 constant 8>
        align 32 symtab -152784816 alias set 38 canonical type 0x7ffff6e46bd0
        fields <field_decl 0x7ffff6d28260 LB0 type <integer_type 
0x7ffff6d1a5e8 int>
            nonaddressable SI file <built-in> line 0 col 0
            size <integer_cst 0x7ffff6d1e0a0 constant 32>
            unit size <integer_cst 0x7ffff6d1e0c0 constant 4>
            align 32 offset_align 128
            offset <integer_cst 0x7ffff6d09d60 constant 0>
            bit offset <integer_cst 0x7ffff6d09de0 constant 0> context 
<record_type 0x7ffff6e46bd0 string___XUB> chain <field_decl 0x7ffff6d282f8 
        pointer_to_this <pointer_type 0x7ffff6e46b28> chain <type_decl 
0x7ffff6d25e60 string___XUB>>
    readonly addressable static ignored in-constant-pool DI file (null) line 0 
col 0 size <integer_cst 0x7ffff6d09d20 64> unit size <integer_cst 
0x7ffff6d09d40 8>
    align 32 initial <error_mark 0x7ffff6d10bb8>>

so I've installed the attached patch as obvious after testing on x86-64/Linux.

2012-12-08  Eric Botcazou  <>

	* lto-streamer-out.c (lto_write_tree): Do not reset the DECL_INITIAL of
	variables in the global contant pool.


Index: lto-streamer-out.c
--- lto-streamer-out.c	(revision 194319)
+++ lto-streamer-out.c	(working copy)
@@ -328,6 +328,7 @@  lto_write_tree (struct output_block *ob,
       tree initial = DECL_INITIAL (expr);
       if (TREE_CODE (expr) == VAR_DECL
 	  && (TREE_STATIC (expr) || DECL_EXTERNAL (expr))
+	  && !DECL_IN_CONSTANT_POOL (expr)
 	  && initial)
 	  lto_symtab_encoder_t encoder;