1 From 2836e92ea557be53fcd91e38cb05a989ad0167e9 Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <mh@glandium.org>
3 Date: Wed, 8 Mar 2023 14:44:58 +0900
4 Subject: [PATCH] Revert "Split getCompileUnitFor{Data,Code}Address."
6 This reverts commit 02e8eb1a438bdb1dc9a97aea75a8c9c748048039, which
7 applies on top of cead4eceb01b935fae07bf4a7e91911b344d2fec, that we
10 .../llvm/DebugInfo/DWARF/DWARFContext.h | 11 +--------
11 llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 23 ++++++++-----------
12 2 files changed, 11 insertions(+), 23 deletions(-)
14 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
15 index 4eba79a7215f..df903b967ef6 100644
16 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
17 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
18 @@ -445,16 +445,7 @@ public:
20 /// TODO: change input parameter from "uint64_t Address"
21 /// into "SectionedAddress Address"
22 - DWARFCompileUnit *getCompileUnitForCodeAddress(uint64_t Address);
24 - /// Return the compile unit which contains data with the provided address.
25 - /// Note: This is more expensive than `getCompileUnitForAddress`, as if
26 - /// `Address` isn't found in the CU ranges (which is cheap), then it falls
27 - /// back to an expensive O(n) walk of all CU's looking for data that spans the
29 - /// TODO: change input parameter from "uint64_t Address" into
30 - /// "SectionedAddress Address"
31 - DWARFCompileUnit *getCompileUnitForDataAddress(uint64_t Address);
32 + DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address);
34 /// Returns whether CU/TU should be populated manually. TU Index populated
35 /// manually only for DWARF5.
36 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
37 index f648ef8ff770..dd86144d16e0 100644
38 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
39 +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
40 @@ -1118,17 +1118,14 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint64_t Offset) {
41 NormalUnits.getUnitForOffset(Offset));
44 -DWARFCompileUnit *DWARFContext::getCompileUnitForCodeAddress(uint64_t Address) {
45 - uint64_t CUOffset = getDebugAranges()->findAddress(Address);
46 - return getCompileUnitForOffset(CUOffset);
49 -DWARFCompileUnit *DWARFContext::getCompileUnitForDataAddress(uint64_t Address) {
50 +DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
51 + // First, get the offset of the compile unit.
52 uint64_t CUOffset = getDebugAranges()->findAddress(Address);
53 + // Retrieve the compile unit.
54 if (DWARFCompileUnit *OffsetCU = getCompileUnitForOffset(CUOffset))
57 - // Global variables are often missed by the above search, for one of two
58 + // Global variables are often not found by the above search, for one of two
60 // 1. .debug_aranges may not include global variables. On clang, it seems we
61 // put the globals in the aranges, but this isn't true for gcc.
62 @@ -1149,7 +1146,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForDataAddress(uint64_t Address) {
63 DWARFContext::DIEsForAddress DWARFContext::getDIEsForAddress(uint64_t Address) {
64 DIEsForAddress Result;
66 - DWARFCompileUnit *CU = getCompileUnitForCodeAddress(Address);
67 + DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
71 @@ -1300,7 +1297,7 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
73 DWARFContext::getLocalsForAddress(object::SectionedAddress Address) {
74 std::vector<DILocal> Result;
75 - DWARFCompileUnit *CU = getCompileUnitForCodeAddress(Address.Address);
76 + DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
80 @@ -1313,7 +1310,7 @@ DWARFContext::getLocalsForAddress(object::SectionedAddress Address) {
81 DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
82 DILineInfoSpecifier Spec) {
84 - DWARFCompileUnit *CU = getCompileUnitForCodeAddress(Address.Address);
85 + DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
89 @@ -1334,7 +1331,7 @@ DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
91 DWARFContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
93 - DWARFCompileUnit *CU = getCompileUnitForDataAddress(Address.Address);
94 + DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
98 @@ -1349,7 +1346,7 @@ DWARFContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
99 DILineInfoTable DWARFContext::getLineInfoForAddressRange(
100 object::SectionedAddress Address, uint64_t Size, DILineInfoSpecifier Spec) {
101 DILineInfoTable Lines;
102 - DWARFCompileUnit *CU = getCompileUnitForCodeAddress(Address.Address);
103 + DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
107 @@ -1405,7 +1402,7 @@ DWARFContext::getInliningInfoForAddress(object::SectionedAddress Address,
108 DILineInfoSpecifier Spec) {
109 DIInliningInfo InliningInfo;
111 - DWARFCompileUnit *CU = getCompileUnitForCodeAddress(Address.Address);
112 + DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);