Skip to content

Commit 5392ab8

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW50)
LLVM: llvm/llvm-project@9bd32d7 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@0166a0f
2 parents bd4a460 + da14480 commit 5392ab8

File tree

2,900 files changed

+279970
-36446
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,900 files changed

+279970
-36446
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81
6767

6868
# [libc++] Rename _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI
6969
4c198542226223f6a5c5511a1f89b37d15ee10b9
70+
71+
# [libc++] Replace uses of _VSTD:: by std:: (#74331)
72+
77a00c0d546cd4aa8311b5b9031ae9ea8cdb050c

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ jobs:
160160
'generic-no-tzdb',
161161
'generic-no-unicode',
162162
'generic-no-wide-characters',
163+
'generic-no-rtti',
163164
'generic-static',
164165
'generic-with_llvm_unwinder',
165166
# TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive

.github/workflows/llvm-project-tests.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
required: false
1111
projects:
1212
required: false
13+
extra_cmake_args:
14+
required: false
15+
os_list:
16+
required: false
17+
default: '["ubuntu-latest", "windows-2019", "macOS-11"]'
1318
workflow_call:
1419
inputs:
1520
build_target:
@@ -20,6 +25,19 @@ on:
2025
required: true
2126
type: string
2227

28+
extra_cmake_args:
29+
required: false
30+
type: string
31+
32+
os_list:
33+
required: false
34+
type: string
35+
# Use windows-2019 due to:
36+
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
37+
# We're using a specific version of macOS due to:
38+
# https://github.com/actions/virtual-environments/issues/5900
39+
default: '["ubuntu-latest", "windows-2019", "macOS-11"]'
40+
2341
concurrency:
2442
# Skip intermediate builds: always.
2543
# Cancel intermediate builds: only if it is a pull request build.
@@ -35,14 +53,7 @@ jobs:
3553
strategy:
3654
fail-fast: false
3755
matrix:
38-
os:
39-
- ubuntu-latest
40-
# Use windows-2019 due to:
41-
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
42-
- windows-2019
43-
# We're using a specific version of macOS due to:
44-
# https://github.com/actions/virtual-environments/issues/5900
45-
- macOS-11
56+
os: ${{ fromJSON(inputs.os_list) }}
4657
steps:
4758
- name: Setup Windows
4859
if: startsWith(matrix.os, 'windows')
@@ -85,7 +96,7 @@ jobs:
8596
# This should be a no-op for non-mac OSes
8697
PKG_CONFIG_PATH: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
8798
with:
88-
cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" -DCMAKE_BUILD_TYPE=Release -DLLDB_INCLUDE_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache'
99+
cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLDB_INCLUDE_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ inputs.extra_cmake_args }}'
89100
build_target: '${{ inputs.build_target }}'
90101

91102
- name: Build and Test libclc

.github/workflows/new-prs.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ jobs:
2020
permissions:
2121
pull-requests: write
2222
# Only comment on PRs that have been opened for the first time, by someone
23-
# new to LLVM or to GitHub as a whole.
23+
# new to LLVM or to GitHub as a whole. Ideally we'd look for FIRST_TIMER
24+
# or FIRST_TIME_CONTRIBUTOR, but this does not appear to work. Instead check
25+
# that we do not have any of the other author associations.
26+
# See https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=opened#pull_request
27+
# for all the possible values.
2428
if: >-
2529
(github.repository == 'llvm/llvm-project') &&
2630
(github.event.action == 'opened') &&
27-
(github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' ||
28-
github.event.pull_request.author_association == 'FIRST_TIMER')
31+
(github.event.pull_request.author_association != 'COLLABORATOR') &&
32+
(github.event.pull_request.author_association != 'CONTRIBUTOR') &&
33+
(github.event.pull_request.author_association != 'MANNEQUIN') &&
34+
(github.event.pull_request.author_association != 'MEMBER') &&
35+
(github.event.pull_request.author_association != 'OWNER')
2936
steps:
3037
- name: Setup Automation Script
3138
run: |

.github/workflows/pr-code-format.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ jobs:
6767
START_REV: ${{ github.event.pull_request.base.sha }}
6868
END_REV: ${{ github.event.pull_request.head.sha }}
6969
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
70+
# TODO(boomanaiden154): Once clang v18 is released, we should be able
71+
# to take advantage of the new --diff_from_common_commit option
72+
# explicitly in code-format-helper.py and not have to diff starting at
73+
# the merge base.
7074
run: |
7175
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
7276
--token ${{ secrets.GITHUB_TOKEN }} \
7377
--issue-number $GITHUB_PR_NUMBER \
74-
--start-rev $START_REV \
78+
--start-rev $(git merge-base $START_REV $END_REV) \
7579
--end-rev $END_REV \
7680
--changed-files "$CHANGED_FILES"

.github/workflows/spirv-tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: SPIR-V Tests
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
paths:
10+
- 'llvm/lib/Target/SPIRV/**'
11+
- 'llvm/test/CodeGen/SPIRV/**'
12+
- '.github/workflows/spirv-tests.yml'
13+
14+
concurrency:
15+
# Skip intermediate builds: always.
16+
# Cancel intermediate builds: only if it is a pull request build.
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
19+
20+
jobs:
21+
check_spirv:
22+
if: github.repository_owner == 'llvm'
23+
name: Test SPIR-V
24+
uses: ./.github/workflows/llvm-project-tests.yml
25+
with:
26+
build_target: check-llvm-codegen-spirv
27+
projects:
28+
extra_cmake_args: '-DLLVM_TARGETS_TO_BUILD="" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="SPIRV"'
29+
os_list: '["ubuntu-latest"]'

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
3434
3535
36+
Jianjian GUAN <[email protected]>
37+
3638
3739
3840

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ enum IndirectCallPromotionType : char {
7575
ICP_ALL /// Perform ICP on calls and jump tables.
7676
};
7777

78+
/// Hash functions supported for BF/BB hashing.
79+
enum class HashFunction : char {
80+
StdHash, /// std::hash, implementation is platform-dependent. Provided for
81+
/// backwards compatibility.
82+
XXH3, /// llvm::xxh3_64bits, the default.
83+
Default = XXH3,
84+
};
85+
7886
/// Information on a single indirect call to a particular callee.
7987
struct IndirectCallProfile {
8088
MCSymbol *Symbol;
@@ -2234,18 +2242,21 @@ class BinaryFunction {
22342242
///
22352243
/// If \p UseDFS is set, process basic blocks in DFS order. Otherwise, use
22362244
/// the existing layout order.
2245+
/// \p HashFunction specifies which function is used for BF hashing.
22372246
///
22382247
/// By default, instruction operands are ignored while calculating the hash.
22392248
/// The caller can change this via passing \p OperandHashFunc function.
22402249
/// The return result of this function will be mixed with internal hash.
22412250
size_t computeHash(
2242-
bool UseDFS = false,
2251+
bool UseDFS = false, HashFunction HashFunction = HashFunction::Default,
22432252
OperandHashFuncTy OperandHashFunc = [](const MCOperand &) {
22442253
return std::string();
22452254
}) const;
22462255

22472256
/// Compute hash values for each block of the function.
2248-
void computeBlockHashes() const;
2257+
/// \p HashFunction specifies which function is used for BB hashing.
2258+
void
2259+
computeBlockHashes(HashFunction HashFunction = HashFunction::Default) const;
22492260

22502261
void setDWARFUnit(DWARFUnit *Unit) { DwarfUnit = Unit; }
22512262

bolt/include/bolt/Core/DebugData.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ class DebugStrOffsetsWriter {
459459
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
460460
std::map<uint32_t, uint32_t> IndexToAddressMap;
461461
std::unordered_map<uint64_t, uint64_t> ProcessedBaseOffsets;
462-
// Section size not including header.
463-
uint32_t CurrentSectionSize{0};
464462
bool StrOffsetSectionWasModified = false;
465463
};
466464

bolt/include/bolt/Profile/ProfileYAMLMapping.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ template <> struct ScalarBitSetTraits<PROFILE_PF> {
178178
}
179179
};
180180

181+
template <> struct ScalarEnumerationTraits<llvm::bolt::HashFunction> {
182+
using HashFunction = llvm::bolt::HashFunction;
183+
static void enumeration(IO &io, HashFunction &value) {
184+
io.enumCase(value, "std-hash", HashFunction::StdHash);
185+
io.enumCase(value, "xxh3", HashFunction::XXH3);
186+
}
187+
};
188+
181189
namespace bolt {
182190
struct BinaryProfileHeader {
183191
uint32_t Version{1};
@@ -188,6 +196,7 @@ struct BinaryProfileHeader {
188196
std::string Origin; // How the profile was obtained.
189197
std::string EventNames; // Events used for sample profile.
190198
bool IsDFSOrder{true}; // Whether using DFS block order in function profile
199+
llvm::bolt::HashFunction HashFunction; // Hash used for BB/BF hashing
191200
};
192201
} // end namespace bolt
193202

@@ -200,6 +209,8 @@ template <> struct MappingTraits<bolt::BinaryProfileHeader> {
200209
YamlIO.mapOptional("profile-origin", Header.Origin);
201210
YamlIO.mapOptional("profile-events", Header.EventNames);
202211
YamlIO.mapOptional("dfs-order", Header.IsDFSOrder);
212+
YamlIO.mapOptional("hash-func", Header.HashFunction,
213+
llvm::bolt::HashFunction::StdHash);
203214
}
204215
};
205216

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,7 +3633,7 @@ BinaryFunction::BasicBlockListType BinaryFunction::dfs() const {
36333633
return DFS;
36343634
}
36353635

3636-
size_t BinaryFunction::computeHash(bool UseDFS,
3636+
size_t BinaryFunction::computeHash(bool UseDFS, HashFunction HashFunction,
36373637
OperandHashFuncTy OperandHashFunc) const {
36383638
if (size() == 0)
36393639
return 0;
@@ -3652,7 +3652,13 @@ size_t BinaryFunction::computeHash(bool UseDFS,
36523652
for (const BinaryBasicBlock *BB : Order)
36533653
HashString.append(hashBlock(BC, *BB, OperandHashFunc));
36543654

3655-
return Hash = llvm::xxh3_64bits(HashString);
3655+
switch (HashFunction) {
3656+
case HashFunction::StdHash:
3657+
return Hash = std::hash<std::string>{}(HashString);
3658+
case HashFunction::XXH3:
3659+
return Hash = llvm::xxh3_64bits(HashString);
3660+
}
3661+
llvm_unreachable("Unhandled HashFunction");
36563662
}
36573663

36583664
void BinaryFunction::insertBasicBlocks(

bolt/lib/Core/BinaryFunctionProfile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void BinaryFunction::mergeProfileDataInto(BinaryFunction &BF) const {
225225
for (const BinaryBasicBlock *BBSucc : BB->successors()) {
226226
(void)BBSucc;
227227
assert(getIndex(BBSucc) == BF.getIndex(*BBMergeSI));
228+
(void)BBMergeSI;
228229

229230
// At this point no branch count should be set to COUNT_NO_PROFILE.
230231
assert(BII->Count != BinaryBasicBlock::COUNT_NO_PROFILE &&

bolt/lib/Core/DebugData.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,10 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
889889
// Handling re-use of str-offsets section.
890890
if (RetVal == ProcessedBaseOffsets.end() || StrOffsetSectionWasModified) {
891891
// Writing out the header for each section.
892-
support::endian::write(*StrOffsetsStream, CurrentSectionSize + 4,
893-
llvm::endianness::little);
892+
support::endian::write(
893+
*StrOffsetsStream,
894+
static_cast<uint32_t>(IndexToAddressMap.size() * 4 + 4),
895+
llvm::endianness::little);
894896
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(5),
895897
llvm::endianness::little);
896898
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(0),

bolt/lib/Core/Exceptions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
108108
DWARFDataExtractor Data(
109109
StringRef(reinterpret_cast<const char *>(LSDASectionData.data()),
110110
LSDASectionData.size()),
111-
BC.DwCtx->getDWARFObj().isLittleEndian(), 8);
111+
BC.DwCtx->getDWARFObj().isLittleEndian(),
112+
BC.DwCtx->getDWARFObj().getAddressSize());
112113
uint64_t Offset = getLSDAAddress() - LSDASectionAddress;
113114
assert(Data.isValidOffset(Offset) && "wrong LSDA address");
114115

bolt/lib/Passes/IdenticalCodeFolding.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ void IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {
360360

361361
// Pre-compute hash before pushing into hashtable.
362362
// Hash instruction operands to minimize hash collisions.
363-
BF.computeHash(opts::ICFUseDFS, [&BC](const MCOperand &Op) {
364-
return hashInstOperand(BC, Op);
365-
});
363+
BF.computeHash(
364+
opts::ICFUseDFS, HashFunction::Default,
365+
[&BC](const MCOperand &Op) { return hashInstOperand(BC, Op); });
366366
};
367367

368368
ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {

bolt/lib/Passes/IndirectCallPromotion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static cl::opt<bool> ICPPeelForInline(
158158

159159
} // namespace opts
160160

161+
#ifndef NDEBUG
161162
static bool verifyProfile(std::map<uint64_t, BinaryFunction> &BFs) {
162163
bool IsValid = true;
163164
for (auto &BFI : BFs) {
@@ -182,6 +183,7 @@ static bool verifyProfile(std::map<uint64_t, BinaryFunction> &BFs) {
182183
}
183184
return IsValid;
184185
}
186+
#endif
185187

186188
namespace llvm {
187189
namespace bolt {
@@ -1467,7 +1469,6 @@ void IndirectCallPromotion::runOnFunctions(BinaryContext &BC) {
14671469
std::max<uint64_t>(TotalIndexBasedCandidates, 1))
14681470
<< "%\n";
14691471

1470-
(void)verifyProfile;
14711472
#ifndef NDEBUG
14721473
verifyProfile(BFs);
14731474
#endif

bolt/lib/Passes/LongJmp.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,23 @@ LongJmpPass::replaceTargetWithStub(BinaryBasicBlock &BB, MCInst &Inst,
202202
}
203203
} else if (LocalStubsIter != Stubs.end() &&
204204
LocalStubsIter->second.count(TgtBB)) {
205-
// If we are replacing a local stub (because it is now out of range),
206-
// use its target instead of creating a stub to jump to another stub
205+
// The TgtBB and TgtSym now are the local out-of-range stub and its label.
206+
// So, we are attempting to restore BB to its previous state without using
207+
// this stub.
207208
TgtSym = BC.MIB->getTargetSymbol(*TgtBB->begin());
208-
TgtBB = BB.getSuccessor(TgtSym, BI);
209+
assert(TgtSym &&
210+
"First instruction is expected to contain a target symbol.");
211+
BinaryBasicBlock *TgtBBSucc = TgtBB->getSuccessor(TgtSym, BI);
212+
213+
// TgtBB might have no successor. e.g. a stub for a function call.
214+
if (TgtBBSucc) {
215+
BB.replaceSuccessor(TgtBB, TgtBBSucc, BI.Count, BI.MispredictedCount);
216+
assert(TgtBB->getExecutionCount() >= BI.Count &&
217+
"At least equal or greater than the branch count.");
218+
TgtBB->setExecutionCount(TgtBB->getExecutionCount() - BI.Count);
219+
}
220+
221+
TgtBB = TgtBBSucc;
209222
}
210223

211224
BinaryBasicBlock *StubBB = lookupLocalStub(BB, Inst, TgtSym, DotAddress);

bolt/lib/Passes/ReorderAlgorithm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <random>
2121
#include <stack>
2222

23-
#undef DEBUG_TYPE
23+
#undef DEBUG_TYPE
2424
#define DEBUG_TYPE "bolt"
2525

2626
using namespace llvm;
@@ -425,7 +425,7 @@ void TSPReorderAlgorithm::reorderBasicBlocks(BinaryFunction &BF,
425425
}
426426

427427
std::vector<std::vector<int64_t>> DP;
428-
DP.resize(1 << N);
428+
DP.resize(static_cast<size_t>(1) << N);
429429
for (std::vector<int64_t> &Elmt : DP)
430430
Elmt.resize(N, -1);
431431

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void VeneerElimination::runOnFunctions(BinaryContext &BC) {
8989
LLVM_DEBUG(
9090
dbgs() << "BOLT-INFO: number of linker-inserted veneers call sites: "
9191
<< VeneerCallers << "\n");
92+
(void)VeneerCallers;
9293
}
9394

9495
} // namespace bolt

0 commit comments

Comments
 (0)