Skip to content

Commit 15c096f

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW26)
LLVM: llvm/llvm-project@daf897d SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@3f5e65d
2 parents bf0fc43 + 8187aea commit 15c096f

File tree

5,093 files changed

+229769
-69724
lines changed

Some content is hidden

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

5,093 files changed

+229769
-69724
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ d8f0e6caa91e230a486c948ab643174e40bdf215
4343

4444
# Use C++11 default member initializers in LLDB. NFC.
4545
9494c510af56d9c8593ab69017dcaa232210b235
46+
47+
# [libc++][NFC] clang-format <__config>
48+
ac251726f84d5b7e6533a2e3712920184435b61b

.github/workflows/closed-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
steps:
1111
- uses: andymckay/[email protected]
1212
with:
13-
remove-labels: "awaiting-review"
13+
remove-labels: 'awaiting-review'

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# /cherry-pick <commit> <...>
55
#
66
# This comment will attempt to cherry-pick the given commits to the latest
7-
# release branch (release/Y.x) and if successful push the result to a branch
7+
# release branch (release/Y.x) and if successful, push the result to a branch
88
# on github.
99
#
1010
# /branch <owner>/<repo>/<branch>
@@ -31,9 +31,9 @@ jobs:
3131
name: Backport Commits
3232
runs-on: ubuntu-20.04
3333
if: >-
34-
(github.repository == 'llvm/llvm-project') &&
35-
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
36-
contains(github.event.action == 'opened' && github.event.issue.body || github.event.comment.body, '/cherry-pick')
34+
(github.repository == 'llvm/llvm-project') &&
35+
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
36+
contains(github.event.action == 'opened' && github.event.issue.body || github.event.comment.body, '/cherry-pick')
3737
steps:
3838
- name: Fetch LLVM sources
3939
uses: actions/checkout@v2
@@ -64,16 +64,16 @@ jobs:
6464
name: Create Pull Request
6565
runs-on: ubuntu-20.04
6666
if: >-
67-
(github.repository == 'llvm/llvm-project') &&
68-
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
69-
contains(github.event.comment.body, '/branch')
67+
(github.repository == 'llvm/llvm-project') &&
68+
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
69+
contains(github.event.comment.body, '/branch')
7070
7171
steps:
7272
- name: Fetch LLVM sources
7373
uses: actions/checkout@v2
7474

7575
- name: Setup Environment
76-
run: |
76+
run: |
7777
pip install -r ./llvm/utils/git/requirements.txt
7878
7979
- name: Create Pull Request

.github/workflows/issue-subscriber.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: github.repository == 'llvm/llvm-project'
1212
steps:
13-
- name: Setup Automation Script
14-
run: |
15-
curl -O -L https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$GITHUB_SHA/llvm/utils/git/github-automation.py
16-
curl -O -L https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$GITHUB_SHA/llvm/utils/git/requirements.txt
17-
chmod a+x github-automation.py
18-
pip install -r requirements.txt
13+
- name: Setup Automation Script
14+
run: |
15+
curl -O -L https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$GITHUB_SHA/llvm/utils/git/github-automation.py
16+
curl -O -L https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$GITHUB_SHA/llvm/utils/git/requirements.txt
17+
chmod a+x github-automation.py
18+
pip install -r requirements.txt
1919
20-
- name: Update watchers
21-
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
22-
env:
23-
LABEL_NAME: ${{ github.event.label.name }}
24-
run: |
25-
./github-automation.py \
26-
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
27-
issue-subscriber \
28-
--issue-number '${{ github.event.issue.number }}' \
29-
--label-name "$LABEL_NAME"
20+
- name: Update watchers
21+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
22+
env:
23+
LABEL_NAME: ${{ github.event.label.name }}
24+
run: |
25+
./github-automation.py \
26+
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
27+
issue-subscriber \
28+
--issue-number '${{ github.event.issue.number }}' \
29+
--label-name "$LABEL_NAME"

.github/workflows/llvm-bugs.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,39 @@ jobs:
1919
MAILGUN_API_KEY: ${{ secrets.LLVM_BUGS_KEY }}
2020
with:
2121
script: |
22-
const Mailgun = require("mailgun.js");
22+
const Mailgun = require('mailgun.js');
2323
const formData = require('form-data');
24-
const mailgun = new Mailgun(formData);
2524
26-
const DOMAIN = "email.llvm.org";
25+
const mailgun = new Mailgun(formData);
26+
const DOMAIN = 'email.llvm.org';
2727
28-
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY});
28+
const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
2929
3030
github.rest.issues.get({
3131
issue_number: context.issue.number,
3232
owner: context.repo.owner,
33-
repo: context.repo.repo,
33+
repo: context.repo.repo
3434
})
35-
.then(function(issue) {
35+
.then((issue) => {
3636
const payload = {
3737
author : issue.data.user.login,
3838
issue : issue.data.number,
3939
title : issue.data.title,
4040
url : issue.data.html_url,
41-
labels : issue.data.labels.map(label => { return label.name }),
42-
assignee : issue.data.assignees.map(assignee => { return assignee.login }),
41+
labels : issue.data.labels.map((label) => label.name),
42+
assignee : issue.data.assignees.map((assignee) => assignee.login),
4343
body : issue.data.body
4444
};
45-
45+
4646
const data = {
47-
from: "LLVM Bugs <[email protected]>",
48-
47+
from: 'LLVM Bugs <[email protected]>',
48+
4949
subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
50-
template: "new-github-issue",
50+
template: 'new-github-issue',
5151
'o:tracking-clicks': 'no',
5252
'h:X-Mailgun-Variables': JSON.stringify(payload)
5353
};
5454
55-
return mg.messages.create(DOMAIN, data)
55+
return mg.messages.create(DOMAIN, data);
5656
})
57-
.then(msg => console.log(msg));
57+
.then((msg) => console.log(msg));

.github/workflows/new-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ jobs:
1010
steps:
1111
- uses: andymckay/[email protected]
1212
with:
13-
add-labels: "new issue"
13+
add-labels: 'new issue'
1414
ignore-if-labeled: true

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,9 @@ class BinaryBasicBlock {
150150
BinaryBasicBlock &operator=(const BinaryBasicBlock &) = delete;
151151
BinaryBasicBlock &operator=(const BinaryBasicBlock &&) = delete;
152152

153-
explicit BinaryBasicBlock(BinaryFunction *Function, MCSymbol *Label,
154-
uint32_t Offset = INVALID_OFFSET)
153+
explicit BinaryBasicBlock(BinaryFunction *Function, MCSymbol *Label)
155154
: Function(Function), Label(Label) {
156155
assert(Function && "Function must be non-null");
157-
InputRange.first = Offset;
158156
}
159157

160158
// Exclusively managed by BinaryFunction.
@@ -561,6 +559,12 @@ class BinaryBasicBlock {
561559
/// Set minimum alignment for the basic block.
562560
void setAlignment(uint32_t Align) { Alignment = Align; }
563561

562+
/// Set alignment of the block based on the alignment of its offset.
563+
void setDerivedAlignment() {
564+
const uint64_t DerivedAlignment = getOffset() & (1 + ~getOffset());
565+
Alignment = std::min(DerivedAlignment, uint64_t(32));
566+
}
567+
564568
/// Return required alignment for the block.
565569
uint32_t getAlignment() const { return Alignment; }
566570

@@ -787,6 +791,9 @@ class BinaryBasicBlock {
787791
/// at the split point.
788792
BinaryBasicBlock *splitAt(iterator II);
789793

794+
/// Set start offset of this basic block in the input binary.
795+
void setOffset(uint32_t Offset) { InputRange.first = Offset; };
796+
790797
/// Sets address of the basic block in the output.
791798
void setOutputStartAddress(uint64_t Address) {
792799
OutputAddressRange.first = Address;

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class BinaryContext {
239239
Optional<DWARFUnit *> getDWOCU(uint64_t DWOId);
240240

241241
/// Returns DWOContext if it exists.
242-
DWARFContext *getDWOContext();
242+
DWARFContext *getDWOContext() const;
243243

244244
/// Get Number of DWOCUs in a map.
245245
uint32_t getNumDWOCUs() { return DWOCUs.size(); }

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,28 @@ class BinaryFunction {
701701
IsInjected = true;
702702
}
703703

704+
/// Create a basic block at a given \p Offset in the function and append it
705+
/// to the end of list of blocks. Used during CFG construction only.
706+
BinaryBasicBlock *addBasicBlockAt(uint64_t Offset, MCSymbol *Label) {
707+
assert(CurrentState == State::Disassembled &&
708+
"Cannot add block with an offset in non-disassembled state.");
709+
assert(!getBasicBlockAtOffset(Offset) &&
710+
"Basic block already exists at the offset.");
711+
712+
BasicBlocks.emplace_back(createBasicBlock(Label).release());
713+
BinaryBasicBlock *BB = BasicBlocks.back();
714+
715+
BB->setIndex(BasicBlocks.size() - 1);
716+
BB->setOffset(Offset);
717+
718+
BasicBlockOffsets.emplace_back(Offset, BB);
719+
assert(std::is_sorted(BasicBlockOffsets.begin(), BasicBlockOffsets.end(),
720+
CompareBasicBlockOffsets()) &&
721+
std::is_sorted(begin(), end()));
722+
723+
return BB;
724+
}
725+
704726
/// Clear state of the function that could not be disassembled or if its
705727
/// disassembled state was later invalidated.
706728
void clearDisasmState();
@@ -842,6 +864,20 @@ class BinaryFunction {
842864
return (RI == Relocations.end()) ? nullptr : &RI->second;
843865
}
844866

867+
/// Return the first relocation in the function that starts at an address in
868+
/// the [StartOffset, EndOffset) range. Return nullptr if no such relocation
869+
/// exists.
870+
const Relocation *getRelocationInRange(uint64_t StartOffset,
871+
uint64_t EndOffset) const {
872+
assert(CurrentState == State::Empty &&
873+
"Relocations unavailable in the current function state.");
874+
auto RI = Relocations.lower_bound(StartOffset);
875+
if (RI != Relocations.end() && RI->first < EndOffset)
876+
return &RI->second;
877+
878+
return nullptr;
879+
}
880+
845881
/// Returns the raw binary encoding of this function.
846882
ErrorOr<ArrayRef<uint8_t>> getData() const;
847883

@@ -968,6 +1004,15 @@ class BinaryFunction {
9681004
return const_cast<BinaryFunction *>(this)->getInstructionAtOffset(Offset);
9691005
}
9701006

1007+
/// Return offset for the first instruction. If there is data at the
1008+
/// beginning of a function then offset of the first instruction could
1009+
/// be different from 0
1010+
uint64_t getFirstInstructionOffset() const {
1011+
if (Instructions.empty())
1012+
return 0;
1013+
return Instructions.begin()->first;
1014+
}
1015+
9711016
/// Return jump table that covers a given \p Address in memory.
9721017
JumpTable *getJumpTableContainingAddress(uint64_t Address) {
9731018
auto JTI = JumpTables.upper_bound(Address);
@@ -1314,11 +1359,11 @@ class BinaryFunction {
13141359
case ELF::R_X86_64_PC8:
13151360
case ELF::R_X86_64_PC32:
13161361
case ELF::R_X86_64_PC64:
1362+
case ELF::R_X86_64_GOTPCRELX:
1363+
case ELF::R_X86_64_REX_GOTPCRELX:
13171364
Relocations[Offset] = Relocation{Offset, Symbol, RelType, Addend, Value};
13181365
return;
13191366
case ELF::R_X86_64_PLT32:
1320-
case ELF::R_X86_64_GOTPCRELX:
1321-
case ELF::R_X86_64_REX_GOTPCRELX:
13221367
case ELF::R_X86_64_GOTPCREL:
13231368
case ELF::R_X86_64_TPOFF32:
13241369
case ELF::R_X86_64_GOTTPOFF:
@@ -1508,66 +1553,34 @@ class BinaryFunction {
15081553
return Address <= PC && PC < Address + Size;
15091554
}
15101555

1511-
/// Create a basic block at a given \p Offset in the
1512-
/// function.
1513-
/// If \p DeriveAlignment is true, set the alignment of the block based
1514-
/// on the alignment of the existing offset.
1515-
/// The new block is not inserted into the CFG. The client must
1516-
/// use insertBasicBlocks to add any new blocks to the CFG.
1556+
/// Create a basic block in the function. The new block is *NOT* inserted
1557+
/// into the CFG. The caller must use insertBasicBlocks() to add any new
1558+
/// blocks to the CFG.
15171559
std::unique_ptr<BinaryBasicBlock>
1518-
createBasicBlock(uint64_t Offset, MCSymbol *Label = nullptr,
1519-
bool DeriveAlignment = false) {
1520-
assert(BC.Ctx && "cannot be called with empty context");
1560+
createBasicBlock(MCSymbol *Label = nullptr) {
15211561
if (!Label) {
15221562
std::unique_lock<std::shared_timed_mutex> Lock(BC.CtxMutex);
15231563
Label = BC.Ctx->createNamedTempSymbol("BB");
15241564
}
1525-
auto BB = std::unique_ptr<BinaryBasicBlock>(
1526-
new BinaryBasicBlock(this, Label, Offset));
1527-
1528-
if (DeriveAlignment) {
1529-
uint64_t DerivedAlignment = Offset & (1 + ~Offset);
1530-
BB->setAlignment(std::min(DerivedAlignment, uint64_t(32)));
1531-
}
1565+
auto BB =
1566+
std::unique_ptr<BinaryBasicBlock>(new BinaryBasicBlock(this, Label));
15321567

15331568
LabelToBB[Label] = BB.get();
15341569

15351570
return BB;
15361571
}
15371572

1538-
/// Create a basic block at a given \p Offset in the
1539-
/// function and append it to the end of list of blocks.
1540-
/// If \p DeriveAlignment is true, set the alignment of the block based
1541-
/// on the alignment of the existing offset.
1542-
///
1543-
/// Returns NULL if basic block already exists at the \p Offset.
1544-
BinaryBasicBlock *addBasicBlock(uint64_t Offset, MCSymbol *Label = nullptr,
1545-
bool DeriveAlignment = false) {
1546-
assert((CurrentState == State::CFG || !getBasicBlockAtOffset(Offset)) &&
1547-
"basic block already exists in pre-CFG state");
1548-
1549-
if (!Label) {
1550-
std::unique_lock<std::shared_timed_mutex> Lock(BC.CtxMutex);
1551-
Label = BC.Ctx->createNamedTempSymbol("BB");
1552-
}
1553-
std::unique_ptr<BinaryBasicBlock> BBPtr =
1554-
createBasicBlock(Offset, Label, DeriveAlignment);
1555-
BasicBlocks.emplace_back(BBPtr.release());
1573+
/// Create a new basic block with an optional \p Label and add it to the list
1574+
/// of basic blocks of this function.
1575+
BinaryBasicBlock *addBasicBlock(MCSymbol *Label = nullptr) {
1576+
assert(CurrentState == State::CFG && "Can only add blocks in CFG state");
15561577

1578+
BasicBlocks.emplace_back(createBasicBlock(Label).release());
15571579
BinaryBasicBlock *BB = BasicBlocks.back();
1558-
BB->setIndex(BasicBlocks.size() - 1);
1559-
1560-
if (CurrentState == State::Disassembled) {
1561-
BasicBlockOffsets.emplace_back(Offset, BB);
1562-
} else if (CurrentState == State::CFG) {
1563-
BB->setLayoutIndex(layout_size());
1564-
BasicBlocksLayout.emplace_back(BB);
1565-
}
15661580

1567-
assert(CurrentState == State::CFG ||
1568-
(std::is_sorted(BasicBlockOffsets.begin(), BasicBlockOffsets.end(),
1569-
CompareBasicBlockOffsets()) &&
1570-
std::is_sorted(begin(), end())));
1581+
BB->setIndex(BasicBlocks.size() - 1);
1582+
BB->setLayoutIndex(layout_size());
1583+
BasicBlocksLayout.emplace_back(BB);
15711584

15721585
return BB;
15731586
}

bolt/include/bolt/Core/Relocation.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ struct Relocation {
5555
/// Return size of this relocation.
5656
size_t getSize() const { return getSizeForType(Type); }
5757

58-
/// Handle special cases when relocation should not be processed by bolt
58+
/// Skip relocations that we don't want to handle in BOLT
59+
static bool skipRelocationType(uint64_t Type);
60+
61+
/// Handle special cases when relocation should not be processed by BOLT
5962
static bool skipRelocationProcess(uint64_t Type, uint64_t Contents);
6063

6164
// Adjust value depending on relocation type (make it PC relative or not)
@@ -77,6 +80,9 @@ struct Relocation {
7780
/// Return true if relocation type implies the creation of a GOT entry
7881
static bool isGOT(uint64_t Type);
7982

83+
/// Special relocation type that allows the linker to modify the instruction.
84+
static bool isX86GOTPCRELX(uint64_t Type);
85+
8086
/// Return true if relocation type is NONE
8187
static bool isNone(uint64_t Type);
8288

0 commit comments

Comments
 (0)