diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-12-14 07:42:00 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-12-14 07:42:00 +0000 |
commit | cd49eb3fa17f9f19cfffa9437eb4db10dc11d43c (patch) | |
tree | 917c58a1914641e214cd77855d36c2d620ca5351 /tools | |
parent | ea8e65febc2fa4d560b36bc503ceab409f942582 (diff) |
[llvm-dwp] Deduplicate type units
It's O(N^2) because it does a simple walk through the existing types to
find duplicates, but that will be fixed in a follow-up commit to use a
mapping data structure of some kind.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-dwp/llvm-dwp.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp index 5d95a751f71..5fb1c52330f 100644 --- a/tools/llvm-dwp/llvm-dwp.cpp +++ b/tools/llvm-dwp/llvm-dwp.cpp @@ -148,24 +148,30 @@ static void addAllTypes(MCStreamer &Out, uint32_t Offset = 0; DataExtractor Data(Types, true, 0); while (Data.isValidOffset(Offset)) { - TypeIndexEntries.push_back(CUEntry); - auto &Entry = TypeIndexEntries.back(); + UnitIndexEntry Entry = CUEntry; // Zero out the debug_info contribution Entry.Contributions[0] = {}; auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO]; - C.Offset = TypesOffset + Offset; + C.Offset = TypesOffset; auto PrevOffset = Offset; // Length of the unit, including the 4 byte length field. C.Length = Data.getU32(&Offset) + 4; - Out.EmitBytes(Types.substr(Offset - 4, C.Length)); - TypesOffset += C.Length; - Data.getU16(&Offset); // Version Data.getU32(&Offset); // Abbrev offset Data.getU8(&Offset); // Address size Entry.Signature = Data.getU64(&Offset); Offset = PrevOffset + C.Length; + + if (any_of(TypeIndexEntries, [&](const UnitIndexEntry &E) { + return E.Signature == Entry.Signature; + })) + continue; + + Out.EmitBytes(Types.substr(PrevOffset, C.Length)); + TypesOffset += C.Length; + + TypeIndexEntries.push_back(Entry); } } |