diff mbox

Use CHECKSUM_ macros and ULEB128 checksum for DIE tag

Message ID CALehDX6StXmfA4=QD91BE5oE7R135PLDy6gV6CMnnJTA4vkJLA@mail.gmail.com
State New
Headers show

Commit Message

Eric Christopher July 22, 2013, 8:15 p.m. UTC
Hi Cary,

This patch changes the ODR checker to use the CHECKSUM_ macros and
instead of depending on size of int to use the ULEB128 of the tag
(similar to the deep hash) to compute the values.

Thoughts?

-eric

2013-07-22  Eric Christopher  <echristo@gmail.com>

        * dwarf2out.c (die_odr_checksum): New function to use
        CHECKSUM_ macros and ULEB128 for DIE tag.
        (generate_type_signature): Use.

Comments

Jakub Jelinek July 22, 2013, 8:17 p.m. UTC | #1
On Mon, Jul 22, 2013 at 01:15:15PM -0700, Eric Christopher wrote:
> --- gcc/dwarf2out.c	(revision 198904)
> +++ gcc/dwarf2out.c	(working copy)
> @@ -6097,6 +6097,13 @@
>    CHECKSUM_ULEB128 (0);
>  }
>  

I guess you should add a function comment, plus spaces before ( everywhere
(and while you're at it, you can change also the is_cxx() ).  Will leave the
rest to Cary.

> +static void
> +die_odr_checksum (dw_die_ref die, md5_ctx *ctx)
> +{
> +  CHECKSUM_ULEB128(die->die_tag);
> +  CHECKSUM_STRING(get_AT_string(die, DW_AT_name));
> +}
> +
>  #undef CHECKSUM
>  #undef CHECKSUM_STRING
>  #undef CHECKSUM_ATTR
> @@ -6128,7 +6135,6 @@
>    /* First, compute a signature for just the type name (and its surrounding
>       context, if any.  This is stored in the type unit DIE for link-time
>       ODR (one-definition rule) checking.  */
> -
>    if (is_cxx() && name != NULL)
>      {
>        md5_init_ctx (&ctx);
> @@ -6137,8 +6143,8 @@
>        if (parent != NULL)
>          checksum_die_context (parent, &ctx);
>  
> -      md5_process_bytes (&die->die_tag, sizeof (die->die_tag), &ctx);
> -      md5_process_bytes (name, strlen (name) + 1, &ctx);
> +      /* Checksum the current DIE. */
> +      die_odr_checksum(die, &ctx);
>        md5_finish_ctx (&ctx, checksum);
>  
>        add_AT_data8 (type_node->root_die, DW_AT_GNU_odr_signature, &checksum[8]);


	Jakub
Cary Coutant July 22, 2013, 8:30 p.m. UTC | #2
-      md5_process_bytes (&die->die_tag, sizeof (die->die_tag), &ctx);
-      md5_process_bytes (name, strlen (name) + 1, &ctx);
+      /* Checksum the current DIE. */
+      die_odr_checksum(die, &ctx);

Since we've already gone to the trouble of getting the name of this
DIE, it seems wasteful to have die_odr_checksum call get_AT_string
again. Why not just pass name as a parameter?

> I guess you should add a function comment, plus spaces before ( everywhere
> (and while you're at it, you can change also the is_cxx() ).  Will leave the
> rest to Cary.

Agree with the function comment and the spaces.

> 2013-07-22  Eric Christopher  <echristo@gmail.com>
>
>         * dwarf2out.c (die_odr_checksum): New function to use
>         CHECKSUM_ macros and ULEB128 for DIE tag.
>         (generate_type_signature): Use.

This is OK with those changes. Thanks!

-cary
Eric Christopher July 22, 2013, 9:55 p.m. UTC | #3
On Mon, Jul 22, 2013 at 1:30 PM, Cary Coutant <ccoutant@google.com> wrote:
> -      md5_process_bytes (&die->die_tag, sizeof (die->die_tag), &ctx);
> -      md5_process_bytes (name, strlen (name) + 1, &ctx);
> +      /* Checksum the current DIE. */
> +      die_odr_checksum(die, &ctx);
>
> Since we've already gone to the trouble of getting the name of this
> DIE, it seems wasteful to have die_odr_checksum call get_AT_string
> again. Why not just pass name as a parameter?
>

Was mostly being cute and assuming it'd get removed. I'll just pass
both of them down into the function for now. If we decide later that
we want to change what's hashed we can change the function.

>> I guess you should add a function comment, plus spaces before ( everywhere
>> (and while you're at it, you can change also the is_cxx() ).  Will leave the
>> rest to Cary.
>
> Agree with the function comment and the spaces.

Oh yeah, thanks. Sorry, it's been a while.

>
>> 2013-07-22  Eric Christopher  <echristo@gmail.com>
>>
>>         * dwarf2out.c (die_odr_checksum): New function to use
>>         CHECKSUM_ macros and ULEB128 for DIE tag.
>>         (generate_type_signature): Use.
>
> This is OK with those changes. Thanks!
>

Committed thusly:

ghostwheel:~/sources/gcc> svn ci
Sending        gcc/ChangeLog
Sending        gcc/dwarf2out.c
Transmitting file data ..
Committed revision 201148.

Thanks!

-eric
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 198904)
+++ gcc/dwarf2out.c	(working copy)
@@ -6097,6 +6097,13 @@ 
   CHECKSUM_ULEB128 (0);
 }
 
+static void
+die_odr_checksum (dw_die_ref die, md5_ctx *ctx)
+{
+  CHECKSUM_ULEB128(die->die_tag);
+  CHECKSUM_STRING(get_AT_string(die, DW_AT_name));
+}
+
 #undef CHECKSUM
 #undef CHECKSUM_STRING
 #undef CHECKSUM_ATTR
@@ -6128,7 +6135,6 @@ 
   /* First, compute a signature for just the type name (and its surrounding
      context, if any.  This is stored in the type unit DIE for link-time
      ODR (one-definition rule) checking.  */
-
   if (is_cxx() && name != NULL)
     {
       md5_init_ctx (&ctx);
@@ -6137,8 +6143,8 @@ 
       if (parent != NULL)
         checksum_die_context (parent, &ctx);
 
-      md5_process_bytes (&die->die_tag, sizeof (die->die_tag), &ctx);
-      md5_process_bytes (name, strlen (name) + 1, &ctx);
+      /* Checksum the current DIE. */
+      die_odr_checksum(die, &ctx);
       md5_finish_ctx (&ctx, checksum);
 
       add_AT_data8 (type_node->root_die, DW_AT_GNU_odr_signature, &checksum[8]);