Skip to content

Commit b23c1b1

Browse files
committed
Merge branch 'sycl' into peter/windows-e2e
2 parents 1857938 + 9fcb4c6 commit b23c1b1

File tree

2,367 files changed

+82676
-38206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,367 files changed

+82676
-38206
lines changed

.github/ISSUE_TEMPLATE/2-bug-report-cuda.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: CUDA-specific bug report
2-
description: Please use this template in case of CUDA-specific issue
2+
description: Please use this template in case of CUDA-specific issue.
3+
Before submitting an issue check that it is not already covered in the
4+
[troubleshooting guide](https://developer.codeplay.com/products/oneapi/nvidia/latest/guides/troubleshooting)
35
labels: ["bug", "cuda"]
46
body:
57
- type: textarea

.github/ISSUE_TEMPLATE/3-bug-report-hip.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: HIP-specific bug report
22
description: Please use this template in case of HIP-specific issue
3+
Before submitting an issue check that it is not already covered in the
4+
[troubleshooting guide](https://developer.codeplay.com/products/oneapi/amd/latest/guides/troubleshooting)
35
labels: ["bug", "hip"]
46
body:
57
- type: textarea

.github/new-prs-labeler.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,26 @@ backend:PowerPC:
846846
- clang/lib/Driver/ToolChains/Arch/PPC.*
847847
- clang/test/CodeGen/PowerPC/**
848848

849+
backend:SystemZ:
850+
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
851+
- llvm/include/llvm/BinaryFormat/GOFF.h
852+
- llvm/include/llvm/IR/IntrinsicsSystemZ.td
853+
- llvm/lib/Target/SystemZ/**
854+
- llvm/test/Analysis/**/SystemZ/**
855+
- llvm/test/CodeGen/SystemZ/**
856+
- llvm/test/DebugInfo/SystemZ/**
857+
- llvm/test/ExecutionEngine/**/SystemZ/**
858+
- llvm/test/MC/Disassembler/SystemZ/**
859+
- llvm/test/MC/GOFF/**
860+
- llvm/test/MC/SystemZ/**
861+
- llvm/test/Transforms/**/SystemZ/**
862+
- clang/include/clang/Basic/BuiltinsSystemZ.*
863+
- clang/lib/Basic/Targets/SystemZ.*
864+
- clang/lib/CodeGen/Targets/SystemZ.cpp
865+
- clang/lib/Driver/ToolChains/ZOS*
866+
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
867+
- clang/test/CodeGen/SystemZ/**
868+
849869
third-party:unittests:
850870
- third-party/unittests/**
851871

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,10 @@ class BinaryContext {
997997
return getUniqueSectionByName(".gdb_index");
998998
}
999999

1000+
ErrorOr<BinarySection &> getDebugNamesSection() const {
1001+
return getUniqueSectionByName(".debug_names");
1002+
}
1003+
10001004
/// @}
10011005

10021006
/// Register \p TargetFunction as a fragment of \p Function if checks pass:

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define BOLT_CORE_DIE_BUILDER_H
1717

1818
#include "bolt/Core/BinaryContext.h"
19+
#include "bolt/Core/DebugNames.h"
1920
#include "llvm/CodeGen/DIE.h"
2021
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
2122
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
@@ -127,6 +128,7 @@ class DIEBuilder {
127128
DWARFUnit *SkeletonCU{nullptr};
128129
uint64_t UnitSize{0};
129130
llvm::DenseSet<uint64_t> AllProcessed;
131+
DWARF5AcceleratorTable &DebugNamesTable;
130132

131133
/// Returns current state of the DIEBuilder
132134
State &getState() { return *BuilderState.get(); }
@@ -206,8 +208,8 @@ class DIEBuilder {
206208
/// Update references once the layout is finalized.
207209
void updateReferences();
208210

209-
/// Update the Offset and Size of DIE.
210-
uint32_t computeDIEOffset(const DWARFUnit &CU, DIE &Die, uint32_t &CurOffset);
211+
/// Update the Offset and Size of DIE, populate DebugNames table.
212+
uint32_t finalizeDIEs(DWARFUnit &CU, DIE &Die, uint32_t &CurOffset);
211213

212214
void registerUnit(DWARFUnit &DU, bool NeedSort);
213215

@@ -269,6 +271,7 @@ class DIEBuilder {
269271

270272
public:
271273
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
274+
DWARF5AcceleratorTable &DebugNamesTable,
272275
DWARFUnit *SkeletonCU = nullptr);
273276

274277
/// Returns enum to what we are currently processing.

bolt/include/bolt/Core/DebugData.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ class DebugStrOffsetsWriter {
439439
/// Update Str offset in .debug_str in .debug_str_offsets.
440440
void updateAddressMap(uint32_t Index, uint32_t Address);
441441

442+
/// Get offset for given index in original .debug_str_offsets section.
443+
uint64_t getOffset(uint32_t Index) const { return StrOffsets[Index]; }
442444
/// Writes out current sections entry into .debug_str_offsets.
443445
void finalizeSection(DWARFUnit &Unit, DIEBuilder &DIEBldr);
444446

@@ -463,7 +465,7 @@ class DebugStrOffsetsWriter {
463465
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
464466
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
465467
std::map<uint32_t, uint32_t> IndexToAddressMap;
466-
std::vector<uint32_t> StrOffsets;
468+
SmallVector<uint32_t, 5> StrOffsets;
467469
std::unordered_map<uint64_t, uint64_t> ProcessedBaseOffsets;
468470
bool StrOffsetSectionWasModified = false;
469471
};
@@ -484,11 +486,12 @@ class DebugStrWriter {
484486
/// Returns False if no strings were added to .debug_str.
485487
bool isInitialized() const { return !StrBuffer->empty(); }
486488

489+
/// Initializes Buffer and Stream.
490+
void initialize();
491+
487492
private:
488493
/// Mutex used for parallel processing of debug info.
489494
std::mutex WriterMutex;
490-
/// Initializes Buffer and Stream.
491-
void initialize();
492495
/// Creates internal data structures.
493496
void create();
494497
std::unique_ptr<DebugStrBufferVector> StrBuffer;

bolt/include/bolt/Core/DebugNames.h

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
//===- bolt/Core/DebugNames.h - Debug names support ---*- C++
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains declaration of classes required for generation of
10+
// .debug_names section.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef BOLT_CORE_DEBUG_NAMES_H
15+
#define BOLT_CORE_DEBUG_NAMES_H
16+
17+
#include "DebugData.h"
18+
#include "llvm/CodeGen/AccelTable.h"
19+
20+
namespace llvm {
21+
namespace bolt {
22+
class BOLTDWARF5AccelTableData : public DWARF5AccelTableData {
23+
public:
24+
BOLTDWARF5AccelTableData(const uint64_t DieOffset,
25+
const std::optional<uint64_t> DefiningParentOffset,
26+
const unsigned DieTag, const unsigned UnitID,
27+
const bool IsTU,
28+
const std::optional<unsigned> SecondUnitID)
29+
: DWARF5AccelTableData(DieOffset, DefiningParentOffset, DieTag, UnitID,
30+
IsTU),
31+
SecondUnitID(SecondUnitID) {}
32+
33+
uint64_t getDieOffset() const { return DWARF5AccelTableData::getDieOffset(); }
34+
unsigned getDieTag() const { return DWARF5AccelTableData::getDieTag(); }
35+
unsigned getUnitID() const { return DWARF5AccelTableData::getUnitID(); }
36+
bool isTU() const { return DWARF5AccelTableData::isTU(); }
37+
std::optional<unsigned> getSecondUnitID() const { return SecondUnitID; }
38+
39+
private:
40+
std::optional<unsigned> SecondUnitID;
41+
};
42+
43+
class DWARF5AcceleratorTable {
44+
public:
45+
DWARF5AcceleratorTable(const bool CreateDebugNames, BinaryContext &BC,
46+
DebugStrWriter &MainBinaryStrWriter);
47+
~DWARF5AcceleratorTable() {
48+
for (DebugNamesAbbrev *Abbrev : AbbreviationsVector)
49+
Abbrev->~DebugNamesAbbrev();
50+
}
51+
/// Add DWARF5 Accelerator table entry.
52+
/// Input is DWARFUnit being processed, DIE that belongs to it, and potential
53+
/// SkeletonCU if the Unit comes from a DWO section.
54+
void addAccelTableEntry(DWARFUnit &Unit, const DIE &Die,
55+
const std::optional<uint64_t> &DWOID);
56+
/// Set current unit being processed.
57+
void setCurrentUnit(DWARFUnit &Unit, const uint64_t UnitStartOffset);
58+
/// Emit Accelerator table.
59+
void emitAccelTable();
60+
/// Returns true if the table was crated.
61+
bool isCreated() const { return NeedToCreate; }
62+
/// Returns buffer containing the accelerator table.
63+
std::unique_ptr<DebugBufferVector> releaseBuffer() {
64+
return std::move(FullTableBuffer);
65+
}
66+
67+
private:
68+
BinaryContext &BC;
69+
bool NeedToCreate = false;
70+
BumpPtrAllocator Allocator;
71+
DebugStrWriter &MainBinaryStrWriter;
72+
StringRef StrSection;
73+
uint64_t CurrentUnitOffset = 0;
74+
const DWARFUnit *CurrentUnit = nullptr;
75+
std::unordered_map<uint32_t, uint32_t> AbbrevTagToIndexMap;
76+
77+
/// Represents a group of entries with identical name (and hence, hash value).
78+
struct HashData {
79+
uint64_t StrOffset;
80+
uint32_t HashValue;
81+
uint32_t EntryOffset;
82+
std::vector<BOLTDWARF5AccelTableData *> Values;
83+
};
84+
using HashList = std::vector<HashData *>;
85+
using BucketList = std::vector<HashList>;
86+
/// Contains all the offsets of CUs.
87+
SmallVector<uint32_t, 1> CUList;
88+
/// Contains all the offsets of local TUs.
89+
SmallVector<uint32_t, 1> LocalTUList;
90+
/// Contains all the type hashes for split dwarf TUs.
91+
SmallVector<uint64_t, 1> ForeignTUList;
92+
using StringEntries =
93+
MapVector<std::string, HashData, llvm::StringMap<unsigned>>;
94+
StringEntries Entries;
95+
/// FoldingSet that uniques the abbreviations.
96+
FoldingSet<DebugNamesAbbrev> AbbreviationsSet;
97+
/// Vector containing DebugNames abbreviations for iteration in order.
98+
SmallVector<DebugNamesAbbrev *, 5> AbbreviationsVector;
99+
/// The bump allocator to use when creating DIEAbbrev objects in the uniqued
100+
/// storage container.
101+
BumpPtrAllocator Alloc;
102+
uint32_t BucketCount = 0;
103+
uint32_t UniqueHashCount = 0;
104+
uint32_t AbbrevTableSize = 0;
105+
uint32_t CUIndexEncodingSize = 4;
106+
uint32_t TUIndexEncodingSize = 4;
107+
uint32_t AugmentationStringSize = 0;
108+
dwarf::Form CUIndexForm = dwarf::DW_FORM_data4;
109+
dwarf::Form TUIndexForm = dwarf::DW_FORM_data4;
110+
111+
BucketList Buckets;
112+
113+
std::unique_ptr<DebugBufferVector> FullTableBuffer;
114+
std::unique_ptr<raw_svector_ostream> FullTableStream;
115+
std::unique_ptr<DebugBufferVector> StrBuffer;
116+
std::unique_ptr<raw_svector_ostream> StrStream;
117+
std::unique_ptr<DebugBufferVector> EntriesBuffer;
118+
std::unique_ptr<raw_svector_ostream> Entriestream;
119+
std::unique_ptr<DebugBufferVector> AugStringBuffer;
120+
std::unique_ptr<raw_svector_ostream> AugStringtream;
121+
llvm::DenseMap<llvm::hash_code, uint64_t> StrCacheToOffsetMap;
122+
// Contains DWO ID to CUList Index.
123+
llvm::DenseMap<uint64_t, uint32_t> CUOffsetsToPatch;
124+
/// Adds Unit to either CUList, LocalTUList or ForeignTUList.
125+
/// Input Unit being processed, and DWO ID if Unit is being processed comes
126+
/// from a DWO section.
127+
void addUnit(DWARFUnit &Unit, const std::optional<uint64_t> &DWOID);
128+
/// Returns number of buckets in .debug_name table.
129+
ArrayRef<HashList> getBuckets() const { return Buckets; }
130+
/// Get encoding for a given attribute.
131+
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>
132+
getIndexForEntry(const BOLTDWARF5AccelTableData &Value) const;
133+
/// Get encoding for a given attribute for second index.
134+
/// Returns nullopt if there is no second index.
135+
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>
136+
getSecondIndexForEntry(const BOLTDWARF5AccelTableData &Value) const;
137+
/// Uniquify Entries.
138+
void finalize();
139+
/// Computes bucket count.
140+
void computeBucketCount();
141+
/// Populate Abbreviations Map.
142+
void populateAbbrevsMap();
143+
/// Write Entries.
144+
void writeEntries();
145+
/// Write an Entry.
146+
void writeEntry(const BOLTDWARF5AccelTableData &Entry);
147+
/// Write augmentation_string for BOLT.
148+
void writeAugmentationString();
149+
/// Emit out Header for DWARF5 Accelerator table.
150+
void emitHeader() const;
151+
/// Emit out CU list.
152+
void emitCUList() const;
153+
/// Emit out TU List. Combination of LocalTUList and ForeignTUList.
154+
void emitTUList() const;
155+
/// Emit buckets.
156+
void emitBuckets() const;
157+
/// Emit hashes for hash table.
158+
void emitHashes() const;
159+
/// Emit string offsets for hash table.
160+
void emitStringOffsets() const;
161+
/// Emit Entry Offsets for hash table.
162+
void emitOffsets() const;
163+
/// Emit abbreviation table.
164+
void emitAbbrevs();
165+
/// Emit entries.
166+
void emitData();
167+
/// Emit augmentation string.
168+
void emitAugmentationString() const;
169+
};
170+
} // namespace bolt
171+
} // namespace llvm
172+
#endif

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,17 @@ class MCPlusBuilder {
620620
return Info->get(Inst.getOpcode()).mayStore();
621621
}
622622

623-
virtual bool isAArch64Exclusive(const MCInst &Inst) const {
623+
virtual bool isAArch64ExclusiveLoad(const MCInst &Inst) const {
624+
llvm_unreachable("not implemented");
625+
return false;
626+
}
627+
628+
virtual bool isAArch64ExclusiveStore(const MCInst &Inst) const {
629+
llvm_unreachable("not implemented");
630+
return false;
631+
}
632+
633+
virtual bool isAArch64ExclusiveClear(const MCInst &Inst) const {
624634
llvm_unreachable("not implemented");
625635
return false;
626636
}
@@ -1173,11 +1183,16 @@ class MCPlusBuilder {
11731183
bool clearOffset(MCInst &Inst) const;
11741184

11751185
/// Return the label of \p Inst, if available.
1176-
MCSymbol *getLabel(const MCInst &Inst) const;
1186+
MCSymbol *getInstLabel(const MCInst &Inst) const;
1187+
1188+
/// Set the label of \p Inst or return the existing label for the instruction.
1189+
/// This label will be emitted right before \p Inst is emitted to MCStreamer.
1190+
MCSymbol *getOrCreateInstLabel(MCInst &Inst, const Twine &Name,
1191+
MCContext *Ctx) const;
11771192

11781193
/// Set the label of \p Inst. This label will be emitted right before \p Inst
11791194
/// is emitted to MCStreamer.
1180-
bool setLabel(MCInst &Inst, MCSymbol *Label) const;
1195+
void setInstLabel(MCInst &Inst, MCSymbol *Label) const;
11811196

11821197
/// Get instruction size specified via annotation.
11831198
std::optional<uint32_t> getSize(const MCInst &Inst) const;

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "bolt/Core/DIEBuilder.h"
1313
#include "bolt/Core/DebugData.h"
14+
#include "bolt/Core/DebugNames.h"
1415
#include "llvm/ADT/StringRef.h"
1516
#include "llvm/CodeGen/DIE.h"
1617
#include "llvm/DWP/DWP.h"
@@ -140,8 +141,10 @@ class DWARFRewriter {
140141
const std::list<DWARFUnit *> &CUs);
141142

142143
/// Finalize debug sections in the main binary.
143-
void finalizeDebugSections(DIEBuilder &DIEBlder, DIEStreamer &Streamer,
144-
raw_svector_ostream &ObjOS, CUOffsetMap &CUMap);
144+
void finalizeDebugSections(DIEBuilder &DIEBlder,
145+
DWARF5AcceleratorTable &DebugNamesTable,
146+
DIEStreamer &Streamer, raw_svector_ostream &ObjOS,
147+
CUOffsetMap &CUMap);
145148

146149
/// Patches the binary for DWARF address ranges (e.g. in functions and lexical
147150
/// blocks) to be updated.

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ void BinaryContext::printInstruction(raw_ostream &OS, const MCInst &Instruction,
19671967
OS << " # Offset: " << *Offset;
19681968
if (std::optional<uint32_t> Size = MIB->getSize(Instruction))
19691969
OS << " # Size: " << *Size;
1970-
if (MCSymbol *Label = MIB->getLabel(Instruction))
1970+
if (MCSymbol *Label = MIB->getInstLabel(Instruction))
19711971
OS << " # Label: " << *Label;
19721972

19731973
MIB->printAnnotations(Instruction, OS);

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
489489

490490
if (!EmitCodeOnly) {
491491
// A symbol to be emitted before the instruction to mark its location.
492-
MCSymbol *InstrLabel = BC.MIB->getLabel(Instr);
492+
MCSymbol *InstrLabel = BC.MIB->getInstLabel(Instr);
493493

494494
if (opts::UpdateDebugSections && BF.getDWARFUnit()) {
495495
LastLocSeen = emitLineInfo(BF, Instr.getLoc(), LastLocSeen,

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ Error BinaryFunction::disassemble() {
14241424
InstrMapType::iterator II = Instructions.find(Offset);
14251425
assert(II != Instructions.end() && "reference to non-existing instruction");
14261426

1427-
BC.MIB->setLabel(II->second, Label);
1427+
BC.MIB->setInstLabel(II->second, Label);
14281428
}
14291429

14301430
// Reset symbolizer for the disassembler.

bolt/lib/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ add_llvm_library(LLVMBOLTCore
2020
BinaryFunctionProfile.cpp
2121
BinarySection.cpp
2222
DebugData.cpp
23+
DebugNames.cpp
2324
DIEBuilder.cpp
2425
DynoStats.cpp
2526
Exceptions.cpp

0 commit comments

Comments
 (0)