diff mbox

Fix non-determinism problem with DWARF output.

Message ID 20130813234103.AF3B0160A98@ccoutant.mtv.corp.google.com
State New
Headers show

Commit Message

Cary Coutant Aug. 13, 2013, 11:41 p.m. UTC
This patch fixes a problem with -fdebug-types-section and with
-gsplit-dwarf where the hash computation for the type signature
and for the DW_AT_dwo_id attribute may produce results that differ
from run to run. For dw_val_class_vec values (e.g., the const value
of a small struct), both hash computations use the value of a pointer
instead of the actual data.

Bootstrapped, tested, and committed to trunk.

-cary


2013-08-13  Cary Coutant  <ccoutant@google.com>

gcc/
	* dwarf2out.c (CHECKSUM_BLOCK): New macro.
	(attr_checksum): Hash vector contents instead of pointer.
	(attr_checksum_ordered): Likewise.
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 201711)
+++ dwarf2out.c	(working copy)
@@ -5432,6 +5432,7 @@  pop_compile_unit (dw_die_ref old_unit)
 }
 
 #define CHECKSUM(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
+#define CHECKSUM_BLOCK(FOO, SIZE) md5_process_bytes ((FOO), (SIZE), ctx)
 #define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
 
 /* Calculate the checksum of a location expression.  */
@@ -5475,7 +5476,9 @@  attr_checksum (dw_attr_ref at, struct md
       CHECKSUM (at->dw_attr_val.v.val_double);
       break;
     case dw_val_class_vec:
-      CHECKSUM (at->dw_attr_val.v.val_vec);
+      CHECKSUM_BLOCK (at->dw_attr_val.v.val_vec.array,
+		      (at->dw_attr_val.v.val_vec.length
+		       * at->dw_attr_val.v.val_vec.elt_size));
       break;
     case dw_val_class_flag:
       CHECKSUM (at->dw_attr_val.v.val_flag);
@@ -5550,10 +5553,12 @@  die_checksum (dw_die_ref die, struct md5
 }
 
 #undef CHECKSUM
+#undef CHECKSUM_BLOCK
 #undef CHECKSUM_STRING
 
 /* For DWARF-4 types, include the trailing NULL when checksumming strings.  */
 #define CHECKSUM(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
+#define CHECKSUM_BLOCK(FOO, SIZE) md5_process_bytes ((FOO), (SIZE), ctx)
 #define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO) + 1, ctx)
 #define CHECKSUM_SLEB128(FOO) checksum_sleb128 ((FOO), ctx)
 #define CHECKSUM_ULEB128(FOO) checksum_uleb128 ((FOO), ctx)
@@ -5749,8 +5754,11 @@  attr_checksum_ordered (enum dwarf_tag ta
 
     case dw_val_class_vec:
       CHECKSUM_ULEB128 (DW_FORM_block);
-      CHECKSUM_ULEB128 (sizeof (at->dw_attr_val.v.val_vec));
-      CHECKSUM (at->dw_attr_val.v.val_vec);
+      CHECKSUM_ULEB128 (at->dw_attr_val.v.val_vec.length
+			* at->dw_attr_val.v.val_vec.elt_size);
+      CHECKSUM_BLOCK (at->dw_attr_val.v.val_vec.array,
+		      (at->dw_attr_val.v.val_vec.length
+		       * at->dw_attr_val.v.val_vec.elt_size));
       break;
 
     case dw_val_class_flag: