This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

fix dwarf2 constant reference

SpecFP 95 applu.f has a couple of variables that are assigned
constants, e.g.

      r43 = ( 4.0d+00 / 3.0d+00 )

Something about the way the fortran front end is emitting the
variable reference (I didn't investigate) leaves the debug info
with the idea that the variable's address is in the constant pool,
i.e., (mem:DF (symbol_ref:DI "$LC43")).  Which is all well and
good, since that memory location would contain the correct value
for that variable.

Except that it turns out that those constants are never actually
used -- we always manage to constant-fold each and every one of
them with something adjacent.  Which means that $LC43 isn't emitted,
which means that we've got a reference to an undefined label in
the debug info, which means the link fails.

Fixed by noticing constant pool references in the debug info and
emitting the constant into the debug info directly, like so:

        .ascii "r43\0"   # DW_AT_name
        .byte   0x1      # DW_AT_decl_file
        .2byte  0x67a    # DW_AT_decl_line
        .4byte  0x642    # DW_AT_type
        .byte   0x8      # DW_AT_const_value
        .4byte  0x55555555       # fp constant word 0
        .4byte  0x3ff55555       # fp constant word 1

Oh, and I happened to notice a buglet in how unsigned integer
constants are emitted.

Tested on alphaev56-linux.


        * simplify-rtx.c (avoid_constant_pool_reference): Export.
        * rtl.h (avoid_constant_pool_reference): Declare it.
        * dwarf2out.c (add_location_or_const_value_attribute): Use it.
        (add_const_value_attribute): Use add_AT_unsigned for unsigned values.

Index: dwarf2out.c
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.294
diff -c -p -d -r1.294 dwarf2out.c
*** dwarf2out.c	2001/07/19 21:17:07	1.294
--- dwarf2out.c	2001/07/26 23:44:46
*************** add_const_value_attribute (die, rtl)
*** 8215,8221 ****
  	    if ((unsigned long) val != (unsigned HOST_WIDE_INT) val)
  	      abort ();
! 	    add_AT_int (die, DW_AT_const_value, (unsigned long) val);
--- 8215,8221 ----
  	    if ((unsigned long) val != (unsigned HOST_WIDE_INT) val)
  	      abort ();
! 	    add_AT_unsigned (die, DW_AT_const_value, (unsigned long) val);
*************** add_location_or_const_value_attribute (d
*** 8473,8478 ****
--- 8473,8483 ----
    rtl = rtl_for_decl_location (decl);
    if (rtl == NULL_RTX)
+   /* If we don't look past the constant pool, we risk emitting a
+      reference to a constant pool entry that isn't referenced from
+      code, and thus is not emitted.  */
+   rtl = avoid_constant_pool_reference (rtl);
    switch (GET_CODE (rtl))
Index: rtl.h
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.279
diff -c -p -d -r1.279 rtl.h
*** rtl.h	2001/07/26 20:36:00	1.279
--- rtl.h	2001/07/26 23:44:46
*************** extern rtx simplify_gen_subreg		PARAMS (
*** 1345,1350 ****
--- 1345,1351 ----
  						 unsigned int));
  extern rtx simplify_replace_rtx		PARAMS ((rtx, rtx, rtx));
  extern rtx simplify_rtx			PARAMS ((rtx));
+ extern rtx avoid_constant_pool_reference PARAMS ((rtx));
  /* In function.c  */
  extern rtx gen_mem_addressof		PARAMS ((rtx, union tree_node *));
Index: simplify-rtx.c
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.72
diff -c -p -d -r1.72 simplify-rtx.c
*** simplify-rtx.c	2001/07/24 23:43:55	1.72
--- simplify-rtx.c	2001/07/26 23:44:46
*************** Boston, MA 02111-1307, USA.  */
*** 99,105 ****
  static rtx simplify_plus_minus		PARAMS ((enum rtx_code,
  						 enum machine_mode, rtx, rtx));
  static void check_fold_consts		PARAMS ((PTR));
- static rtx avoid_constant_pool_reference PARAMS ((rtx));
  /* Make a binary operation by properly ordering the operands and 
     seeing if the expression folds.  */
--- 99,104 ----
*************** simplify_gen_binary (code, mode, op0, op
*** 138,144 ****
  /* If X is a MEM referencing the constant pool, return the real value.
     Otherwise return X.  */
! static rtx
  avoid_constant_pool_reference (x)
       rtx x;
--- 137,143 ----
  /* If X is a MEM referencing the constant pool, return the real value.
     Otherwise return X.  */
! rtx
  avoid_constant_pool_reference (x)
       rtx x;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]