Revert "Revert "Debug Info: Type Units: Simplify type hashing using IR-provided unique names.""

This reverts commit r198398, thus reapplying r198397.

I had accidentally introduced an endianness issue when applying the hash
to the type unit. Using support::ulittle64_t in the reinterpret_cast in
addDwarfTypeUnitType fixes this issue.

Original commit message:

Debug Info: Type Units: Simplify type hashing using IR-provided unique
names.

What's good for LTO metadata size problems ought to be good for non-LTO
debug info size too, so let's rely on the same uniqueness in both cases.
If it's insufficient for non-LTO for whatever reason (since we now won't
be uniquing CU-local types or any C types - but these are likely to not
be the most significant contributors to type bloat) we should consider a
frontend solution that'll help both LTO and non-LTO alike, rather than
using DWARF-level DIE-hashing that only helps non-LTO debug info size.

It's also much simpler this way and benefits C++ even more since we can
deduplicate lexically separate definitions of the same C++ type since
they have the same mangled name.

llvm-svn: 198436
diff --git a/llvm/test/DebugInfo/X86/generate-odr-hash.ll b/llvm/test/DebugInfo/X86/generate-odr-hash.ll
index 28c4295..57b6b06 100644
--- a/llvm/test/DebugInfo/X86/generate-odr-hash.ll
+++ b/llvm/test/DebugInfo/X86/generate-odr-hash.ll
@@ -1,6 +1,6 @@
 ; REQUIRES: object-emission
 
-; RUN: llc %s -o %t -filetype=obj -O0 -generate-type-units -generate-odr-hash -mtriple=x86_64-unknown-linux-gnu
+; RUN: llc %s -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu
 ; RUN: llvm-dwarfdump %t | FileCheck %s
 
 ; Generated from:
@@ -46,18 +46,31 @@
 ; CHECK-LABEL: .debug_info contents:
 ; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]]
 
+; CHECK: DW_TAG_structure_type
+; CHECK-NEXT: DW_AT_signature
+; CHECK: DW_TAG_class_type
+; CHECK-NEXT: DW_AT_signature
+
+; Ensure the CU-local type 'walrus' is not placed in a type unit.
+; CHECK: DW_TAG_structure_type
+; CHECK-NEXT: debug_str{{.*}}"walrus"
+; CHECK-NEXT: DW_AT_byte_size
+; CHECK-NEXT: DW_AT_decl_file
+; CHECK-NEXT: DW_AT_decl_line
+
 ; CHECK-LABEL: .debug_types contents:
 
 ; Check that we generate a hash for bar and the value.
-; CHECK-LABEL: type_signature = 0x6a7ee3d400662e88
-; CHECK: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x200520c0d5b90eff)
+; CHECK-NOT: type_signature
+; CHECK-LABEL: type_signature = 0x1d02f3be30cc5688
 ; CHECK: DW_TAG_structure_type
 ; CHECK-NEXT: debug_str{{.*}}"bar"
 
 
 ; Check that we generate a hash for fluffy and the value.
-; CHECK-LABEL: type_signature = 0x139b2e1ea94afec7
-; CHECK: DW_AT_GNU_odr_signature [DW_FORM_data8]   (0x9a0124d5a0c21c52)
+; CHECK-NOT: type_signature
+; CHECK-LABEL: type_signature = 0xb04af47397402e77
+; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8]   (0x9a0124d5a0c21c52)
 ; CHECK: DW_TAG_namespace
 ; CHECK-NEXT: debug_str{{.*}}"echidna"
 ; CHECK: DW_TAG_namespace
@@ -67,34 +80,22 @@
 ; CHECK: DW_TAG_class_type
 ; CHECK-NEXT: debug_str{{.*}}"fluffy"
 
-; namespace and won't violate any ODR-ness.
-; CHECK-LABEL: type_signature = 0xc0d031d6449dbca7
-; CHECK: DW_TAG_type_unit
-; CHECK-NOT: NULL
-; We emit no hash for walrus since the type is contained in an anonymous
-; CHECK-NOT: DW_AT_GNU_odr_signature
-; CHECK: DW_TAG_structure_type
-; CHECK-NEXT: debug_str{{.*}}"walrus"
-; CHECK-NEXT: DW_AT_byte_size
-; CHECK-NEXT: DW_AT_decl_file
-; CHECK-NEXT: DW_AT_decl_line
-; CHECK: DW_TAG_subprogram
-
 ; Check that we generate a hash for wombat and the value, but not for the
 ; anonymous type contained within.
-; CHECK-LABEL: type_signature = 0x73776f130648b986
-; CHECK: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)
+; CHECK-NOT: type_signature
+; CHECK-LABEL: type_signature = 0xfd756cee88f8a118
+; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)
 ; CHECK: DW_TAG_structure_type
 ; CHECK-NEXT: debug_str{{.*}}"wombat"
 
-; CHECK-LABEL: type_signature = 0xbf6fc40e82583d7c
+; CHECK-NOT: type_signature
+; CHECK-LABEL: type_signature = 0xe94f6d3843e62d6b
 ; CHECK: DW_TAG_type_unit
 ; CHECK-NOT: NULL
-; Check that we generate no ODR hash for the anonymous type nested inside 'wombat'
 ; CHECK-NOT: DW_AT_GNU_odr_signature
 ; CHECK: DW_TAG_structure_type
 ; The signature for the outer 'wombat' type
-; CHECK: DW_AT_signature [DW_FORM_ref_sig8] (0x73776f130648b986)
+; CHECK: DW_AT_signature [DW_FORM_ref_sig8] (0xfd756cee88f8a118)
 ; CHECK: DW_TAG_structure_type
 ; CHECK-NOT: DW_AT_name
 ; CHECK-NOT: DW_AT_GNU_odr_signature
@@ -107,18 +108,16 @@
 ; Don't emit pubtype entries for type DIEs in the compile unit that just indirect to a type unit.
 ; CHECK-NEXT: unit_size = [[CU_SIZE]]
 ; CHECK-NEXT: Offset Name
+; CHECK-NEXT: "walrus"
 ; Type unit for 'bar'
-; CHECK-NEXT: unit_size = 0x0000002b
+; CHECK-NEXT: unit_size = 0x00000023
 ; CHECK-NEXT: Offset Name
 ; CHECK-NEXT: "bar"
-; CHECK-NEXT: unit_size = 0x00000065
+; CHECK-NEXT: unit_size = 0x0000005d
 ; CHECK-NEXT: Offset Name
 ; CHECK-NEXT: "int"
 ; CHECK-NEXT: "echidna::capybara::mongoose::fluffy"
-; CHECK-NEXT: unit_size = 0x0000003b
-; CHECK-NEXT: Offset Name
-; CHECK-NEXT: "walrus"
-; CHECK-NEXT: unit_size = 0x00000042
+; CHECK-NEXT: unit_size = 0x0000003a
 ; CHECK-NEXT: Offset Name
 ; CHECK-NEXT: "wombat"
 ; CHECK-NEXT: unit_size = 0x0000004b