summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-26 16:26:41 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-26 16:26:41 +0000
commitf95477d11fde13740664ef5a89dd5180d20ec121 (patch)
tree66af5ce09173b89d487336553b35848599fb4ea6 /lib/CodeGen
parentd9ced7112e85a566999276099aef5f2ddf6735b7 (diff)
downloadllvm-f95477d11fde13740664ef5a89dd5180d20ec121.tar.gz
llvm-f95477d11fde13740664ef5a89dd5180d20ec121.tar.bz2
llvm-f95477d11fde13740664ef5a89dd5180d20ec121.tar.xz
DwarfDebug: Minor refactoring around type unit construction
Sinking addition of the declaration attribute down to where the signature is added. So that if the signature is not added neither is the declaration attribute (this will come in handy when aborting type unit construction to instead emit the type into the CU directly in some cases) Pull out type unit identifier hashing just to simplify the function a little, it'll be getting longer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp31
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.cpp6
2 files changed, 21 insertions, 16 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 32f7f42c5d..cbd2eb6ca4 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2486,15 +2486,20 @@ MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) {
return &SplitTypeUnitFileTable;
}
+static uint64_t makeTypeSignature(StringRef Identifier) {
+ MD5 Hash;
+ Hash.update(Identifier);
+ // ... take the least significant 8 bytes and return those. Our MD5
+ // implementation always returns its results in little endian, swap bytes
+ // appropriately.
+ MD5::MD5Result Result;
+ Hash.final(Result);
+ return *reinterpret_cast<support::ulittle64_t *>(Result + 8);
+}
+
void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
StringRef Identifier, DIE &RefDie,
DICompositeType CTy) {
- // Flag the type unit reference as a declaration so that if it contains
- // members (implicit special members, static data member definitions, member
- // declarations for definitions in this CU, etc) consumers don't get confused
- // and think this is a full definition.
- CU.addFlag(RefDie, dwarf::DW_AT_declaration);
-
const DwarfTypeUnit *&TU = DwarfTypeUnits[CTy];
if (TU) {
CU.addDIETypeSignature(RefDie, *TU);
@@ -2512,27 +2517,21 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
NewTU.addUInt(*UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
CU.getLanguage());
- MD5 Hash;
- Hash.update(Identifier);
- // ... take the least significant 8 bytes and return those. Our MD5
- // implementation always returns its results in little endian, swap bytes
- // appropriately.
- MD5::MD5Result Result;
- Hash.final(Result);
- uint64_t Signature = *reinterpret_cast<support::ulittle64_t *>(Result + 8);
+ uint64_t Signature = makeTypeSignature(Identifier);
NewTU.setTypeSignature(Signature);
+
if (useSplitDwarf())
NewTU.setSkeleton(constructSkeletonTU(NewTU));
else
CU.applyStmtList(*UnitDie);
- NewTU.setType(NewTU.createTypeDIE(CTy));
-
NewTU.initSection(
useSplitDwarf()
? Asm->getObjFileLowering().getDwarfTypesDWOSection(Signature)
: Asm->getObjFileLowering().getDwarfTypesSection(Signature));
+ NewTU.setType(NewTU.createTypeDIE(CTy));
+
CU.addDIETypeSignature(RefDie, NewTU);
}
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 326243278e..f3cd80027d 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -360,6 +360,12 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry) {
}
void DwarfUnit::addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type) {
+ // Flag the type unit reference as a declaration so that if it contains
+ // members (implicit special members, static data member definitions, member
+ // declarations for definitions in this CU, etc) consumers don't get confused
+ // and think this is a full definition.
+ addFlag(Die, dwarf::DW_AT_declaration);
+
Die.addValue(dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
new (DIEValueAllocator) DIETypeSignature(Type));
}