Skip to content

Commit 8352029

Browse files
author
Hugh Delaney
authored
Merge branch 'sycl' into refactor-device-initialization
2 parents 0f0d30d + d697024 commit 8352029

File tree

2,620 files changed

+120340
-75479
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,620 files changed

+120340
-75479
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
233233

234234
windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
235235
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
236-
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
236+
# Temporary disable the windows job.
237+
# See https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840
238+
#windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
239+
windows_projects=""
237240

238241
# Generate the appropriate pipeline
239242
if [[ "${linux_projects}" != "" ]]; then

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81
7878
082b89b25faae3e45a023caf51b65ca0f02f377f
7979
0ba22f51d128bee9d69756c56c4678097270e10b
8080
84da0e1bb75f8666cf222d2f600f37bebb9ea389
81+
82+
# [NFC] clang-format utils/TableGen (#80973)
83+
b9079baaddfed5e604fbfaa1d81a7a1c38e78c26

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ sycl/plugins/**/hip/ @intel/llvm-reviewers-cuda
5050
# CUDA specific runtime implementations
5151
sycl/include/sycl/ext/oneapi/experimental/cuda/ @intel/llvm-reviewers-cuda
5252

53-
# CUDA device code tests
53+
# CUDA and HIP device code tests
5454
sycl/test/check_device_code/cuda/ @intel/llvm-reviewers-cuda
55+
sycl/test/check_device_code/hip/ @intel/llvm-reviewers-cuda
5556

5657
# XPTI instrumentation utilities
5758
xpti/ @intel/llvm-reviewers-runtime

.github/workflows/issue-release-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ jobs:
6565
release-workflow \
6666
--branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
6767
--issue-number ${{ github.event.issue.number }} \
68+
--requested-by ${{ github.event.issue.user.login }} \
6869
auto
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will test the llvm-project-tests workflow in PRs
2+
# targetting the main branch. Since this workflow doesn't normally
3+
# run on main PRs, we need some way to test it to ensure new updates
4+
# don't break it.
5+
6+
name: LLVM Workflow Test
7+
8+
permissions:
9+
contents: read
10+
11+
on:
12+
pull_request:
13+
branches:
14+
- 'main'
15+
paths:
16+
- '.github/workflows/llvm-project-tests.yml'
17+
- '.github/workflows/llvm-project-workflow-tests.yml'
18+
19+
concurrency:
20+
# Skip intermediate builds: always.
21+
# Cancel intermediate builds: only if it is a pull request build.
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
24+
25+
jobs:
26+
llvm-test:
27+
if: github.repository_owner == 'llvm'
28+
name: Build and Test
29+
uses: ./.github/workflows/llvm-project-tests.yml
30+
with:
31+
build_target: check-all
32+
projects: clang;lld;libclc;lldb

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,35 @@ class FilterIterator {
145145
}
146146
};
147147

148+
/// BOLT-exclusive errors generated in core BOLT libraries, optionally holding a
149+
/// string message and whether it is fatal or not. In case it is fatal and if
150+
/// BOLT is running as a standalone process, the process might be killed as soon
151+
/// as the error is checked.
152+
class BOLTError : public ErrorInfo<BOLTError> {
153+
public:
154+
static char ID;
155+
156+
BOLTError(bool IsFatal, const Twine &S = Twine());
157+
void log(raw_ostream &OS) const override;
158+
bool isFatal() const { return IsFatal; }
159+
160+
const std::string &getMessage() const { return Msg; }
161+
std::error_code convertToErrorCode() const override;
162+
163+
private:
164+
bool IsFatal;
165+
std::string Msg;
166+
};
167+
168+
/// Streams used by BOLT to log regular or error events
169+
struct JournalingStreams {
170+
raw_ostream &Out;
171+
raw_ostream &Err;
172+
};
173+
174+
Error createNonFatalBOLTError(const Twine &S);
175+
Error createFatalBOLTError(const Twine &S);
176+
148177
class BinaryContext {
149178
BinaryContext() = delete;
150179

@@ -237,7 +266,8 @@ class BinaryContext {
237266
public:
238267
static Expected<std::unique_ptr<BinaryContext>>
239268
createBinaryContext(const ObjectFile *File, bool IsPIC,
240-
std::unique_ptr<DWARFContext> DwCtx);
269+
std::unique_ptr<DWARFContext> DwCtx,
270+
JournalingStreams Logger);
241271

242272
/// Superset of compiler units that will contain overwritten code that needs
243273
/// new debug info. In a few cases, functions may end up not being
@@ -605,6 +635,10 @@ class BinaryContext {
605635

606636
std::unique_ptr<MCAsmBackend> MAB;
607637

638+
/// Allows BOLT to print to log whenever it is necessary (with or without
639+
/// const references)
640+
mutable JournalingStreams Logger;
641+
608642
/// Indicates if the binary is Linux kernel.
609643
bool IsLinuxKernel{false};
610644

@@ -737,7 +771,8 @@ class BinaryContext {
737771
std::unique_ptr<const MCInstrAnalysis> MIA,
738772
std::unique_ptr<MCPlusBuilder> MIB,
739773
std::unique_ptr<const MCRegisterInfo> MRI,
740-
std::unique_ptr<MCDisassembler> DisAsm);
774+
std::unique_ptr<MCDisassembler> DisAsm,
775+
JournalingStreams Logger);
741776

742777
~BinaryContext();
743778

@@ -1349,8 +1384,12 @@ class BinaryContext {
13491384
return Offset;
13501385
}
13511386

1352-
void exitWithBugReport(StringRef Message,
1353-
const BinaryFunction &Function) const;
1387+
/// Log BOLT errors to journaling streams and quit process with non-zero error
1388+
/// code 1 if error is fatal.
1389+
void logBOLTErrorsAndQuitOnFatal(Error E);
1390+
1391+
std::string generateBugReportMessage(StringRef Message,
1392+
const BinaryFunction &Function) const;
13541393

13551394
struct IndependentCodeEmitter {
13561395
std::unique_ptr<MCObjectFileInfo> LocalMOFI;
@@ -1398,6 +1437,10 @@ class BinaryContext {
13981437
assert(IOAddressMap && "Address map not set yet");
13991438
return *IOAddressMap;
14001439
}
1440+
1441+
raw_ostream &outs() const { return Logger.Out; }
1442+
1443+
raw_ostream &errs() const { return Logger.Err; }
14011444
};
14021445

14031446
template <typename T, typename = std::enable_if_t<sizeof(T) == 1>>

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,12 +1910,11 @@ class BinaryFunction {
19101910

19111911
/// Support dynamic relocations in constant islands, which may happen if
19121912
/// binary is linked with -z notext option.
1913-
void markIslandDynamicRelocationAtAddress(uint64_t Address) {
1914-
if (!isInConstantIsland(Address)) {
1915-
errs() << "BOLT-ERROR: dynamic relocation found for text section at 0x"
1916-
<< Twine::utohexstr(Address) << "\n";
1917-
exit(1);
1918-
}
1913+
Error markIslandDynamicRelocationAtAddress(uint64_t Address) {
1914+
if (!isInConstantIsland(Address))
1915+
return createFatalBOLTError(
1916+
Twine("dynamic relocation found for text section at 0x") +
1917+
Twine::utohexstr(Address) + Twine("\n"));
19191918

19201919
// Mark island to have dynamic relocation
19211920
Islands->HasDynamicRelocations = true;
@@ -1924,6 +1923,7 @@ class BinaryFunction {
19241923
// move binary data during updateOutputValues, making us emit
19251924
// dynamic relocation with the right offset value.
19261925
getOrCreateIslandAccess(Address);
1926+
return Error::success();
19271927
}
19281928

19291929
bool hasDynamicRelocationAtIsland() const {
@@ -2054,9 +2054,10 @@ class BinaryFunction {
20542054
/// state to State:Disassembled.
20552055
///
20562056
/// Returns false if disassembly failed.
2057-
bool disassemble();
2057+
Error disassemble();
20582058

2059-
void handlePCRelOperand(MCInst &Instruction, uint64_t Address, uint64_t Size);
2059+
Error handlePCRelOperand(MCInst &Instruction, uint64_t Address,
2060+
uint64_t Size);
20602061

20612062
MCSymbol *handleExternalReference(MCInst &Instruction, uint64_t Size,
20622063
uint64_t Offset, uint64_t TargetAddress,
@@ -2100,7 +2101,7 @@ class BinaryFunction {
21002101
///
21012102
/// Returns true on success and update the current function state to
21022103
/// State::CFG. Returns false if CFG cannot be built.
2103-
bool buildCFG(MCPlusBuilder::AllocatorIdTy);
2104+
Error buildCFG(MCPlusBuilder::AllocatorIdTy);
21042105

21052106
/// Perform post-processing of the CFG.
21062107
void postProcessCFG();
@@ -2217,7 +2218,7 @@ class BinaryFunction {
22172218
}
22182219

22192220
/// Process LSDA information for the function.
2220-
void parseLSDA(ArrayRef<uint8_t> LSDAData, uint64_t LSDAAddress);
2221+
Error parseLSDA(ArrayRef<uint8_t> LSDAData, uint64_t LSDAAddress);
22212222

22222223
/// Update exception handling ranges for the function.
22232224
void updateEHRanges();

bolt/include/bolt/Core/BinarySection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class BinarySection {
112112
static StringRef getName(SectionRef Section) {
113113
return cantFail(Section.getName());
114114
}
115-
static StringRef getContents(SectionRef Section) {
115+
static StringRef getContentsOrQuit(SectionRef Section) {
116116
if (Section.getObject()->isELF() &&
117117
ELFSectionRef(Section).getType() == ELF::SHT_NOBITS)
118118
return StringRef();
@@ -159,7 +159,7 @@ class BinarySection {
159159

160160
BinarySection(BinaryContext &BC, SectionRef Section)
161161
: BC(BC), Name(getName(Section)), Section(Section),
162-
Contents(getContents(Section)), Address(Section.getAddress()),
162+
Contents(getContentsOrQuit(Section)), Address(Section.getAddress()),
163163
Size(Section.getSize()), Alignment(Section.getAlignment().value()),
164164
OutputName(Name), SectionNumber(++Count) {
165165
if (isELF()) {

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef BOLT_CORE_DIE_BUILDER_H
1616
#define BOLT_CORE_DIE_BUILDER_H
1717

18+
#include "bolt/Core/BinaryContext.h"
1819
#include "llvm/CodeGen/DIE.h"
1920
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
2021
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
@@ -32,6 +33,7 @@
3233
namespace llvm {
3334

3435
namespace bolt {
36+
3537
class DIEStreamer;
3638
class DebugStrOffsetsWriter;
3739

@@ -120,6 +122,7 @@ class DIEBuilder {
120122
std::unique_ptr<State> BuilderState;
121123
FoldingSet<DIEAbbrev> AbbreviationsSet;
122124
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
125+
BinaryContext &BC;
123126
DWARFContext *DwarfContext{nullptr};
124127
bool IsDWO{false};
125128
uint64_t UnitSize{0};
@@ -219,9 +222,10 @@ class DIEBuilder {
219222
if (getState().CloneUnitCtxMap[UnitId].DieInfoVector.size() > DIEId)
220223
return *getState().CloneUnitCtxMap[UnitId].DieInfoVector[DIEId].get();
221224

222-
errs() << "BOLT-WARNING: [internal-dwarf-error]: The DIE is not allocated "
223-
"before looking up, some"
224-
<< "unexpected corner cases happened.\n";
225+
BC.errs()
226+
<< "BOLT-WARNING: [internal-dwarf-error]: The DIE is not allocated "
227+
"before looking up, some"
228+
<< "unexpected corner cases happened.\n";
225229
return *getState().CloneUnitCtxMap[UnitId].DieInfoVector.front().get();
226230
}
227231

@@ -261,7 +265,7 @@ class DIEBuilder {
261265
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);
262266

263267
public:
264-
DIEBuilder(DWARFContext *DwarfContext, bool IsDWO = false);
268+
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
265269

266270
/// Returns enum to what we are currently processing.
267271
ProcessingType getCurrentProcessingState() { return getState().Type; }
@@ -295,8 +299,9 @@ class DIEBuilder {
295299
if (getState().TypeDIEMap.count(&DU))
296300
return getState().TypeDIEMap[&DU];
297301

298-
errs() << "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
299-
<< DU.getOffset() << "\n";
302+
BC.errs()
303+
<< "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
304+
<< DU.getOffset() << "\n";
300305
return nullptr;
301306
}
302307

bolt/include/bolt/Core/DynoStats.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ inline DynoStats getDynoStats(FuncsType &Funcs, bool IsAArch64) {
159159

160160
/// Call a function with optional before and after dynostats printing.
161161
template <typename FnType, typename FuncsType>
162-
inline void callWithDynoStats(FnType &&Func, FuncsType &Funcs, StringRef Phase,
163-
const bool Flag, bool IsAArch64) {
162+
inline void callWithDynoStats(raw_ostream &OS, FnType &&Func, FuncsType &Funcs,
163+
StringRef Phase, const bool Flag,
164+
bool IsAArch64) {
164165
DynoStats DynoStatsBefore(IsAArch64);
165166
if (Flag)
166167
DynoStatsBefore = getDynoStats(Funcs, IsAArch64);
@@ -170,12 +171,12 @@ inline void callWithDynoStats(FnType &&Func, FuncsType &Funcs, StringRef Phase,
170171
if (Flag) {
171172
const DynoStats DynoStatsAfter = getDynoStats(Funcs, IsAArch64);
172173
const bool Changed = (DynoStatsAfter != DynoStatsBefore);
173-
outs() << "BOLT-INFO: program-wide dynostats after running " << Phase
174-
<< (Changed ? "" : " (no change)") << ":\n\n"
175-
<< DynoStatsBefore << '\n';
174+
OS << "BOLT-INFO: program-wide dynostats after running " << Phase
175+
<< (Changed ? "" : " (no change)") << ":\n\n"
176+
<< DynoStatsBefore << '\n';
176177
if (Changed)
177-
DynoStatsAfter.print(outs(), &DynoStatsBefore);
178-
outs() << '\n';
178+
DynoStatsAfter.print(OS, &DynoStatsBefore);
179+
OS << '\n';
179180
}
180181
}
181182

bolt/include/bolt/Core/Exceptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ class FDE;
3030

3131
namespace bolt {
3232

33+
class BinaryContext;
3334
class BinaryFunction;
3435

3536
/// \brief Wraps up information to read all CFI instructions and feed them to a
3637
/// BinaryFunction, as well as rewriting CFI sections.
3738
class CFIReaderWriter {
3839
public:
39-
explicit CFIReaderWriter(const DWARFDebugFrame &EHFrame);
40+
explicit CFIReaderWriter(BinaryContext &BC, const DWARFDebugFrame &EHFrame);
4041

4142
bool fillCFIInfoFor(BinaryFunction &Function) const;
4243

@@ -59,6 +60,7 @@ class CFIReaderWriter {
5960
const FDEsMap &getFDEs() const { return FDEs; }
6061

6162
private:
63+
BinaryContext &BC;
6264
FDEsMap FDEs;
6365
};
6466

bolt/include/bolt/Passes/ADRRelaxationPass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ADRRelaxationPass : public BinaryFunctionPass {
3030
const char *getName() const override { return "adr-relaxation"; }
3131

3232
/// Pass entry point
33-
void runOnFunctions(BinaryContext &BC) override;
33+
Error runOnFunctions(BinaryContext &BC) override;
3434
void runOnFunction(BinaryFunction &BF);
3535
};
3636

bolt/include/bolt/Passes/Aligner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AlignerPass : public BinaryFunctionPass {
3939
const char *getName() const override { return "aligner"; }
4040

4141
/// Pass entry point
42-
void runOnFunctions(BinaryContext &BC) override;
42+
Error runOnFunctions(BinaryContext &BC) override;
4343
};
4444

4545
} // namespace bolt

bolt/include/bolt/Passes/AllocCombiner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AllocCombinerPass : public BinaryFunctionPass {
3333
}
3434

3535
/// Pass entry point
36-
void runOnFunctions(BinaryContext &BC) override;
36+
Error runOnFunctions(BinaryContext &BC) override;
3737
};
3838

3939
} // namespace bolt

bolt/include/bolt/Passes/AsmDump.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AsmDumpPass : public BinaryFunctionPass {
2828
bool shouldPrint(const BinaryFunction &BF) const override { return false; }
2929

3030
/// Pass entry point
31-
void runOnFunctions(BinaryContext &BC) override;
31+
Error runOnFunctions(BinaryContext &BC) override;
3232
};
3333

3434
} // namespace bolt

0 commit comments

Comments
 (0)