Skip to content

Commit 91aa18b

Browse files
Merge branch 'sycl' of https://github.com/intel/llvm into esimd_emu_promot_memory_intrinsic
2 parents 421bd78 + c42abb5 commit 91aa18b

File tree

4,083 files changed

+216874
-196948
lines changed

Some content is hidden

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

4,083 files changed

+216874
-196948
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ clang/tools/clang-offload-*/ @intel/dpcpp-tools-reviewers
5050
# Explicit SIMD
5151
ESIMD/ @intel/dpcpp-esimd-reviewers
5252
esimd/ @intel/dpcpp-esimd-reviewers
53-
sycl/include/sycl/ext/intel/experimental/esimd.hpp @intel/dpcpp-esimd-reviewers
53+
sycl/include/sycl/ext/intel/esimd.hpp @intel/dpcpp-esimd-reviewers
5454
sycl/doc/extensions/experimental/sycl_ext_intel_esimd/ @intel/dpcpp-esimd-reviewers
5555
llvm/lib/SYCLLowerIR/CMakeLists.txt @intel/dpcpp-tools-reviewers @intel/dpcpp-esimd-reviewers

.github/workflows/llvm-bugs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
4949
subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
5050
template: "new-github-issue",
51+
'o:tracking-clicks': 'no',
5152
'h:X-Mailgun-Variables': JSON.stringify(payload)
5253
};
5354

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ on:
1515
type: string
1616
required: false
1717
default: "ghcr.io/intel/llvm/ubuntu2004_build:latest"
18-
build_runs_on:
19-
type: string
20-
required: false
21-
default: "build"
2218
build_ref:
2319
type: string
2420
required: false
@@ -36,7 +32,7 @@ on:
3632
build_configure_extra_args:
3733
type: string
3834
required: false
39-
default: "--hip --cuda"
35+
default: "--hip --cuda --enable-esimd-emulator"
4036
build_artifact_suffix:
4137
type: string
4238
required: true
@@ -68,7 +64,7 @@ on:
6864
jobs:
6965
build:
7066
name: Build + LIT
71-
runs-on: ${{ inputs.build_runs_on }}
67+
runs-on: [Linux, build]
7268
container:
7369
image: ${{ inputs.build_image }}
7470
options: -u 1001:1001
@@ -204,6 +200,11 @@ jobs:
204200
image: ${{ matrix.image }}
205201
options: ${{ matrix.container_options }}
206202
steps:
203+
- name: Reset GPU
204+
if: ${{ contains(matrix.config, 'gen9') }}
205+
run: |
206+
sudo mount -t debugfs none /sys/kernel/debug
207+
sudo bash -c 'echo 1 > /sys/kernel/debug/dri/0/i915_wedged'
207208
- run: cp -r /actions .
208209
- name: Register cleanup after job is finished
209210
uses: ./actions/cleanup

.github/workflows/sycl_nightly.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ jobs:
6464
if: github.repository == 'intel/llvm'
6565
uses: ./.github/workflows/sycl_linux_build_and_test.yml
6666
with:
67-
build_runs_on: build
6867
build_cache_root: "/__w/"
6968
build_cache_suffix: new_pm
7069
build_artifact_suffix: new_pm

.github/workflows/sycl_post_commit.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ jobs:
1515
name: Linux Default
1616
uses: ./.github/workflows/sycl_linux_build_and_test.yml
1717
with:
18-
build_runs_on: build
1918
build_cache_root: "/__w/llvm"
2019
build_artifact_suffix: default
2120
linux_no_assert:
2221
name: Linux (no assert)
2322
uses: ./.github/workflows/sycl_linux_build_and_test.yml
2423
with:
25-
build_runs_on: build
2624
build_cache_root: "/__w/llvm"
2725
build_cache_suffix: gcc_no_assertions
2826
build_artifact_suffix: gcc_no_assertions

.github/workflows/sycl_precommit.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ jobs:
3535
if: always() && (success() || contains(github.event.pull_request.labels.*.name, 'ignore-lint'))
3636
uses: ./.github/workflows/sycl_linux_build_and_test.yml
3737
with:
38-
build_runs_on: "build"
3938
build_cache_root: "/__w/"
4039
build_cache_size: "8G"
4140
build_artifact_suffix: "default"
4241
build_cache_suffix: "default"
43-
lts_config: "hip_amdgpu;ocl_x64;ocl_gen9;l0_gen9"
42+
lts_config: "hip_amdgpu;ocl_x64;ocl_gen9;l0_gen9;esimd_emu"

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Combinations of both are possible too, see
1717
# https://git-scm.com/docs/gitmailmap for format details.
1818
#
19-
# You can commit changes for your own names and email addresses without review.
19+
# You can commit changes for your own names and email addresses without review.
2020
# If you want to add entries for other people, please have them review the
2121
# addition.
2222
#

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,10 +1299,11 @@ class BinaryFunction {
12991299
case ELF::R_X86_64_32:
13001300
case ELF::R_X86_64_32S:
13011301
case ELF::R_X86_64_64:
1302+
case ELF::R_X86_64_PC8:
1303+
case ELF::R_X86_64_PC32:
1304+
case ELF::R_X86_64_PC64:
13021305
Relocations[Offset] = Relocation{Offset, Symbol, RelType, Addend, Value};
13031306
return;
1304-
case ELF::R_X86_64_PC32:
1305-
case ELF::R_X86_64_PC8:
13061307
case ELF::R_X86_64_PLT32:
13071308
case ELF::R_X86_64_GOTPCRELX:
13081309
case ELF::R_X86_64_REX_GOTPCRELX:

bolt/include/bolt/Core/DebugData.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
490490
PatchBaseClass,
491491
PatchValue32,
492492
PatchValue64to32,
493+
PatchValue32GenericSize,
493494
PatchValue64,
494495
PatchValueVariable,
495496
ReferencePatchValue,
@@ -536,6 +537,22 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
536537
uint32_t Value;
537538
};
538539

540+
/// Patch for 4 byte entry, where original entry size is not 4 bytes or 8
541+
/// bytes.
542+
struct DebugPatch32GenericSize : public Patch {
543+
DebugPatch32GenericSize(uint32_t O, uint32_t V, uint32_t OVS)
544+
: Patch(O, DebugPatchKind::PatchValue32GenericSize) {
545+
Value = V;
546+
OldValueSize = OVS;
547+
}
548+
549+
static bool classof(const Patch *Writer) {
550+
return Writer->getKind() == DebugPatchKind::PatchValue32GenericSize;
551+
}
552+
uint32_t Value;
553+
uint32_t OldValueSize;
554+
};
555+
539556
struct DebugPatch64 : public Patch {
540557
DebugPatch64(uint32_t O, uint64_t V)
541558
: Patch(O, DebugPatchKind::PatchValue64) {
@@ -693,6 +710,9 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
693710
case DebugPatchKind::PatchValue64to32:
694711
delete reinterpret_cast<DebugPatch64to32 *>(P);
695712
break;
713+
case DebugPatchKind::PatchValue32GenericSize:
714+
delete reinterpret_cast<DebugPatch32GenericSize *>(P);
715+
break;
696716
case DebugPatchKind::PatchValue64:
697717
delete reinterpret_cast<DebugPatch64 *>(P);
698718
break;

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ class MCPlusBuilder {
424424

425425
/// Return a register number that is guaranteed to not match with
426426
/// any real register on the underlying architecture.
427-
virtual MCPhysReg getNoRegister() const {
428-
llvm_unreachable("not implemented");
429-
}
427+
MCPhysReg getNoRegister() const { return MCRegister::NoRegister; }
430428

431429
/// Return a register corresponding to a function integer argument \p ArgNo
432430
/// if the argument is passed in a register. Or return the result of
@@ -1327,6 +1325,16 @@ class MCPlusBuilder {
13271325
return IndirectBranchType::UNKNOWN;
13281326
}
13291327

1328+
/// Analyze branch \p Instruction in PLT section and try to determine
1329+
/// associated got entry address.
1330+
virtual uint64_t analyzePLTEntry(MCInst &Instruction,
1331+
InstructionIterator Begin,
1332+
InstructionIterator End,
1333+
uint64_t BeginPC) const {
1334+
llvm_unreachable("not implemented");
1335+
return 0;
1336+
}
1337+
13301338
virtual bool analyzeVirtualMethodCall(InstructionIterator Begin,
13311339
InstructionIterator End,
13321340
std::vector<MCInst *> &MethodFetchInsns,

bolt/include/bolt/Core/Relocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct Relocation {
4949
/// Used to validate relocation correctness.
5050
uint64_t Value;
5151

52-
/// Return size of the given relocation \p Type.
52+
/// Return size in bytes of the given relocation \p Type.
5353
static size_t getSizeForType(uint64_t Type);
5454

5555
/// Return size of this relocation.

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class RewriteInstance {
5656
Error setProfile(StringRef Filename);
5757

5858
/// Run all the necessary steps to read, optimize and rewrite the binary.
59-
void run();
59+
Error run();
6060

6161
/// Diff this instance against another one. Non-const since we may run passes
6262
/// to fold identical functions.
@@ -218,7 +218,7 @@ class RewriteInstance {
218218

219219
/// Detect addresses and offsets available in the binary for allocating
220220
/// new sections.
221-
void discoverStorage();
221+
Error discoverStorage();
222222

223223
/// Adjust function sizes and set proper maximum size values after the whole
224224
/// symbol table has been processed.
@@ -246,6 +246,19 @@ class RewriteInstance {
246246
/// Disassemble and create function entries for PLT.
247247
void disassemblePLT();
248248

249+
/// Auxiliary function to create .plt BinaryFunction on \p EntryAddres
250+
/// with the \p EntrySize size. \p TargetAddress is the .got entry
251+
/// associated address.
252+
void createPLTBinaryFunction(uint64_t TargetAddress, uint64_t EntryAddress,
253+
uint64_t EntrySize);
254+
255+
/// Disassemble aarch64-specific .plt \p Section auxiliary function
256+
void disassemblePLTSectionAArch64(BinarySection &Section);
257+
258+
/// Disassemble X86-specific .plt \p Section auxiliary function. \p EntrySize
259+
/// is the expected .plt \p Section entry function size.
260+
void disassemblePLTSectionX86(BinarySection &Section, uint64_t EntrySize);
261+
249262
/// ELF-specific part. TODO: refactor into new class.
250263
#define ELF_FUNCTION(FUNC) \
251264
template <typename ELFT> void FUNC(object::ELFObjectFile<ELFT> *Obj); \
@@ -473,7 +486,7 @@ class RewriteInstance {
473486
/// multiple variants generated by different linkers.
474487
struct PLTSectionInfo {
475488
const char *Name;
476-
uint64_t EntrySize;
489+
uint64_t EntrySize{0};
477490
};
478491

479492
/// Different types of X86-64 PLT sections.
@@ -485,10 +498,7 @@ class RewriteInstance {
485498
};
486499

487500
/// AArch64 PLT sections.
488-
const PLTSectionInfo AArch64_PLTSections[2] = {
489-
{ ".plt", 16 },
490-
{ nullptr, 0 }
491-
};
501+
const PLTSectionInfo AArch64_PLTSections[2] = {{".plt"}, {nullptr}};
492502

493503
/// Return PLT information for a section with \p SectionName or nullptr
494504
/// if the section is not PLT.

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,51 +1265,6 @@ bool BinaryFunction::disassemble() {
12651265
}
12661266
}
12671267

1268-
// Check if there's a relocation associated with this instruction.
1269-
bool UsedReloc = false;
1270-
for (auto Itr = Relocations.lower_bound(Offset),
1271-
ItrE = Relocations.lower_bound(Offset + Size);
1272-
Itr != ItrE; ++Itr) {
1273-
const Relocation &Relocation = Itr->second;
1274-
1275-
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: replacing immediate 0x"
1276-
<< Twine::utohexstr(Relocation.Value)
1277-
<< " with relocation"
1278-
" against "
1279-
<< Relocation.Symbol << "+" << Relocation.Addend
1280-
<< " in function " << *this
1281-
<< " for instruction at offset 0x"
1282-
<< Twine::utohexstr(Offset) << '\n');
1283-
1284-
// Process reference to the primary symbol.
1285-
if (!Relocation.isPCRelative())
1286-
BC.handleAddressRef(Relocation.Value - Relocation.Addend, *this,
1287-
/*IsPCRel*/ false);
1288-
1289-
int64_t Value = Relocation.Value;
1290-
const bool Result = BC.MIB->replaceImmWithSymbolRef(
1291-
Instruction, Relocation.Symbol, Relocation.Addend, Ctx.get(), Value,
1292-
Relocation.Type);
1293-
(void)Result;
1294-
assert(Result && "cannot replace immediate with relocation");
1295-
1296-
// For aarch, if we replaced an immediate with a symbol from a
1297-
// relocation, we mark it so we do not try to further process a
1298-
// pc-relative operand. All we need is the symbol.
1299-
if (BC.isAArch64())
1300-
UsedReloc = true;
1301-
1302-
// Make sure we replaced the correct immediate (instruction
1303-
// can have multiple immediate operands).
1304-
if (BC.isX86()) {
1305-
assert(truncateToSize(static_cast<uint64_t>(Value),
1306-
Relocation::getSizeForType(Relocation.Type)) ==
1307-
truncateToSize(Relocation.Value, Relocation::getSizeForType(
1308-
Relocation.Type)) &&
1309-
"immediate value mismatch in function");
1310-
}
1311-
}
1312-
13131268
if (MIB->isBranch(Instruction) || MIB->isCall(Instruction)) {
13141269
uint64_t TargetAddress = 0;
13151270
if (MIB->evaluateBranch(Instruction, AbsoluteInstrAddr, Size,
@@ -1394,8 +1349,75 @@ bool BinaryFunction::disassemble() {
13941349
if (BC.isAArch64())
13951350
handleAArch64IndirectCall(Instruction, Offset);
13961351
}
1397-
} else if (MIB->hasPCRelOperand(Instruction) && !UsedReloc) {
1398-
handlePCRelOperand(Instruction, AbsoluteInstrAddr, Size);
1352+
} else {
1353+
// Check if there's a relocation associated with this instruction.
1354+
bool UsedReloc = false;
1355+
for (auto Itr = Relocations.lower_bound(Offset),
1356+
ItrE = Relocations.lower_bound(Offset + Size);
1357+
Itr != ItrE; ++Itr) {
1358+
const Relocation &Relocation = Itr->second;
1359+
uint64_t SymbolValue = Relocation.Value - Relocation.Addend;
1360+
if (Relocation.isPCRelative())
1361+
SymbolValue += getAddress() + Relocation.Offset;
1362+
1363+
// Process reference to the symbol.
1364+
if (BC.isX86())
1365+
BC.handleAddressRef(SymbolValue, *this, Relocation.isPCRelative());
1366+
1367+
if (BC.isAArch64() || !Relocation.isPCRelative()) {
1368+
int64_t Value = Relocation.Value;
1369+
const bool Result = BC.MIB->replaceImmWithSymbolRef(
1370+
Instruction, Relocation.Symbol, Relocation.Addend, Ctx.get(),
1371+
Value, Relocation.Type);
1372+
(void)Result;
1373+
assert(Result && "cannot replace immediate with relocation");
1374+
1375+
if (BC.isX86()) {
1376+
// Make sure we replaced the correct immediate (instruction
1377+
// can have multiple immediate operands).
1378+
assert(
1379+
truncateToSize(static_cast<uint64_t>(Value),
1380+
Relocation::getSizeForType(Relocation.Type)) ==
1381+
truncateToSize(Relocation.Value, Relocation::getSizeForType(
1382+
Relocation.Type)) &&
1383+
"immediate value mismatch in function");
1384+
} else if (BC.isAArch64()) {
1385+
// For aarch, if we replaced an immediate with a symbol from a
1386+
// relocation, we mark it so we do not try to further process a
1387+
// pc-relative operand. All we need is the symbol.
1388+
UsedReloc = true;
1389+
}
1390+
} else {
1391+
// Check if the relocation matches memop's Disp.
1392+
uint64_t TargetAddress;
1393+
if (!BC.MIB->evaluateMemOperandTarget(Instruction, TargetAddress,
1394+
AbsoluteInstrAddr, Size)) {
1395+
errs() << "BOLT-ERROR: PC-relative operand can't be evaluated\n";
1396+
exit(1);
1397+
}
1398+
assert(TargetAddress == Relocation.Value + AbsoluteInstrAddr + Size &&
1399+
"Immediate value mismatch detected.");
1400+
1401+
const MCExpr *Expr = MCSymbolRefExpr::create(
1402+
Relocation.Symbol, MCSymbolRefExpr::VK_None, *BC.Ctx);
1403+
// Real addend for pc-relative targets is adjusted with a delta
1404+
// from relocation placement to the next instruction.
1405+
const uint64_t TargetAddend =
1406+
Relocation.Addend + Offset + Size - Relocation.Offset;
1407+
if (TargetAddend) {
1408+
const MCConstantExpr *Offset =
1409+
MCConstantExpr::create(TargetAddend, *BC.Ctx);
1410+
Expr = MCBinaryExpr::createAdd(Expr, Offset, *BC.Ctx);
1411+
}
1412+
BC.MIB->replaceMemOperandDisp(
1413+
Instruction, MCOperand::createExpr(BC.MIB->getTargetExprFor(
1414+
Instruction, Expr, *BC.Ctx, 0)));
1415+
UsedReloc = true;
1416+
}
1417+
}
1418+
1419+
if (MIB->hasPCRelOperand(Instruction) && !UsedReloc)
1420+
handlePCRelOperand(Instruction, AbsoluteInstrAddr, Size);
13991421
}
14001422

14011423
add_instruction:
@@ -1565,6 +1587,8 @@ bool BinaryFunction::scanExternalRefs() {
15651587
ItrE = Relocations.lower_bound(Offset + Size);
15661588
Itr != ItrE; ++Itr) {
15671589
Relocation &Relocation = Itr->second;
1590+
if (Relocation.isPCRelative() && BC.isX86())
1591+
continue;
15681592
if (ignoreReference(Relocation.Symbol))
15691593
continue;
15701594

0 commit comments

Comments
 (0)