diff mbox

[GOOGLE] Add discriminator for inlined callsite

Message ID CAO2gOZXxfJf7Ps=7AVTu25gr++4KPyEdmWGdSk0uVqrUX8cFiQ@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen Aug. 16, 2013, 11:11 p.m. UTC
This patch emits discriminator for inlined callsite. This is important
when there are two inlined callsites in the same line.

Bootstrapped, testing on going.

OK for google branches?

Thanks,
Dehao

Comments

Cary Coutant Aug. 19, 2013, 4:31 p.m. UTC | #1
> -  expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (stmt));
> +  location_t locus = BLOCK_SOURCE_LOCATION (stmt);
> +  expanded_location s = expand_location (locus);
>
>    if (dwarf_version >= 3 || !dwarf_strict)
>      {
>        add_AT_file (die, DW_AT_call_file, lookup_filename (s.file));
>        add_AT_unsigned (die, DW_AT_call_line, s.line);
> +      unsigned discr = get_discriminator_from_locus (locus);
> +      if (discr != 0)
> + add_AT_unsigned (die, DW_AT_discr, discr);

DW_AT_discr is used to identify the "discriminant" for variant
records; we should not reuse it for the discriminator, even if it's
the case that the other meaning could never apply to a
DW_TAG_inlined_subroutine. You should instead add a new
DW_AT_GNU_discriminator to include/dwarf2.def and use that. 0x2136
looks like the next value in the GNU vendor range. Note that
dwarf2.def lives in both GCC and binutils repos, so once you have
approval to commit to the GCC repo, you'll need to commit the same
change to the binutils repo as well.

-cary
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 201632)
+++ gcc/dwarf2out.c (working copy)
@@ -18807,12 +18807,16 @@  gen_label_die (tree decl, dw_die_ref context_die)
 static inline void
 add_call_src_coords_attributes (tree stmt, dw_die_ref die)
 {
-  expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (stmt));
+  location_t locus = BLOCK_SOURCE_LOCATION (stmt);
+  expanded_location s = expand_location (locus);

   if (dwarf_version >= 3 || !dwarf_strict)
     {
       add_AT_file (die, DW_AT_call_file, lookup_filename (s.file));
       add_AT_unsigned (die, DW_AT_call_line, s.line);
+      unsigned discr = get_discriminator_from_locus (locus);
+      if (discr != 0)
+ add_AT_unsigned (die, DW_AT_discr, discr);
     }
 }