Skip to content

Commit b0c8d99

Browse files
committed
Address review comments
1 parent f9a78ea commit b0c8d99

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfFile.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ struct RangeSpanList {
5454
};
5555

5656
/// Tracks abstract and concrete DIEs for debug info entities of a certain type.
57-
template <typename DINodeT, typename DbgEntityT> class DINodeInfoHolder {
57+
template <typename DINodeT, typename DbgEntityT> class DINodeMap {
5858
public:
5959
using AbstractMapT = DenseMap<const DINodeT *, DIE *>;
60-
using ConcreteMapT =
61-
DenseMap<const DINodeT *, SmallDenseMap<const DbgEntityT *, DIE *, 2>>;
60+
using EntityMapT = SmallDenseMap<const DbgEntityT *, DIE *, 2>;
6261

6362
private:
6463
AbstractMapT AbstractMap;
65-
ConcreteMapT ConcreteMap;
64+
DenseMap<const DINodeT *, EntityMapT> ConcreteMap;
6665

6766
public:
6867
void insertAbstractDIE(const DINodeT *N, DIE *D) {
@@ -84,23 +83,21 @@ template <typename DINodeT, typename DbgEntityT> class DINodeInfoHolder {
8483

8584
DIE *getAbstractDIE(const DINodeT *N) const { return AbstractMap.lookup(N); }
8685

87-
std::optional<
88-
std::reference_wrapper<const typename ConcreteMapT::mapped_type>>
89-
getConcreteDIEs(const DINodeT *N) const {
90-
if (auto I = ConcreteMap.find(N); I != ConcreteMap.end())
91-
return std::make_optional(std::ref(I->second));
92-
return std::nullopt;
86+
const EntityMapT *getConcreteDIEs(const DINodeT *N) const {
87+
if (const auto I = ConcreteMap.find(N); I != ConcreteMap.end())
88+
return &I->second;
89+
return nullptr;
9390
}
9491

9592
DIE *getConcreteDIE(const DINodeT *N, const DbgEntityT *E) const {
9693
if (auto I = getConcreteDIEs(N))
97-
return I->get().lookup(E);
94+
return I->lookup(E);
9895
return nullptr;
9996
}
10097

10198
DIE *getAnyConcreteDIE(const DINodeT *N) const {
102-
if (auto I = getConcreteDIEs(N))
103-
return I->get().empty() ? nullptr : I->get().begin()->second;
99+
if (auto *I = getConcreteDIEs(N))
100+
return I->empty() ? nullptr : I->begin()->second;
104101
return nullptr;
105102
}
106103

@@ -109,7 +106,6 @@ template <typename DINodeT, typename DbgEntityT> class DINodeInfoHolder {
109106
DIE *getDIE(const DINodeT *N) const {
110107
if (DIE *D = getAbstractDIE(N))
111108
return D;
112-
113109
return getAnyConcreteDIE(N);
114110
}
115111

@@ -120,13 +116,21 @@ template <typename DINodeT, typename DbgEntityT> class DINodeInfoHolder {
120116
/// These DIEs can be shared across CUs, that is why we keep the map here
121117
/// instead of in DwarfCompileUnit.
122118
class DwarfInfoHolder {
119+
public:
120+
using LVMapT = DINodeMap<DILocalVariable, DbgVariable>;
121+
using LabelMapT = DINodeMap<DILabel, DbgLabel>;
122+
using AbstractEntityMapT =
123+
DenseMap<const DINode *, std::unique_ptr<DbgEntity>>;
124+
using AbstractScopeMapT = DenseMap<const DILocalScope *, DIE *>;
125+
126+
private:
123127
/// DIEs of local DbgVariables.
124-
DINodeInfoHolder<DILocalVariable, DbgVariable> LVHolder;
128+
LVMapT LVMap;
125129
/// DIEs of labels.
126-
DINodeInfoHolder<DILabel, DbgLabel> LabelHolder;
127-
DenseMap<const DINode *, std::unique_ptr<DbgEntity>> AbstractEntities;
130+
LabelMapT LabelMap;
131+
AbstractEntityMapT AbstractEntities;
128132
// List of abstract local scopes (either DISubprogram or DILexicalBlock).
129-
DenseMap<const DILocalScope *, DIE *> AbstractLocalScopeDIEs;
133+
AbstractScopeMapT AbstractLocalScopeDIEs;
130134
/// Keeps track of abstract subprograms to populate them only once.
131135
// FIXME: merge creation and population of abstract scopes.
132136
SmallPtrSet<const DISubprogram *, 8> FinalizedAbstractSubprograms;
@@ -154,11 +158,11 @@ class DwarfInfoHolder {
154158
return D;
155159
}
156160

157-
auto &getLVs() { return LVHolder; }
158-
auto &getLVs() const { return LVHolder; }
161+
LVMapT &getLVs() { return LVMap; }
162+
const LVMapT &getLVs() const { return LVMap; }
159163

160-
auto &getLabels() { return LabelHolder; }
161-
auto &getLabels() const { return LabelHolder; }
164+
LabelMapT &getLabels() { return LabelMap; }
165+
const LabelMapT &getLabels() const { return LabelMap; }
162166

163167
/// For a global variable, returns DIE of the variable.
164168
///
@@ -171,13 +175,9 @@ class DwarfInfoHolder {
171175
return getDIE(V);
172176
}
173177

174-
DenseMap<const DILocalScope *, DIE *> &getAbstractScopeDIEs() {
175-
return AbstractLocalScopeDIEs;
176-
}
178+
AbstractScopeMapT &getAbstractScopeDIEs() { return AbstractLocalScopeDIEs; }
177179

178-
DenseMap<const DINode *, std::unique_ptr<DbgEntity>> &getAbstractEntities() {
179-
return AbstractEntities;
180-
}
180+
AbstractEntityMapT &getAbstractEntities() { return AbstractEntities; }
181181

182182
auto &getFinalizedAbstractSubprograms() {
183183
return FinalizedAbstractSubprograms;

0 commit comments

Comments
 (0)