Skip to content

Commit 2636fd6

Browse files
authored
Merge branch 'main' into users/kparzysz/spr/a04-atomic-one
2 parents b27c7cb + b668b64 commit 2636fd6

File tree

27 files changed

+4084
-4051
lines changed

27 files changed

+4084
-4051
lines changed

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,10 @@ void CompilerInvocation::setDefaultPredefinitions() {
16561656
fortranOptions.predefinitions.emplace_back("__64BIT__", "1");
16571657
}
16581658
break;
1659+
case llvm::Triple::ArchType::aarch64:
1660+
fortranOptions.predefinitions.emplace_back("__aarch64__", "1");
1661+
fortranOptions.predefinitions.emplace_back("__aarch64", "1");
1662+
break;
16591663
}
16601664
}
16611665

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! Test predefined macro for AArch64
2+
3+
! REQUIRES: aarch64-registered-target
4+
5+
! RUN: %flang_fc1 -triple aarch64-unknown-linux-gnu -cpp -E %s | FileCheck %s
6+
7+
! CHECK: integer :: var1 = 1
8+
! CHECK: integer :: var2 = 1
9+
10+
#if __aarch64__
11+
integer :: var1 = __aarch64__
12+
#endif
13+
#if __aarch64
14+
integer :: var2 = __aarch64
15+
#endif
16+
end program

llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class LVSplitContext final {
5656

5757
/// The logical reader owns of all the logical elements created during
5858
/// the debug information parsing. For its creation it uses a specific
59-
/// bump allocator for each type of logical element.
59+
/// bump allocator for each type of logical element.
6060
class LVReader {
6161
LVBinaryType BinaryType;
6262

@@ -122,7 +122,24 @@ class LVReader {
122122

123123
#undef LV_OBJECT_ALLOCATOR
124124

125+
// Scopes with ranges for current compile unit. It is used to find a line
126+
// giving its exact or closest address. To support comdat functions, all
127+
// addresses for the same section are recorded in the same map.
128+
using LVSectionRanges = std::map<LVSectionIndex, std::unique_ptr<LVRange>>;
129+
LVSectionRanges SectionRanges;
130+
125131
protected:
132+
// Current elements during the processing of a DIE/MDNode.
133+
LVElement *CurrentElement = nullptr;
134+
LVScope *CurrentScope = nullptr;
135+
LVSymbol *CurrentSymbol = nullptr;
136+
LVType *CurrentType = nullptr;
137+
LVLine *CurrentLine = nullptr;
138+
LVOffset CurrentOffset = 0;
139+
140+
// Address ranges collected for current DIE/MDNode/AST Node.
141+
std::vector<LVAddressRange> CurrentRanges;
142+
126143
LVScopeRoot *Root = nullptr;
127144
std::string InputFilename;
128145
std::string FileFormatName;
@@ -133,11 +150,18 @@ class LVReader {
133150
// Only for ELF format. The CodeView is handled in a different way.
134151
LVSectionIndex DotTextSectionIndex = UndefinedSectionIndex;
135152

153+
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope);
154+
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope,
155+
LVAddress LowerAddress, LVAddress UpperAddress);
156+
LVRange *getSectionRanges(LVSectionIndex SectionIndex);
157+
136158
// Record Compilation Unit entry.
137159
void addCompileUnitOffset(LVOffset Offset, LVScopeCompileUnit *CompileUnit) {
138160
CompileUnits.emplace(Offset, CompileUnit);
139161
}
140162

163+
LVElement *createElement(dwarf::Tag Tag);
164+
141165
// Create the Scope Root.
142166
virtual Error createScopes() {
143167
Root = createScopeRoot();

llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ class LVBinaryReader : public LVReader {
9393
SectionAddresses.emplace(Section.getAddress(), Section);
9494
}
9595

96-
// Scopes with ranges for current compile unit. It is used to find a line
97-
// giving its exact or closest address. To support comdat functions, all
98-
// addresses for the same section are recorded in the same map.
99-
using LVSectionRanges = std::map<LVSectionIndex, std::unique_ptr<LVRange>>;
100-
LVSectionRanges SectionRanges;
101-
10296
// Image base and virtual address for Executable file.
10397
uint64_t ImageBaseAddress = 0;
10498
uint64_t VirtualAddress = 0;
@@ -179,11 +173,6 @@ class LVBinaryReader : public LVReader {
179173
Expected<std::pair<LVSectionIndex, object::SectionRef>>
180174
getSection(LVScope *Scope, LVAddress Address, LVSectionIndex SectionIndex);
181175

182-
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope);
183-
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope,
184-
LVAddress LowerAddress, LVAddress UpperAddress);
185-
LVRange *getSectionRanges(LVSectionIndex SectionIndex);
186-
187176
void includeInlineeLines(LVSectionIndex SectionIndex, LVScope *Function);
188177

189178
Error createInstructions();

llvm/include/llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,13 @@ class LVDWARFReader final : public LVBinaryReader {
3939
LVAddress CUBaseAddress = 0;
4040
LVAddress CUHighAddress = 0;
4141

42-
// Current elements during the processing of a DIE.
43-
LVElement *CurrentElement = nullptr;
44-
LVScope *CurrentScope = nullptr;
45-
LVSymbol *CurrentSymbol = nullptr;
46-
LVType *CurrentType = nullptr;
47-
LVOffset CurrentOffset = 0;
4842
LVOffset CurrentEndOffset = 0;
4943

5044
// In DWARF v4, the files are 1-indexed.
5145
// In DWARF v5, the files are 0-indexed.
5246
// The DWARF reader expects the indexes as 1-indexed.
5347
bool IncrementFileIndex = false;
5448

55-
// Address ranges collected for current DIE.
56-
std::vector<LVAddressRange> CurrentRanges;
57-
5849
// Symbols with locations for current compile unit.
5950
LVSymbols SymbolsWithLocations;
6051

@@ -82,7 +73,6 @@ class LVDWARFReader final : public LVBinaryReader {
8273

8374
void mapRangeAddress(const object::ObjectFile &Obj) override;
8475

85-
LVElement *createElement(dwarf::Tag Tag);
8676
void traverseDieAndChildren(DWARFDie &DIE, LVScope *Parent,
8777
DWARFDie &SkeletonDie);
8878
// Process the attributes for the given DIE.

llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,253 @@ StringRef LVReader::getFilename(LVObject *Object, size_t Index) const {
194194
return CompileUnit ? CompileUnit->getFilename(Index) : StringRef();
195195
}
196196

197+
void LVReader::addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope) {
198+
LVRange *ScopesWithRanges = getSectionRanges(SectionIndex);
199+
ScopesWithRanges->addEntry(Scope);
200+
}
201+
202+
void LVReader::addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope,
203+
LVAddress LowerAddress, LVAddress UpperAddress) {
204+
LVRange *ScopesWithRanges = getSectionRanges(SectionIndex);
205+
ScopesWithRanges->addEntry(Scope, LowerAddress, UpperAddress);
206+
}
207+
208+
LVRange *LVReader::getSectionRanges(LVSectionIndex SectionIndex) {
209+
// Check if we already have a mapping for this section index.
210+
LVSectionRanges::iterator IterSection = SectionRanges.find(SectionIndex);
211+
if (IterSection == SectionRanges.end())
212+
IterSection =
213+
SectionRanges.emplace(SectionIndex, std::make_unique<LVRange>()).first;
214+
LVRange *Range = IterSection->second.get();
215+
assert(Range && "Range is null.");
216+
return Range;
217+
}
218+
219+
LVElement *LVReader::createElement(dwarf::Tag Tag) {
220+
CurrentScope = nullptr;
221+
CurrentSymbol = nullptr;
222+
CurrentType = nullptr;
223+
CurrentRanges.clear();
224+
225+
LLVM_DEBUG(
226+
{ dbgs() << "\n[createElement] " << dwarf::TagString(Tag) << "\n"; });
227+
228+
if (!options().getPrintSymbols()) {
229+
switch (Tag) {
230+
// As the command line options did not specify a request to print
231+
// logical symbols (--print=symbols or --print=all or --print=elements),
232+
// skip its creation.
233+
case dwarf::DW_TAG_formal_parameter:
234+
case dwarf::DW_TAG_unspecified_parameters:
235+
case dwarf::DW_TAG_member:
236+
case dwarf::DW_TAG_variable:
237+
case dwarf::DW_TAG_inheritance:
238+
case dwarf::DW_TAG_constant:
239+
case dwarf::DW_TAG_call_site_parameter:
240+
case dwarf::DW_TAG_GNU_call_site_parameter:
241+
return nullptr;
242+
default:
243+
break;
244+
}
245+
}
246+
247+
switch (Tag) {
248+
// Types.
249+
case dwarf::DW_TAG_base_type:
250+
CurrentType = createType();
251+
CurrentType->setIsBase();
252+
if (options().getAttributeBase())
253+
CurrentType->setIncludeInPrint();
254+
return CurrentType;
255+
case dwarf::DW_TAG_const_type:
256+
CurrentType = createType();
257+
CurrentType->setIsConst();
258+
CurrentType->setName("const");
259+
return CurrentType;
260+
case dwarf::DW_TAG_enumerator:
261+
CurrentType = createTypeEnumerator();
262+
return CurrentType;
263+
case dwarf::DW_TAG_imported_declaration:
264+
CurrentType = createTypeImport();
265+
CurrentType->setIsImportDeclaration();
266+
return CurrentType;
267+
case dwarf::DW_TAG_imported_module:
268+
CurrentType = createTypeImport();
269+
CurrentType->setIsImportModule();
270+
return CurrentType;
271+
case dwarf::DW_TAG_pointer_type:
272+
CurrentType = createType();
273+
CurrentType->setIsPointer();
274+
CurrentType->setName("*");
275+
return CurrentType;
276+
case dwarf::DW_TAG_ptr_to_member_type:
277+
CurrentType = createType();
278+
CurrentType->setIsPointerMember();
279+
CurrentType->setName("*");
280+
return CurrentType;
281+
case dwarf::DW_TAG_reference_type:
282+
CurrentType = createType();
283+
CurrentType->setIsReference();
284+
CurrentType->setName("&");
285+
return CurrentType;
286+
case dwarf::DW_TAG_restrict_type:
287+
CurrentType = createType();
288+
CurrentType->setIsRestrict();
289+
CurrentType->setName("restrict");
290+
return CurrentType;
291+
case dwarf::DW_TAG_rvalue_reference_type:
292+
CurrentType = createType();
293+
CurrentType->setIsRvalueReference();
294+
CurrentType->setName("&&");
295+
return CurrentType;
296+
case dwarf::DW_TAG_subrange_type:
297+
CurrentType = createTypeSubrange();
298+
return CurrentType;
299+
case dwarf::DW_TAG_template_value_parameter:
300+
CurrentType = createTypeParam();
301+
CurrentType->setIsTemplateValueParam();
302+
return CurrentType;
303+
case dwarf::DW_TAG_template_type_parameter:
304+
CurrentType = createTypeParam();
305+
CurrentType->setIsTemplateTypeParam();
306+
return CurrentType;
307+
case dwarf::DW_TAG_GNU_template_template_param:
308+
CurrentType = createTypeParam();
309+
CurrentType->setIsTemplateTemplateParam();
310+
return CurrentType;
311+
case dwarf::DW_TAG_typedef:
312+
CurrentType = createTypeDefinition();
313+
return CurrentType;
314+
case dwarf::DW_TAG_unspecified_type:
315+
CurrentType = createType();
316+
CurrentType->setIsUnspecified();
317+
return CurrentType;
318+
case dwarf::DW_TAG_volatile_type:
319+
CurrentType = createType();
320+
CurrentType->setIsVolatile();
321+
CurrentType->setName("volatile");
322+
return CurrentType;
323+
324+
// Symbols.
325+
case dwarf::DW_TAG_formal_parameter:
326+
CurrentSymbol = createSymbol();
327+
CurrentSymbol->setIsParameter();
328+
return CurrentSymbol;
329+
case dwarf::DW_TAG_unspecified_parameters:
330+
CurrentSymbol = createSymbol();
331+
CurrentSymbol->setIsUnspecified();
332+
CurrentSymbol->setName("...");
333+
return CurrentSymbol;
334+
case dwarf::DW_TAG_member:
335+
CurrentSymbol = createSymbol();
336+
CurrentSymbol->setIsMember();
337+
return CurrentSymbol;
338+
case dwarf::DW_TAG_variable:
339+
CurrentSymbol = createSymbol();
340+
CurrentSymbol->setIsVariable();
341+
return CurrentSymbol;
342+
case dwarf::DW_TAG_inheritance:
343+
CurrentSymbol = createSymbol();
344+
CurrentSymbol->setIsInheritance();
345+
return CurrentSymbol;
346+
case dwarf::DW_TAG_call_site_parameter:
347+
case dwarf::DW_TAG_GNU_call_site_parameter:
348+
CurrentSymbol = createSymbol();
349+
CurrentSymbol->setIsCallSiteParameter();
350+
return CurrentSymbol;
351+
case dwarf::DW_TAG_constant:
352+
CurrentSymbol = createSymbol();
353+
CurrentSymbol->setIsConstant();
354+
return CurrentSymbol;
355+
356+
// Scopes.
357+
case dwarf::DW_TAG_catch_block:
358+
CurrentScope = createScope();
359+
CurrentScope->setIsCatchBlock();
360+
return CurrentScope;
361+
case dwarf::DW_TAG_lexical_block:
362+
CurrentScope = createScope();
363+
CurrentScope->setIsLexicalBlock();
364+
return CurrentScope;
365+
case dwarf::DW_TAG_try_block:
366+
CurrentScope = createScope();
367+
CurrentScope->setIsTryBlock();
368+
return CurrentScope;
369+
case dwarf::DW_TAG_compile_unit:
370+
case dwarf::DW_TAG_skeleton_unit:
371+
CurrentScope = createScopeCompileUnit();
372+
CompileUnit = static_cast<LVScopeCompileUnit *>(CurrentScope);
373+
return CurrentScope;
374+
case dwarf::DW_TAG_inlined_subroutine:
375+
CurrentScope = createScopeFunctionInlined();
376+
return CurrentScope;
377+
case dwarf::DW_TAG_namespace:
378+
CurrentScope = createScopeNamespace();
379+
return CurrentScope;
380+
case dwarf::DW_TAG_template_alias:
381+
CurrentScope = createScopeAlias();
382+
return CurrentScope;
383+
case dwarf::DW_TAG_array_type:
384+
CurrentScope = createScopeArray();
385+
return CurrentScope;
386+
case dwarf::DW_TAG_call_site:
387+
case dwarf::DW_TAG_GNU_call_site:
388+
CurrentScope = createScopeFunction();
389+
CurrentScope->setIsCallSite();
390+
return CurrentScope;
391+
case dwarf::DW_TAG_entry_point:
392+
CurrentScope = createScopeFunction();
393+
CurrentScope->setIsEntryPoint();
394+
return CurrentScope;
395+
case dwarf::DW_TAG_subprogram:
396+
CurrentScope = createScopeFunction();
397+
CurrentScope->setIsSubprogram();
398+
return CurrentScope;
399+
case dwarf::DW_TAG_subroutine_type:
400+
CurrentScope = createScopeFunctionType();
401+
return CurrentScope;
402+
case dwarf::DW_TAG_label:
403+
CurrentScope = createScopeFunction();
404+
CurrentScope->setIsLabel();
405+
return CurrentScope;
406+
case dwarf::DW_TAG_class_type:
407+
CurrentScope = createScopeAggregate();
408+
CurrentScope->setIsClass();
409+
return CurrentScope;
410+
case dwarf::DW_TAG_structure_type:
411+
CurrentScope = createScopeAggregate();
412+
CurrentScope->setIsStructure();
413+
return CurrentScope;
414+
case dwarf::DW_TAG_union_type:
415+
CurrentScope = createScopeAggregate();
416+
CurrentScope->setIsUnion();
417+
return CurrentScope;
418+
case dwarf::DW_TAG_enumeration_type:
419+
CurrentScope = createScopeEnumeration();
420+
return CurrentScope;
421+
case dwarf::DW_TAG_GNU_formal_parameter_pack:
422+
CurrentScope = createScopeFormalPack();
423+
return CurrentScope;
424+
case dwarf::DW_TAG_GNU_template_parameter_pack:
425+
CurrentScope = createScopeTemplatePack();
426+
return CurrentScope;
427+
case dwarf::DW_TAG_module:
428+
CurrentScope = createScopeModule();
429+
return CurrentScope;
430+
default:
431+
// Collect TAGs not implemented.
432+
if (options().getInternalTag() && Tag)
433+
CompileUnit->addDebugTag(Tag, CurrentOffset);
434+
break;
435+
}
436+
437+
LLVM_DEBUG({
438+
dbgs() << "DWARF Tag not implemented: " << dwarf::TagString(Tag) << "\n";
439+
});
440+
441+
return nullptr;
442+
}
443+
197444
// The Reader is the module that creates the logical view using the debug
198445
// information contained in the binary file specified in the command line.
199446
// This is the main entry point for the Reader and performs the following

0 commit comments

Comments
 (0)