summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-08-15 15:54:43 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-08-15 15:54:43 +0000
commite1c30f74f7b974daed175db8a73d83ef659c1162 (patch)
treecee0a3deffb7a4501c90a7bc5090e39604e97e1c /llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
parenteb2f5f3256f45696c933e83e376c0848e8fea943 (diff)
downloadbcm5719-llvm-e1c30f74f7b974daed175db8a73d83ef659c1162.tar.gz
bcm5719-llvm-e1c30f74f7b974daed175db8a73d83ef659c1162.zip
[llvm-dwarfdump] - Refactor section name/uniqueness gathering.
As was requested in D36313 thread, with this patch section names and uniqueness calculated once, and not every time when a range is dumped. Differential revision: https://reviews.llvm.org/D36740 llvm-svn: 310923
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDie.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDie.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 6b557b9e265..7086535c334 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -57,18 +57,9 @@ static void dumpRanges(const DWARFObject &Obj, raw_ostream &OS,
const DWARFAddressRangesVector &Ranges,
unsigned AddressSize, unsigned Indent,
const DIDumpOptions &DumpOpts) {
- StringMap<unsigned> SectionAmountMap;
- std::vector<StringRef> SectionNames;
- if (Obj.getFile() && !DumpOpts.Brief) {
- for (const SectionRef &Section : Obj.getFile()->sections()) {
- StringRef Name;
- if (Section.getName(Name))
- Name = "<error>";
-
- ++SectionAmountMap[Name];
- SectionNames.push_back(Name);
- }
- }
+ ArrayRef<SectionName> SectionNames;
+ if (!DumpOpts.Brief)
+ SectionNames = Obj.getSectionNames();
for (size_t I = 0; I < Ranges.size(); ++I) {
const DWARFAddressRange &R = Ranges[I];
@@ -81,13 +72,11 @@ static void dumpRanges(const DWARFObject &Obj, raw_ostream &OS,
if (SectionNames.empty() || R.SectionIndex == -1ULL)
continue;
- StringRef Name = R.SectionIndex < SectionNames.size()
- ? SectionNames[R.SectionIndex]
- : "<error>";
- OS << format(" \"%s\"", Name.str().c_str());
+ StringRef Name = SectionNames[R.SectionIndex].Name;
+ OS << " \"" << Name << '\"';
- // Print section index if there is more than one section with this name.
- if (SectionAmountMap[Name] > 1)
+ // Print section index if name is not unique.
+ if (!SectionNames[R.SectionIndex].IsNameUnique)
OS << format(" [%u]", R.SectionIndex);
}
}
OpenPOWER on IntegriCloud