Skip to content

Commit cb34cf5

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW33)
LLVM: llvm/llvm-project@ec7f4a7 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@a827fb0
2 parents 92770b6 + 36a19b6 commit cb34cf5

File tree

2,064 files changed

+114226
-58895
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,064 files changed

+114226
-58895
lines changed

.clang-tidy

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
1+
Checks: |
2+
-*,
3+
clang-diagnostic-*,
4+
llvm-*,
5+
-llvm-header-guard,
6+
misc-*,
7+
-misc-no-recursion,
8+
-misc-non-private-member-variables-in-classes,
9+
-misc-unused-parameters,
10+
readability-identifier-naming
11+
WarningsAsErrors: |
12+
llvm-*,
13+
-llvm-header-guard,
14+
misc-*,
15+
-misc-no-recursion,
16+
-misc-non-private-member-variables-in-classes,
17+
-misc-unused-parameters,
18+
readability-identifier-naming
219
CheckOptions:
320
- key: readability-identifier-naming.ClassCase
421
value: CamelCase
@@ -24,3 +41,5 @@ CheckOptions:
2441
value: 1
2542
- key: modernize-use-default-member-init.UseAssignment
2643
value: 1
44+
- key: llvm-namespace-comment.ShortNamespaceLines
45+
value: '25'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ jobs:
8787
--token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
8888
release-workflow \
8989
--issue-number ${{ github.event.issue.number }} \
90+
--phab-token ${{ secrets.RELEASE_WORKFLOW_PHAB_TOKEN }} \
9091
auto

.github/workflows/libclang-abi-tests.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,10 @@ jobs:
124124
- name: Dump ABI
125125
run: |
126126
parallel abi-dumper -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o {}-${{ matrix.ref }}.abi ./build/lib/{} ::: ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}
127-
# Remove symbol versioning from dumps, so we can compare across major
128-
# versions. We don't need to do this for libclang.so since its ABI
129-
# is stable across major releases and the symbol versions don't change.
130-
if [ -e libclang-cpp.so-${{ matrix.ref }}.abi ]; then
131-
sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' libclang-cpp.so-${{ matrix.ref }}.abi
132-
fi
127+
for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
128+
# Remove symbol versioning from dumps, so we can compare across major versions.
129+
sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi
130+
done
133131
- name: Upload ABI file
134132
uses: actions/upload-artifact@v2
135133
with:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Intel LLVM-based projects:
55

66
- [oneAPI DPC++ compiler](#oneapi-dpc-compiler)
77
- [Late-outline OpenMP and OpenMP Offload](#late-outline-openmp-and-openmp-offload)
8+
sudo apt-get install llvm-16-dev llvm-16-tools clang-16 libclang-16-dev
9+
`-DLLVM_EXTERNAL_LIT="/usr/lib/llvm-16/build/utils/lit/lit.py"` is
810

911
## oneAPI DPC++ compiler
1012

bolt/include/bolt/Core/BinaryDomTree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
#ifndef BOLT_CORE_BINARY_DOMTREE_H
1515
#define BOLT_CORE_BINARY_DOMTREE_H
1616

17+
#include "bolt/Core/BinaryBasicBlock.h"
18+
#include "llvm/IR/Dominators.h"
1719
#include "llvm/Support/GenericDomTreeConstruction.h"
1820

1921
namespace llvm {
2022
namespace bolt {
2123

22-
class BinaryBasicBlock;
2324
using BinaryDomTreeNode = DomTreeNodeBase<BinaryBasicBlock>;
2425
using BinaryDominatorTree = DomTreeBase<BinaryBasicBlock>;
2526

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ class BinaryFunction {
994994
bool hasName(const std::string &FunctionName) const {
995995
auto Res =
996996
forEachName([&](StringRef Name) { return Name == FunctionName; });
997-
return Res.hasValue();
997+
return Res.has_value();
998998
}
999999

10001000
/// Check if any of function names matches the given regex.
@@ -1005,7 +1005,7 @@ class BinaryFunction {
10051005
Optional<StringRef> hasRestoredNameRegex(const StringRef NameRegex) const;
10061006

10071007
/// Return a vector of all possible names for the function.
1008-
const std::vector<StringRef> getNames() const {
1008+
std::vector<StringRef> getNames() const {
10091009
std::vector<StringRef> AllNames;
10101010
forEachName([&AllNames](StringRef Name) {
10111011
AllNames.push_back(Name);
@@ -1427,17 +1427,15 @@ class BinaryFunction {
14271427

14281428
const CallSitesType &getColdCallSites() const { return ColdCallSites; }
14291429

1430-
const ArrayRef<uint8_t> getLSDAActionTable() const { return LSDAActionTable; }
1430+
ArrayRef<uint8_t> getLSDAActionTable() const { return LSDAActionTable; }
14311431

14321432
const LSDATypeTableTy &getLSDATypeTable() const { return LSDATypeTable; }
14331433

14341434
const LSDATypeTableTy &getLSDATypeAddressTable() const {
14351435
return LSDATypeAddressTable;
14361436
}
14371437

1438-
const ArrayRef<uint8_t> getLSDATypeIndexTable() const {
1439-
return LSDATypeIndexTable;
1440-
}
1438+
ArrayRef<uint8_t> getLSDATypeIndexTable() const { return LSDATypeIndexTable; }
14411439

14421440
const LabelsMapType &getLabels() const { return Labels; }
14431441

@@ -1652,7 +1650,6 @@ class BinaryFunction {
16521650
}
16531651
OffsetToCFI.emplace(Offset, FrameInstructions.size());
16541652
FrameInstructions.emplace_back(std::forward<MCCFIInstruction>(Inst));
1655-
return;
16561653
}
16571654

16581655
BinaryBasicBlock::iterator addCFIInstruction(BinaryBasicBlock *BB,

bolt/include/bolt/Core/DebugData.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,22 @@ class DebugRangeListsSectionWriter : public DebugRangesSectionWriter {
226226
static void setAddressWriter(DebugAddrWriter *AddrW) { AddrWriter = AddrW; }
227227

228228
/// Add ranges with caching.
229-
virtual uint64_t addRanges(
229+
uint64_t addRanges(
230230
DebugAddressRangesVector &&Ranges,
231231
std::map<DebugAddressRangesVector, uint64_t> &CachedRanges) override;
232232

233233
/// Add ranges and return offset into section.
234-
virtual uint64_t addRanges(const DebugAddressRangesVector &Ranges) override;
234+
uint64_t addRanges(const DebugAddressRangesVector &Ranges) override;
235235

236-
virtual std::unique_ptr<DebugBufferVector> releaseBuffer() override {
236+
std::unique_ptr<DebugBufferVector> releaseBuffer() override {
237237
return std::move(RangesBuffer);
238238
}
239239

240240
/// Needs to be invoked before each \p CU is processed.
241-
void virtual initSection(DWARFUnit &CU) override;
241+
void initSection(DWARFUnit &CU) override;
242242

243243
/// Writes out range lists for a current CU being processed.
244-
void virtual finalizeSection() override;
244+
void finalizeSection() override;
245245

246246
// Returns true if section is empty.
247247
bool empty() { return RangesBuffer->empty(); }
@@ -391,15 +391,15 @@ class DebugAddrWriterDwarf5 : public DebugAddrWriter {
391391
DebugAddrWriterDwarf5(BinaryContext *BC) : DebugAddrWriter(BC) {}
392392

393393
/// Creates consolidated .debug_addr section, and builds DWOID to offset map.
394-
virtual AddressSectionBuffer finalize() override;
394+
AddressSectionBuffer finalize() override;
395395
/// Given DWARFUnit \p Unit returns offset of this CU in to .debug_addr
396396
/// section.
397-
virtual uint64_t getOffset(DWARFUnit &Unit) override;
397+
uint64_t getOffset(DWARFUnit &Unit) override;
398398

399399
protected:
400400
/// Given DWARFUnit \p Unit returns either DWO ID or it's offset within
401401
/// .debug_info.
402-
virtual uint64_t getCUID(DWARFUnit &Unit) override {
402+
uint64_t getCUID(DWARFUnit &Unit) override {
403403
if (Unit.isDWOUnit()) {
404404
DWARFUnit *SkeletonCU = Unit.getLinkedUnit();
405405
return SkeletonCU->getOffset();
@@ -561,9 +561,9 @@ class DebugLoclistWriter : public DebugLocWriter {
561561
static void setAddressWriter(DebugAddrWriter *AddrW) { AddrWriter = AddrW; }
562562

563563
/// Stores location lists internally to be written out during finalize phase.
564-
virtual void addList(AttrInfo &AttrVal, DebugLocationsVector &LocList,
565-
DebugInfoBinaryPatcher &DebugInfoPatcher,
566-
DebugAbbrevWriter &AbbrevWriter) override;
564+
void addList(AttrInfo &AttrVal, DebugLocationsVector &LocList,
565+
DebugInfoBinaryPatcher &DebugInfoPatcher,
566+
DebugAbbrevWriter &AbbrevWriter) override;
567567

568568
/// Writes out locations in to a local buffer and applies debug info patches.
569569
void finalize(DebugInfoBinaryPatcher &DebugInfoPatcher,
@@ -685,7 +685,7 @@ class SimpleBinaryPatcher : public BinaryPatcher {
685685

686686
/// This function takes in \p BinaryContents, applies patches to it and
687687
/// returns an updated string.
688-
virtual std::string patchBinary(StringRef BinaryContents) override;
688+
std::string patchBinary(StringRef BinaryContents) override;
689689
};
690690

691691
class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
@@ -843,7 +843,7 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
843843
std::string Value;
844844
};
845845

846-
virtual PatcherKind getKind() const override {
846+
PatcherKind getKind() const override {
847847
return PatcherKind::DebugInfoBinaryPatcher;
848848
}
849849

@@ -853,23 +853,23 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
853853

854854
/// This function takes in \p BinaryContents, and re-writes it with new
855855
/// patches inserted into it. It returns an updated string.
856-
virtual std::string patchBinary(StringRef BinaryContents) override;
856+
std::string patchBinary(StringRef BinaryContents) override;
857857

858858
/// Adds a patch to put the integer \p NewValue encoded as a 64-bit
859859
/// little-endian value at offset \p Offset.
860-
virtual void addLE64Patch(uint64_t Offset, uint64_t NewValue) override;
860+
void addLE64Patch(uint64_t Offset, uint64_t NewValue) override;
861861

862862
/// Adds a patch to put the integer \p NewValue encoded as a 32-bit
863863
/// little-endian value at offset \p Offset.
864864
/// The \p OldValueSize is the size of the old value that will be replaced.
865-
virtual void addLE32Patch(uint64_t Offset, uint32_t NewValue,
866-
uint32_t OldValueSize = 4) override;
865+
void addLE32Patch(uint64_t Offset, uint32_t NewValue,
866+
uint32_t OldValueSize = 4) override;
867867

868868
/// Add a patch at \p Offset with \p Value using unsigned LEB128 encoding with
869869
/// size \p OldValueSize.
870870
/// The \p OldValueSize is the size of the old value that will be replaced.
871-
virtual void addUDataPatch(uint64_t Offset, uint64_t Value,
872-
uint32_t OldValueSize) override;
871+
void addUDataPatch(uint64_t Offset, uint64_t Value,
872+
uint32_t OldValueSize) override;
873873

874874
/// Adds a label \p Offset for DWARF UNit.
875875
/// Used to recompute relative references.

bolt/include/bolt/Core/JumpTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class JumpTable : public BinaryData {
109109
/// starting at (or containing) 'Addr'.
110110
std::pair<size_t, size_t> getEntriesForAddress(const uint64_t Addr) const;
111111

112-
virtual bool isJumpTable() const override { return true; }
112+
bool isJumpTable() const override { return true; }
113113

114114
/// Change all entries of the jump table in \p JTAddress pointing to
115115
/// \p OldDest to \p NewDest. Return false if unsuccessful.
@@ -120,7 +120,7 @@ class JumpTable : public BinaryData {
120120
void updateOriginal();
121121

122122
/// Print for debugging purposes.
123-
virtual void print(raw_ostream &OS) const override;
123+
void print(raw_ostream &OS) const override;
124124
};
125125

126126
} // namespace bolt

bolt/include/bolt/Passes/RegReAssign.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef BOLT_PASSES_REGREASSIGN_H
1010
#define BOLT_PASSES_REGREASSIGN_H
1111

12+
#include "bolt/Passes/BinaryFunctionCallGraph.h"
1213
#include "bolt/Passes/BinaryPasses.h"
1314
#include "bolt/Passes/RegAnalysis.h"
1415

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,29 @@ class BoltAddressTranslation {
7676
/// output binary
7777
static const char *SECTION_NAME;
7878

79-
BoltAddressTranslation(BinaryContext &BC) : BC(BC) {}
79+
BoltAddressTranslation() {}
8080

8181
/// Write the serialized address translation tables for each reordered
8282
/// function
83-
void write(raw_ostream &OS);
83+
void write(const BinaryContext &BC, raw_ostream &OS);
8484

8585
/// Read the serialized address translation tables and load them internally
8686
/// in memory. Return a parse error if failed.
8787
std::error_code parse(StringRef Buf);
8888

89+
/// Dump the parsed address translation tables
90+
void dump(raw_ostream &OS);
91+
8992
/// If the maps are loaded in memory, perform the lookup to translate LBR
90-
/// addresses in \p Func.
91-
uint64_t translate(const BinaryFunction &Func, uint64_t Offset,
93+
/// addresses in function located at \p FuncAddress.
94+
uint64_t translate(uint64_t FuncAddress, uint64_t Offset,
9295
bool IsBranchSrc) const;
9396

9497
/// Use the map keys containing basic block addresses to infer fall-throughs
9598
/// taken in the path started at FirstLBR.To and ending at SecondLBR.From.
9699
/// Return NoneType if trace is invalid or the list of fall-throughs
97100
/// otherwise.
98-
Optional<FallthroughListTy> getFallthroughsInTrace(const BinaryFunction &Func,
101+
Optional<FallthroughListTy> getFallthroughsInTrace(uint64_t FuncAddress,
99102
uint64_t From,
100103
uint64_t To) const;
101104

@@ -115,8 +118,6 @@ class BoltAddressTranslation {
115118
void writeEntriesForBB(MapTy &Map, const BinaryBasicBlock &BB,
116119
uint64_t FuncAddress);
117120

118-
BinaryContext &BC;
119-
120121
std::map<uint64_t, MapTy> Maps;
121122

122123
/// Links outlined cold bocks to their original function

bolt/include/bolt/Profile/DataReader.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,18 @@ class DataReader : public ProfileReaderBase {
268268

269269
bool isTrustedSource() const override { return false; }
270270

271-
virtual Error preprocessProfile(BinaryContext &BC) override;
271+
Error preprocessProfile(BinaryContext &BC) override;
272272

273-
virtual Error readProfilePreCFG(BinaryContext &BC) override;
273+
Error readProfilePreCFG(BinaryContext &BC) override;
274274

275-
virtual Error readProfile(BinaryContext &BC) override;
275+
Error readProfile(BinaryContext &BC) override;
276276

277-
virtual bool hasLocalsWithFileName() const override;
277+
bool hasLocalsWithFileName() const override;
278278

279-
virtual bool mayHaveProfileData(const BinaryFunction &BF) override;
279+
bool mayHaveProfileData(const BinaryFunction &BF) override;
280280

281281
/// Return all event names used to collect this profile
282-
virtual StringSet<> getEventNames() const override { return EventNames; }
282+
StringSet<> getEventNames() const override { return EventNames; }
283283

284284
protected:
285285
/// Read profile information available for the function.

bolt/include/bolt/Profile/YAMLProfileReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class YAMLProfileReader : public ProfileReaderBase {
3333

3434
Error preprocessProfile(BinaryContext &BC) override;
3535

36-
virtual bool hasLocalsWithFileName() const override;
36+
bool hasLocalsWithFileName() const override;
3737

38-
virtual bool mayHaveProfileData(const BinaryFunction &BF) override;
38+
bool mayHaveProfileData(const BinaryFunction &BF) override;
3939

4040
/// Check if the file contains YAML.
4141
static bool isYAML(StringRef Filename);

bolt/lib/Core/BinaryContext.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,6 @@ bool BinaryContext::analyzeJumpTable(
622622
void BinaryContext::populateJumpTables() {
623623
LLVM_DEBUG(dbgs() << "DataPCRelocations: " << DataPCRelocations.size()
624624
<< '\n');
625-
626-
// Collect jump tables that pass the analyzeJumpTable's first check,
627-
// but fail the analyzeJumpTable's second check
628-
SmallVector<JumpTable *, 1> AbortedJTs;
629625
for (auto JTI = JumpTables.begin(), JTE = JumpTables.end(); JTI != JTE;
630626
++JTI) {
631627
JumpTable *JT = JTI->second;
@@ -644,13 +640,6 @@ void BinaryContext::populateJumpTables() {
644640
const bool Success =
645641
analyzeJumpTable(JT->getAddress(), JT->Type, *(JT->Parents[0]),
646642
NextJTAddress, &JT->EntriesAsAddress);
647-
// !Success means a false positive from earlier analysis run due to
648-
// different context. A possible culprit is instruction bounds check.
649-
// Previous run happens during disassembly. If the target function
650-
// is not disassembled, the check will be skipped, leading to a false
651-
// positive
652-
//
653-
// Solution: Ignore fragments accessing JT that fails the check
654643
if (!Success) {
655644
LLVM_DEBUG(ListSeparator LS;
656645
dbgs() << "failed to analyze jump table in function ";
@@ -670,8 +659,7 @@ void BinaryContext::populateJumpTables() {
670659
dbgs() << "\n";);
671660
NextJTI->second->print(dbgs());
672661
}
673-
AbortedJTs.push_back(JT);
674-
continue;
662+
llvm_unreachable("jump table heuristic failure");
675663
}
676664
for (BinaryFunction *Frag : JT->Parents) {
677665
for (uint64_t EntryAddress : JT->EntriesAsAddress)
@@ -701,15 +689,6 @@ void BinaryContext::populateJumpTables() {
701689
addFragmentsToSkip(Frag);
702690
}
703691

704-
// Ignore fragments accessing JT that fails analyzeJumpTable check
705-
for (JumpTable *JT : AbortedJTs) {
706-
for (BinaryFunction *Frag : JT->Parents) {
707-
Frag->setIgnored();
708-
Frag->JumpTables.erase(Frag->JumpTables.find(JT->getAddress()));
709-
}
710-
JumpTables.erase(JumpTables.find(JT->getAddress()));
711-
}
712-
713692
if (opts::StrictMode && DataPCRelocations.size()) {
714693
LLVM_DEBUG({
715694
dbgs() << DataPCRelocations.size()
@@ -799,9 +778,8 @@ BinaryContext::getOrCreateJumpTable(BinaryFunction &Function, uint64_t Address,
799778
// Prevent associating a jump table to a specific fragment twice.
800779
// This simple check arises from the assumption: no more than 2 fragments.
801780
if (JT->Parents.size() == 1 && JT->Parents[0] != &Function) {
802-
bool SameFunction = isFragmentOf(JT->Parents[0], &Function) ||
803-
isFragmentOf(&Function, JT->Parents[0]);
804-
assert(SameFunction &&
781+
assert((isFragmentOf(JT->Parents[0], &Function) ||
782+
isFragmentOf(&Function, JT->Parents[0])) &&
805783
"cannot re-use jump table of a different function");
806784
// Duplicate the entry for the parent function for easy access
807785
JT->Parents.push_back(&Function);

0 commit comments

Comments
 (0)