@@ -58,18 +58,17 @@ class LVIRReader final : public LVReader {
5858 // Whether to emit all linkage names, or just abstract subprograms.
5959 bool UseAllLinkageNames = true ;
6060
61- // Dependencies on external options (llc, etc).
61+ // Looking at IR generated with the '-gdwarf -gsplit-dwarf=split' the only
62+ // difference is setting the 'DICompileUnit::splitDebugFilename' to the
63+ // name of the split filename: "xxx.dwo".
6264 bool includeMinimalInlineScopes () const ;
6365 bool useAllLinkageNames () const { return UseAllLinkageNames; }
6466
6567 bool LanguageIsFortran = false ;
6668 void mapFortranLanguage (unsigned DWLang);
6769 bool moduleIsInFortran () const { return LanguageIsFortran; }
6870
69- // Generate logical debug line before prologue.
70- bool GenerateLineBeforePrologue = true ;
71-
72- // We assume a constante increase between instructions.
71+ // We assume a constant instruction-size increase between instructions.
7372 const unsigned OffsetIncrease = 4 ;
7473 void updateLineOffset () { CurrentOffset += OffsetIncrease; }
7574
@@ -79,6 +78,7 @@ class LVIRReader final : public LVReader {
7978 std::unique_ptr<DbgValueRangeTable> DbgValueRanges;
8079
8180 // Record the last assigned file index for each compile unit.
81+ // This data structure is to aid mapping DIFiles onto a DWARF-like file table.
8282 using LVIndexFiles = std::map<LVScopeCompileUnit *, size_t >;
8383 LVIndexFiles IndexFiles;
8484
@@ -99,13 +99,13 @@ class LVIRReader final : public LVReader {
9999 return FileIndex;
100100 }
101101
102- // Collect the compile unit metadata files .
102+ // Store a FileID number for each DIFile seen .
103103 using LVCompileUnitFiles = std::map<const DIFile *, size_t >;
104104 LVCompileUnitFiles CompileUnitFiles;
105105
106106 size_t getOrCreateSourceID (const DIFile *File);
107107
108- // Associate the logical elements to metadata objects .
108+ // Associate the metadata objects to logical elements .
109109 using LVMDObjects = std::map<const MDNode *, LVElement *>;
110110 LVMDObjects MDObjects;
111111
@@ -130,18 +130,23 @@ class LVIRReader final : public LVReader {
130130 return static_cast <LVType *>(getElementForSeenMD (MD));
131131 }
132132
133- // Inlined concrete scopes with its associated inlined abstract scopes.
134- // When creating abstract scopes, there is no direct information to find
133+ // Abstract scopes mapped to the associated inlined scopes.
134+ // When creating inlined scopes, there is no direct information to find
135135 // the correct lexical scope.
136- using LVInlinedScopes = std::map<LVScope *, LVScope *>;
136+ using LVScopeEntry = std::pair<LVScope *, const DILocation *>;
137+ using LVInlinedScopes = std::map<LVScopeEntry, LVScope *>;
137138 LVInlinedScopes InlinedScopes;
138139
139- void addInlinedScope (LVScope *ConcreteScope, LVScope *AbstractScope) {
140- if (InlinedScopes.find (ConcreteScope) == InlinedScopes.end ())
141- InlinedScopes.emplace (ConcreteScope, AbstractScope);
140+ void addInlinedScope (LVScope *AbstractScope, const DILocation *InlinedAt,
141+ LVScope *InlinedScope) {
142+ auto Entry = LVScopeEntry (AbstractScope, InlinedAt);
143+ if (InlinedScopes.find (Entry) == InlinedScopes.end ())
144+ InlinedScopes.emplace (Entry, InlinedScope);
142145 }
143- LVScope *getInlinedScope (LVScope *ConcreteScope) const {
144- LVInlinedScopes::const_iterator Iter = InlinedScopes.find (ConcreteScope);
146+ LVScope *getInlinedScope (LVScope *AbstractScope,
147+ const DILocation *InlinedAt) const {
148+ auto Entry = LVScopeEntry (AbstractScope, InlinedAt);
149+ LVInlinedScopes::const_iterator Iter = InlinedScopes.find (Entry);
145150 return Iter != InlinedScopes.end () ? Iter->second : nullptr ;
146151 }
147152
@@ -163,9 +168,6 @@ class LVIRReader final : public LVReader {
163168
164169 void processBasicBlocks (Function &F, const DISubprogram *SP);
165170
166- void addGlobalName (StringRef Name, LVElement *Element,
167- const DIScope *Context);
168-
169171 void addAccess (LVElement *Element, DINode::DIFlags Flags);
170172
171173 void addConstantValue (LVElement *Element, const DIExpression *DIExpr);
@@ -175,7 +177,7 @@ class LVIRReader final : public LVReader {
175177 const DIType *Ty);
176178 void addConstantValue (LVElement *Element, const APInt &Value, bool Unsigned);
177179 void addConstantValue (LVElement *Element, uint64_t Value, const DIType *Ty);
178- void addConstantValue (LVElement *Element, bool Unsigned, uint64_t Value );
180+ void addConstantValue (LVElement *Element, uint64_t Value, bool Unsigned );
179181
180182 void addString (LVElement *Element, StringRef Str);
181183
@@ -197,8 +199,6 @@ class LVIRReader final : public LVReader {
197199 bool applySubprogramDefinitionAttributes (LVScope *Function,
198200 const DISubprogram *SP,
199201 bool Minimal = false );
200- void applySubprogramAttributesToDefinition (LVScope *Function,
201- const DISubprogram *SP);
202202
203203 void constructAggregate (LVScopeAggregate *Aggregate,
204204 const DICompositeType *CTy);
@@ -210,7 +210,8 @@ class LVIRReader final : public LVReader {
210210 LVType *IndexType);
211211 void constructImportedEntity (LVElement *Element, const DIImportedEntity *IE);
212212
213- void constructLine (LVScope *Scope, const DISubprogram *SP, Instruction &I);
213+ void constructLine (LVScope *Scope, const DISubprogram *SP, Instruction &I,
214+ bool &GenerateLineBeforePrologue);
214215
215216 LVSymbol *getOrCreateMember (LVScope *Aggregate, const DIDerivedType *DT);
216217 LVSymbol *getOrCreateStaticMember (LVScope *Aggregate,
@@ -220,14 +221,15 @@ class LVIRReader final : public LVReader {
220221 LVScope *getOrCreateScope (const DIScope *Context);
221222 void constructScope (LVElement *Element, const DIScope *Context);
222223
223- LVScope *getOrCreateSubprogram (const DISubprogram *SP, bool Minimal = false );
224+ LVScope *getOrCreateSubprogram (const DISubprogram *SP);
224225 LVScope *getOrCreateSubprogram (LVScope *Function, const DISubprogram *SP,
225226 bool Minimal = false );
226227 void constructSubprogramArguments (LVScope *Function,
227228 const DITypeRefArray Args);
228229
229- LVScope *getOrCreateInlinedScope (LVScope *Parent, const DILocation *DL);
230- LVScope *getOrCreateAbstractScope (LVScope *OriginScope, const DILocation *DL);
230+ LVScope *getOrCreateAbstractScope (LVScope *Parent, const DILocation *DL);
231+ LVScope *getOrCreateInlinedScope (LVScope *AbstractScope,
232+ const DILocation *DL);
231233
232234 void constructSubrange (LVScopeArray *Array, const DISubrange *GSR,
233235 LVType *IndexType);
@@ -245,8 +247,8 @@ class LVIRReader final : public LVReader {
245247 LVSymbol *getOrCreateVariable (const DIGlobalVariableExpression *GVE);
246248 LVSymbol *getOrCreateVariable (const DIVariable *Var,
247249 const DILocation *DL = nullptr );
248- LVSymbol *getOrCreateAbstractVariable (LVSymbol *OriginSymbol,
249- const DILocation *DL);
250+ LVSymbol *getOrCreateInlinedVariable (LVSymbol *OriginSymbol,
251+ const DILocation *DL);
250252
251253 LVElement *constructElement (const DINode *DN);
252254
0 commit comments