This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix non-determinism problem with DWARF output.
- From: ccoutant at google dot com (Cary Coutant)
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Aug 2013 16:41:03 -0700
- Subject: [patch] Fix non-determinism problem with DWARF output.
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.
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: