Skip to content

Commit 58ebf67

Browse files
authored
Merge pull request #2 from intel/sycl
v
2 parents d1f1698 + bf0fc43 commit 58ebf67

File tree

2,747 files changed

+122204
-54992
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,747 files changed

+122204
-54992
lines changed

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ on:
5252
type: string
5353
required: false
5454
default: "ghcr.io/intel/llvm/ubuntu2004_build:latest"
55+
cuda_image:
56+
type: string
57+
required: false
58+
default: "ghcr.io/intel/llvm/ubuntu2004_build:latest"
5559
lts_ref:
5660
type: string
5761
required: false

.github/workflows/sycl_precommit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ jobs:
4141
build_cache_size: "8G"
4242
build_artifact_suffix: "default"
4343
build_cache_suffix: "default"
44-
lts_config: "hip_amdgpu;ocl_x64;ocl_gen9;l0_gen9;esimd_emu"
44+
lts_config: "hip_amdgpu;ocl_x64;ocl_gen9;l0_gen9;esimd_emu;cuda"

.github/workflows/sycl_windows_build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
IF NOT EXIST D:\github\_work\cache MKDIR D:\github\_work\cache
3939
IF NOT EXIST D:\github\_work\cache\sycl_${{inputs.build_cache_suffix}} MKDIR D:\github\_work\cache\${{inputs.build_cache_suffix}}
4040
python.exe src/buildbot/configure.py -o build ^
41-
--ci-default ^
41+
--ci-defaults ^
4242
--cmake-opt="-DCMAKE_C_COMPILER=cl" ^
4343
--cmake-opt="-DCMAKE_CXX_COMPILER=cl" ^
4444
--cmake-opt="-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%\install" ^

bolt/include/bolt/Core/DebugData.h

Lines changed: 68 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ namespace llvm {
3434

3535
namespace bolt {
3636

37+
struct AttrInfo {
38+
DWARFFormValue V;
39+
const DWARFAbbreviationDeclaration *AbbrevDecl;
40+
uint64_t Offset;
41+
uint32_t Size; // Size of the attribute.
42+
};
43+
44+
/// Finds attributes FormValue and Offset.
45+
///
46+
/// \param DIE die to look up in.
47+
/// \param AbbrevDecl abbrev declaration for the die.
48+
/// \param Index an index in Abbrev declaration entry.
49+
Optional<AttrInfo>
50+
findAttributeInfo(const DWARFDie DIE,
51+
const DWARFAbbreviationDeclaration *AbbrevDecl,
52+
uint32_t Index);
53+
54+
/// Finds attributes FormValue and Offset.
55+
///
56+
/// \param DIE die to look up in.
57+
/// \param Attr the attribute to extract.
58+
/// \return an optional AttrInfo with DWARFFormValue and Offset.
59+
Optional<AttrInfo> findAttributeInfo(const DWARFDie DIE, dwarf::Attribute Attr);
60+
3761
// DWARF5 Header in order of encoding.
3862
// Types represent encodnig sizes.
3963
using UnitLengthType = uint32_t;
@@ -447,23 +471,31 @@ class DebugStrWriter {
447471
BinaryContext &BC;
448472
};
449473

474+
class DebugInfoBinaryPatcher;
475+
class DebugAbbrevWriter;
450476
enum class LocWriterKind { DebugLocWriter, DebugLoclistWriter };
451477

452478
/// Serializes part of a .debug_loc DWARF section with LocationLists.
453479
class SimpleBinaryPatcher;
454480
class DebugLocWriter {
481+
protected:
482+
DebugLocWriter(uint8_t DwarfVersion, LocWriterKind Kind)
483+
: DwarfVersion(DwarfVersion), Kind(Kind) {
484+
init();
485+
}
486+
455487
public:
456-
DebugLocWriter() = delete;
457-
DebugLocWriter(BinaryContext *BC);
488+
DebugLocWriter() { init(); };
458489
virtual ~DebugLocWriter(){};
459490

460491
/// Writes out location lists and stores internal patches.
461-
virtual void addList(uint64_t AttrOffset, uint32_t LocListIndex,
462-
DebugLocationsVector &&LocList);
492+
virtual void addList(AttrInfo &AttrVal, DebugLocationsVector &LocList,
493+
DebugInfoBinaryPatcher &DebugInfoPatcher,
494+
DebugAbbrevWriter &AbbrevWriter);
463495

464496
/// Writes out locations in to a local buffer, and adds Debug Info patches.
465-
virtual void finalize(uint64_t SectionOffset,
466-
SimpleBinaryPatcher &DebugInfoPatcher);
497+
virtual void finalize(DebugInfoBinaryPatcher &DebugInfoPatcher,
498+
DebugAbbrevWriter &AbbrevWriter);
467499

468500
/// Return internal buffer.
469501
virtual std::unique_ptr<DebugBufferVector> getBuffer();
@@ -485,13 +517,15 @@ class DebugLocWriter {
485517
std::unique_ptr<raw_svector_ostream> LocStream;
486518
/// Current offset in the section (updated as new entries are written).
487519
/// Starts with 0 here since this only writes part of a full location lists
488-
/// section. In the final section, the first 16 bytes are reserved for an
489-
/// empty list.
490-
uint32_t SectionOffset{0};
520+
/// section. In the final section, for DWARF4, the first 16 bytes are reserved
521+
/// for an empty list.
522+
static uint32_t LocSectionOffset;
491523
uint8_t DwarfVersion{4};
492524
LocWriterKind Kind{LocWriterKind::DebugLocWriter};
493525

494526
private:
527+
/// Inits all the related data structures.
528+
void init();
495529
struct LocListDebugInfoPatchType {
496530
uint64_t DebugInfoAttrOffset;
497531
uint64_t LocListOffset;
@@ -501,36 +535,39 @@ class DebugLocWriter {
501535
/// The list of debug info patches to be made once individual
502536
/// location list writers have been filled
503537
VectorLocListDebugInfoPatchType LocListDebugInfoPatches;
504-
505-
using VectorEmptyLocListAttributes = std::vector<uint64_t>;
506-
/// Contains all the attributes pointing to empty location list.
507-
VectorEmptyLocListAttributes EmptyAttrLists;
508538
};
509539

510540
class DebugLoclistWriter : public DebugLocWriter {
511541
public:
512542
~DebugLoclistWriter() {}
513543
DebugLoclistWriter() = delete;
514-
DebugLoclistWriter(BinaryContext *BC, DWARFUnit &Unit,
515-
uint32_t LocListsBaseAttrOffset, uint8_t DV, bool SD)
516-
: DebugLocWriter(BC), CU(Unit),
517-
LocListsBaseAttrOffset(LocListsBaseAttrOffset), IsSplitDwarf(SD) {
518-
Kind = LocWriterKind::DebugLoclistWriter;
519-
DwarfVersion = DV;
544+
DebugLoclistWriter(DWARFUnit &Unit, uint8_t DV, bool SD)
545+
: DebugLocWriter(DV, LocWriterKind::DebugLoclistWriter), CU(Unit),
546+
IsSplitDwarf(SD) {
520547
assert(DebugLoclistWriter::AddrWriter &&
521548
"Please use SetAddressWriter to initialize "
522549
"DebugAddrWriter before instantiation.");
550+
if (DwarfVersion >= 5) {
551+
LocBodyBuffer = std::make_unique<DebugBufferVector>();
552+
LocBodyStream = std::make_unique<raw_svector_ostream>(*LocBodyBuffer);
553+
} else {
554+
// Writing out empty location list to which all references to empty
555+
// location lists will point.
556+
const char Zeroes[16] = {0};
557+
*LocStream << StringRef(Zeroes, 16);
558+
}
523559
}
524560

525561
static void setAddressWriter(DebugAddrWriter *AddrW) { AddrWriter = AddrW; }
526562

527563
/// Stores location lists internally to be written out during finalize phase.
528-
virtual void addList(uint64_t AttrOffset, uint32_t LocListIndex,
529-
DebugLocationsVector &&LocList) override;
564+
virtual void addList(AttrInfo &AttrVal, DebugLocationsVector &LocList,
565+
DebugInfoBinaryPatcher &DebugInfoPatcher,
566+
DebugAbbrevWriter &AbbrevWriter) override;
530567

531568
/// Writes out locations in to a local buffer and applies debug info patches.
532-
void finalize(uint64_t SectionOffset,
533-
SimpleBinaryPatcher &DebugInfoPatcher) override;
569+
void finalize(DebugInfoBinaryPatcher &DebugInfoPatcher,
570+
DebugAbbrevWriter &AbbrevWriter) override;
534571

535572
/// Returns CU ID.
536573
/// For Skelton CU it is a CU Offset.
@@ -548,36 +585,21 @@ class DebugLoclistWriter : public DebugLocWriter {
548585
bool isSplitDwarf() const { return IsSplitDwarf; }
549586

550587
constexpr static uint32_t InvalidIndex = UINT32_MAX;
551-
constexpr static uint32_t InvalidLocListsBaseAttrOffset = UINT32_MAX;
552588

553589
private:
554590
/// Writes out locations in to a local buffer and applies debug info patches.
555-
void finalizeDWARFLegacy(uint64_t SectionOffset,
556-
SimpleBinaryPatcher &DebugInfoPatcher);
557-
558-
/// Writes out locations in to a local buffer and applies debug info patches.
559-
void finalizeDWARF5(uint64_t SectionOffset,
560-
SimpleBinaryPatcher &DebugInfoPatcher);
561-
562-
struct LocPatch {
563-
uint64_t AttrOffset{0};
564-
uint32_t Index;
565-
DebugLocationsVector LocList;
566-
};
567-
using LocPatchVec = SmallVector<LocPatch, 4>;
568-
LocPatchVec Patches;
591+
void finalizeDWARF5(DebugInfoBinaryPatcher &DebugInfoPatcher,
592+
DebugAbbrevWriter &AbbrevWriter);
569593

570-
class Patch {
571-
public:
572-
Patch() = delete;
573-
Patch(uint64_t O, uint64_t A) : Offset(O), Address(A) {}
574-
uint64_t Offset{0};
575-
uint64_t Address{0};
576-
};
577594
static DebugAddrWriter *AddrWriter;
578595
DWARFUnit &CU;
579-
uint32_t LocListsBaseAttrOffset{InvalidLocListsBaseAttrOffset};
580596
bool IsSplitDwarf{false};
597+
// Used for DWARF5 to store location lists before being finalized.
598+
std::unique_ptr<DebugBufferVector> LocBodyBuffer;
599+
std::unique_ptr<raw_svector_ostream> LocBodyStream;
600+
std::vector<uint32_t> RelativeLocListOffsets;
601+
uint32_t NumberOfEntries{0};
602+
static uint32_t LoclistBaseOffset;
581603
};
582604

583605
enum class PatcherKind { SimpleBinaryPatcher, DebugInfoBinaryPatcher };
@@ -1156,18 +1178,6 @@ class DwarfLineTable {
11561178
// Returns DWARF Version for this line table.
11571179
uint16_t getDwarfVersion() const { return DwarfVersion; }
11581180
};
1159-
1160-
struct AttrInfo {
1161-
DWARFFormValue V;
1162-
uint64_t Offset;
1163-
uint32_t Size; // Size of the attribute.
1164-
};
1165-
1166-
Optional<AttrInfo>
1167-
findAttributeInfo(const DWARFDie DIE,
1168-
const DWARFAbbreviationDeclaration *AbbrevDecl,
1169-
uint32_t Index);
1170-
11711181
} // namespace bolt
11721182
} // namespace llvm
11731183

bolt/include/bolt/Passes/BinaryPasses.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class ReorderBasicBlocks : public BinaryFunctionPass {
142142
/// LT_OPTIMIZE_CACHE piggybacks on the idea from Ispike paper (CGO '04)
143143
/// that suggests putting frequently executed chains first in the layout.
144144
LT_OPTIMIZE_CACHE,
145+
// CACHE_PLUS and EXT_TSP are synonyms, emit warning of deprecation.
146+
LT_OPTIMIZE_CACHE_PLUS,
145147
/// Block reordering guided by the extended TSP metric.
146148
LT_OPTIMIZE_EXT_TSP,
147149
/// Create clusters and use random order for them.

bolt/include/bolt/Passes/CallGraph.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#ifndef BOLT_PASSES_CALLGRAPH_H
1010
#define BOLT_PASSES_CALLGRAPH_H
1111

12+
#include "llvm/Support/FileSystem.h"
13+
#include "llvm/Support/raw_ostream.h"
1214
#include <cassert>
1315
#include <cstdint>
14-
#include <cstdio>
1516
#include <unordered_set>
1617
#include <vector>
1718

@@ -160,31 +161,31 @@ class CallGraph {
160161
};
161162

162163
template <class L> void CallGraph::printDot(char *FileName, L GetLabel) const {
163-
FILE *File = fopen(FileName, "wt");
164-
if (!File)
164+
std::error_code EC;
165+
raw_fd_ostream OS(std::string(FileName), EC, sys::fs::OF_None);
166+
if (EC)
165167
return;
166168

167-
fprintf(File, "digraph g {\n");
169+
OS << "digraph g {\n";
168170
for (NodeId F = 0; F < Nodes.size(); F++) {
169171
if (Nodes[F].samples() == 0)
170172
continue;
171-
fprintf(File, "f%lu [label=\"%s\\nsamples=%u\\nsize=%u\"];\n", F,
172-
GetLabel(F), Nodes[F].samples(), Nodes[F].size());
173+
OS << "f" << F << " [label=\"" << GetLabel(F)
174+
<< "\\nsamples=" << Nodes[F].samples() << "\\nsize=" << Nodes[F].size()
175+
<< "\"];\n";
173176
}
174177
for (NodeId F = 0; F < Nodes.size(); F++) {
175178
if (Nodes[F].samples() == 0)
176179
continue;
177180
for (NodeId Dst : Nodes[F].successors()) {
178181
ArcConstIterator Arc = findArc(F, Dst);
179-
fprintf(
180-
File,
181-
"f%lu -> f%u [label=\"normWgt=%.3lf,weight=%.0lf,callOffset=%.1lf\"];"
182-
"\n",
183-
F, Dst, Arc->normalizedWeight(), Arc->weight(), Arc->avgCallOffset());
182+
OS << "f" << F << " -> f" << Dst
183+
<< " [label=\"normWgt=" << format("%.3lf", Arc->normalizedWeight())
184+
<< ",weight=" << format("%.0lf", Arc->weight())
185+
<< ",callOffset=" << format("%.1lf", Arc->avgCallOffset()) << "\"];\n";
184186
}
185187
}
186-
fprintf(File, "}\n");
187-
fclose(File);
188+
OS << "}\n";
188189
}
189190

190191
} // namespace bolt

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class DWARFRewriter {
112112
Optional<uint64_t> RangesBase = None);
113113

114114
std::unique_ptr<DebugBufferVector>
115-
makeFinalLocListsSection(SimpleBinaryPatcher &DebugInfoPatcher,
115+
makeFinalLocListsSection(DebugInfoBinaryPatcher &DebugInfoPatcher,
116116
DWARFVersion Version);
117117

118118
/// Finalize debug sections in the main binary.

bolt/lib/Core/BinaryContext.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,9 @@ using namespace llvm;
4747

4848
namespace opts {
4949

50-
cl::opt<bool>
51-
NoHugePages("no-huge-pages",
52-
cl::desc("use regular size pages for code alignment"),
53-
cl::ZeroOrMore,
54-
cl::Hidden,
55-
cl::cat(BoltCategory));
50+
cl::opt<bool> NoHugePages("no-huge-pages",
51+
cl::desc("use regular size pages for code alignment"),
52+
cl::Hidden, cl::cat(BoltCategory));
5653

5754
static cl::opt<bool>
5855
PrintDebugInfo("print-debug-info",
@@ -61,12 +58,10 @@ PrintDebugInfo("print-debug-info",
6158
cl::ZeroOrMore,
6259
cl::cat(BoltCategory));
6360

64-
cl::opt<bool>
65-
PrintRelocations("print-relocations",
66-
cl::desc("print relocations when printing functions/objects"),
67-
cl::Hidden,
68-
cl::ZeroOrMore,
69-
cl::cat(BoltCategory));
61+
cl::opt<bool> PrintRelocations(
62+
"print-relocations",
63+
cl::desc("print relocations when printing functions/objects"), cl::Hidden,
64+
cl::cat(BoltCategory));
7065

7166
static cl::opt<bool>
7267
PrintMemData("print-mem-data",

bolt/lib/Core/BinaryData.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ extern cl::OptionCategory BoltCategory;
2525
extern cl::opt<unsigned> Verbosity;
2626

2727
cl::opt<bool>
28-
PrintSymbolAliases("print-aliases",
29-
cl::desc("print aliases when printing objects"),
30-
cl::Hidden,
31-
cl::ZeroOrMore,
32-
cl::cat(BoltCategory));
28+
PrintSymbolAliases("print-aliases",
29+
cl::desc("print aliases when printing objects"),
30+
cl::Hidden, cl::cat(BoltCategory));
3331
}
3432

3533
bool BinaryData::isAbsolute() const { return Flags & SymbolRef::SF_Absolute; }

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ namespace opts {
3434
extern cl::opt<JumpTableSupportLevel> JumpTables;
3535
extern cl::opt<bool> PreserveBlocksAlignment;
3636

37-
cl::opt<bool>
38-
AlignBlocks("align-blocks",
39-
cl::desc("align basic blocks"),
40-
cl::init(false),
41-
cl::ZeroOrMore,
42-
cl::cat(BoltOptCategory));
37+
cl::opt<bool> AlignBlocks("align-blocks", cl::desc("align basic blocks"),
38+
cl::cat(BoltOptCategory));
4339

4440
cl::opt<MacroFusionType>
4541
AlignMacroOpFusion("align-macro-fusion",
@@ -70,20 +66,15 @@ FunctionPadSpec("pad-funcs",
7066
cl::Hidden,
7167
cl::cat(BoltCategory));
7268

73-
static cl::opt<bool>
74-
MarkFuncs("mark-funcs",
75-
cl::desc("mark function boundaries with break instruction to make "
76-
"sure we accidentally don't cross them"),
77-
cl::ReallyHidden,
78-
cl::ZeroOrMore,
79-
cl::cat(BoltCategory));
69+
static cl::opt<bool> MarkFuncs(
70+
"mark-funcs",
71+
cl::desc("mark function boundaries with break instruction to make "
72+
"sure we accidentally don't cross them"),
73+
cl::ReallyHidden, cl::cat(BoltCategory));
8074

81-
static cl::opt<bool>
82-
PrintJumpTables("print-jump-tables",
83-
cl::desc("print jump tables"),
84-
cl::ZeroOrMore,
85-
cl::Hidden,
86-
cl::cat(BoltCategory));
75+
static cl::opt<bool> PrintJumpTables("print-jump-tables",
76+
cl::desc("print jump tables"), cl::Hidden,
77+
cl::cat(BoltCategory));
8778

8879
static cl::opt<bool>
8980
X86AlignBranchBoundaryHotOnly("x86-align-branch-boundary-hot-only",

0 commit comments

Comments
 (0)