Skip to content

Commit ab74e81

Browse files
Merge commit '85851165290d' into rebase_85851165290d
2 parents 58379c3 + 8585116 commit ab74e81

File tree

9,395 files changed

+549103
-324024
lines changed

Some content is hidden

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

9,395 files changed

+549103
-324024
lines changed

.github/workflows/sycl_containers.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ jobs:
7777
id: deps
7878
run: |
7979
DEPS=`cat devops/dependencies.json`
80-
DEPS="${DEPS//'%'/'%25'}"
81-
DEPS="${DEPS//$'\n'/'%0A'}"
82-
DEPS="${DEPS//$'\r'/'%0D'}"
80+
DEPS="${DEPS//$'\r'/''}"
81+
DEPS="${DEPS//$'\n'/' '}"
8382
echo $DEPS
84-
echo "::set-output name=deps::$DEPS"
83+
echo "deps=$DEPS" >>$GITHUB_OUTPUT
8584
- name: Build and Push Container
8685
uses: ./devops/actions/build_container
8786
with:
@@ -115,11 +114,10 @@ jobs:
115114
id: deps
116115
run: |
117116
DEPS=`cat devops/dependencies.json`
118-
DEPS="${DEPS//'%'/'%25'}"
119-
DEPS="${DEPS//$'\n'/'%0A'}"
120-
DEPS="${DEPS//$'\r'/'%0D'}"
117+
DEPS="${DEPS//$'\r'/''}"
118+
DEPS="${DEPS//$'\n'/' '}"
121119
echo $DEPS
122-
echo "::set-output name=deps::$DEPS"
120+
echo "deps=$DEPS" >>$GITHUB_OUTPUT
123121
- name: Build and Push Container
124122
uses: ./devops/actions/build_container
125123
with:

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ jobs:
267267
fi
268268
# FIXME cached_checkout fails here, but works everywhere else
269269
# TODO: figure out if we remove this action
270-
- uses: actions/checkout@v2
270+
- uses: actions/checkout@v3
271271
with:
272272
path: llvm
273273
# TODO should this action be packed into container as well?

.github/workflows/sycl_macos_build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Pack toolchain
6767
run: tar -cJf llvm_sycl.tar.xz -C $GITHUB_WORKSPACE/build/install .
6868
- name: Upload toolchain
69-
uses: actions/upload-artifact@v2
69+
uses: actions/upload-artifact@v3
7070
with:
7171
name: sycl_macos_${{ inputs.build_artifact_suffix }}
7272
path: llvm_sycl.tar.xz

.github/workflows/sycl_nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ubuntu-latest
4848
needs: ubuntu2004_build_test
4949
steps:
50-
- uses: actions/checkout@v2
50+
- uses: actions/checkout@v3
5151
- uses: actions/download-artifact@v3
5252
with:
5353
name: sycl_linux_default

.github/workflows/version-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_version_from_tag(tag):
1212
# We have an rc tag.
1313
return m.group(1,2,3)
1414
# We have a final release tag.
15-
return (m.group(1), m.group(2), int(m.group(3)) + 1)
15+
return (m.group(1), m.group(2), str(int(m.group(3)) + 1))
1616

1717
m = re.match('llvmorg-([0-9]+)-init', tag)
1818
if m:

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,9 @@ inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
104104
/// Filter iterator.
105105
template <typename ItrType,
106106
typename PredType = std::function<bool(const ItrType &)>>
107-
class FilterIterator
108-
: public std::iterator<std::bidirectional_iterator_tag,
109-
typename std::iterator_traits<ItrType>::value_type> {
107+
class FilterIterator {
108+
using inner_traits = std::iterator_traits<ItrType>;
110109
using Iterator = FilterIterator;
111-
using T = typename std::iterator_traits<ItrType>::reference;
112-
using PointerT = typename std::iterator_traits<ItrType>::pointer;
113110

114111
PredType Pred;
115112
ItrType Itr, End;
@@ -128,14 +125,20 @@ class FilterIterator
128125
}
129126

130127
public:
128+
using iterator_category = std::bidirectional_iterator_tag;
129+
using value_type = typename inner_traits::value_type;
130+
using difference_type = typename inner_traits::difference_type;
131+
using pointer = typename inner_traits::pointer;
132+
using reference = typename inner_traits::reference;
133+
131134
Iterator &operator++() { next(); return *this; }
132135
Iterator &operator--() { prev(); return *this; }
133136
Iterator operator++(int) { auto Tmp(Itr); next(); return Tmp; }
134137
Iterator operator--(int) { auto Tmp(Itr); prev(); return Tmp; }
135138
bool operator==(const Iterator &Other) const { return Itr == Other.Itr; }
136139
bool operator!=(const Iterator &Other) const { return !operator==(Other); }
137-
T operator*() { return *Itr; }
138-
PointerT operator->() { return &operator*(); }
140+
reference operator*() { return *Itr; }
141+
pointer operator->() { return &operator*(); }
139142
FilterIterator(PredType Pred, ItrType Itr, ItrType End)
140143
: Pred(Pred), Itr(Itr), End(End) {
141144
nextMatching();
@@ -383,6 +386,8 @@ class BinaryContext {
383386
}
384387

385388
unsigned getDWARFEncodingSize(unsigned Encoding) {
389+
if (Encoding == dwarf::DW_EH_PE_omit)
390+
return 0;
386391
switch (Encoding & 0x0f) {
387392
default:
388393
llvm_unreachable("unknown encoding");
@@ -610,6 +615,9 @@ class BinaryContext {
610615
/// Number of functions with profile information
611616
uint64_t NumProfiledFuncs{0};
612617

618+
/// Number of functions with stale profile information
619+
uint64_t NumStaleProfileFuncs{0};
620+
613621
/// Number of objects in profile whose profile was ignored.
614622
uint64_t NumUnusedProfiledObjects{0};
615623

@@ -666,7 +674,6 @@ class BinaryContext {
666674

667675
/// DWARF encoding. Available encoding types defined in BinaryFormat/Dwarf.h
668676
/// enum Constants, e.g. DW_EH_PE_omit.
669-
unsigned TTypeEncoding = dwarf::DW_EH_PE_omit;
670677
unsigned LSDAEncoding = dwarf::DW_EH_PE_omit;
671678

672679
BinaryContext(std::unique_ptr<MCContext> Ctx,

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
#include "bolt/Core/JumpTable.h"
3535
#include "bolt/Core/MCPlus.h"
3636
#include "bolt/Utils/NameResolver.h"
37+
#include "llvm/ADT/STLExtras.h"
38+
#include "llvm/ADT/SmallString.h"
3739
#include "llvm/ADT/StringRef.h"
3840
#include "llvm/ADT/iterator.h"
41+
#include "llvm/ADT/iterator_range.h"
3942
#include "llvm/BinaryFormat/Dwarf.h"
4043
#include "llvm/MC/MCContext.h"
4144
#include "llvm/MC/MCDwarf.h"
@@ -44,9 +47,11 @@
4447
#include "llvm/Object/ObjectFile.h"
4548
#include "llvm/Support/raw_ostream.h"
4649
#include <algorithm>
50+
#include <iterator>
4751
#include <limits>
4852
#include <unordered_map>
4953
#include <unordered_set>
54+
#include <utility>
5055
#include <vector>
5156

5257
using namespace llvm::object;
@@ -142,7 +147,8 @@ class BinaryFunction {
142147
uint64_t Action;
143148
};
144149

145-
using CallSitesType = SmallVector<CallSite, 0>;
150+
using CallSitesList = SmallVector<std::pair<FragmentNum, CallSite>, 0>;
151+
using CallSitesRange = iterator_range<CallSitesList::const_iterator>;
146152

147153
using IslandProxiesType =
148154
std::map<BinaryFunction *, std::map<const MCSymbol *, MCSymbol *>>;
@@ -382,6 +388,9 @@ class BinaryFunction {
382388
/// Original LSDA address for the function.
383389
uint64_t LSDAAddress{0};
384390

391+
/// Original LSDA type encoding
392+
unsigned LSDATypeEncoding{dwarf::DW_EH_PE_omit};
393+
385394
/// Containing compilation unit for the function.
386395
DWARFUnit *DwarfUnit{nullptr};
387396

@@ -492,8 +501,7 @@ class BinaryFunction {
492501
DenseMap<int32_t, SmallVector<int32_t, 4>> FrameRestoreEquivalents;
493502

494503
// For tracking exception handling ranges.
495-
CallSitesType CallSites;
496-
CallSitesType ColdCallSites;
504+
CallSitesList CallSites;
497505

498506
/// Binary blobs representing action, type, and type index tables for this
499507
/// function' LSDA (exception handling).
@@ -507,9 +515,9 @@ class BinaryFunction {
507515
/// addressing.
508516
LSDATypeTableTy LSDATypeAddressTable;
509517

510-
/// Marking for the beginning of language-specific data area for the function.
511-
MCSymbol *LSDASymbol{nullptr};
512-
MCSymbol *ColdLSDASymbol{nullptr};
518+
/// Marking for the beginnings of language-specific data areas for each
519+
/// fragment of the function.
520+
SmallVector<MCSymbol *, 0> LSDASymbols;
513521

514522
/// Map to discover which CFIs are attached to a given instruction offset.
515523
/// Maps an instruction offset into a FrameInstructions offset.
@@ -716,7 +724,6 @@ class BinaryFunction {
716724
BB->releaseCFG();
717725

718726
clearList(CallSites);
719-
clearList(ColdCallSites);
720727
clearList(LSDATypeTable);
721728
clearList(LSDATypeAddressTable);
722729

@@ -1067,6 +1074,14 @@ class BinaryFunction {
10671074
return N;
10681075
}
10691076

1077+
/// Return true if function has instructions to emit.
1078+
bool hasNonPseudoInstructions() const {
1079+
for (const BinaryBasicBlock &BB : blocks())
1080+
if (BB.getNumNonPseudos() > 0)
1081+
return true;
1082+
return false;
1083+
}
1084+
10701085
/// Return MC symbol associated with the function.
10711086
/// All references to the function should use this symbol.
10721087
MCSymbol *getSymbol(const FragmentNum Fragment = FragmentNum::main()) {
@@ -1418,14 +1433,24 @@ class BinaryFunction {
14181433

14191434
uint8_t getPersonalityEncoding() const { return PersonalityEncoding; }
14201435

1421-
const CallSitesType &getCallSites() const { return CallSites; }
1436+
CallSitesRange getCallSites(const FragmentNum F) const {
1437+
return make_range(std::equal_range(CallSites.begin(), CallSites.end(),
1438+
std::make_pair(F, CallSite()),
1439+
llvm::less_first()));
1440+
}
14221441

1423-
const CallSitesType &getColdCallSites() const { return ColdCallSites; }
1442+
void
1443+
addCallSites(const ArrayRef<std::pair<FragmentNum, CallSite>> NewCallSites) {
1444+
llvm::copy(NewCallSites, std::back_inserter(CallSites));
1445+
llvm::stable_sort(CallSites, llvm::less_first());
1446+
}
14241447

14251448
ArrayRef<uint8_t> getLSDAActionTable() const { return LSDAActionTable; }
14261449

14271450
const LSDATypeTableTy &getLSDATypeTable() const { return LSDATypeTable; }
14281451

1452+
unsigned getLSDATypeEncoding() const { return LSDATypeEncoding; }
1453+
14291454
const LSDATypeTableTy &getLSDATypeAddressTable() const {
14301455
return LSDATypeAddressTable;
14311456
}
@@ -1822,9 +1847,11 @@ class BinaryFunction {
18221847
return *this;
18231848
}
18241849

1825-
/// Set LSDA symbol for the function.
1850+
/// Set main LSDA symbol for the function.
18261851
BinaryFunction &setLSDASymbol(MCSymbol *Symbol) {
1827-
LSDASymbol = Symbol;
1852+
if (LSDASymbols.empty())
1853+
LSDASymbols.resize(1);
1854+
LSDASymbols.front() = Symbol;
18281855
return *this;
18291856
}
18301857

@@ -1848,30 +1875,25 @@ class BinaryFunction {
18481875
uint64_t getLSDAAddress() const { return LSDAAddress; }
18491876

18501877
/// Return symbol pointing to function's LSDA.
1851-
MCSymbol *getLSDASymbol() {
1852-
if (LSDASymbol)
1853-
return LSDASymbol;
1854-
if (CallSites.empty())
1878+
MCSymbol *getLSDASymbol(const FragmentNum F) {
1879+
if (F.get() < LSDASymbols.size() && LSDASymbols[F.get()] != nullptr)
1880+
return LSDASymbols[F.get()];
1881+
if (getCallSites(F).empty())
18551882
return nullptr;
18561883

1857-
LSDASymbol = BC.Ctx->getOrCreateSymbol(
1858-
Twine("GCC_except_table") + Twine::utohexstr(getFunctionNumber()));
1859-
1860-
return LSDASymbol;
1861-
}
1884+
if (F.get() >= LSDASymbols.size())
1885+
LSDASymbols.resize(F.get() + 1);
18621886

1863-
/// Return symbol pointing to function's LSDA for the cold part.
1864-
MCSymbol *getColdLSDASymbol(const FragmentNum Fragment) {
1865-
if (ColdLSDASymbol)
1866-
return ColdLSDASymbol;
1867-
if (ColdCallSites.empty())
1868-
return nullptr;
1887+
SmallString<256> SymbolName;
1888+
if (F == FragmentNum::main())
1889+
SymbolName = formatv("GCC_except_table{0:x-}", getFunctionNumber());
1890+
else
1891+
SymbolName = formatv("GCC_cold_except_table{0:x-}.{1}",
1892+
getFunctionNumber(), F.get());
18691893

1870-
ColdLSDASymbol =
1871-
BC.Ctx->getOrCreateSymbol(formatv("GCC_cold_except_table{0:x-}.{1}",
1872-
getFunctionNumber(), Fragment.get()));
1894+
LSDASymbols[F.get()] = BC.Ctx->getOrCreateSymbol(SymbolName);
18731895

1874-
return ColdLSDASymbol;
1896+
return LSDASymbols[F.get()];
18751897
}
18761898

18771899
void setOutputDataAddress(uint64_t Address) { OutputDataOffset = Address; }
@@ -2101,6 +2123,12 @@ class BinaryFunction {
21012123
/// cannot be statically evaluated for any given indirect branch.
21022124
bool postProcessIndirectBranches(MCPlusBuilder::AllocatorIdTy AllocId);
21032125

2126+
/// Validate that all data references to function offsets are claimed by
2127+
/// recognized jump tables. Register externally referenced blocks as entry
2128+
/// points. Returns true if there are no unclaimed externally referenced
2129+
/// offsets.
2130+
bool validateExternallyReferencedOffsets();
2131+
21042132
/// Return all call site profile info for this function.
21052133
IndirectCallSiteProfile &getAllCallSites() { return AllCallSites; }
21062134

bolt/include/bolt/Core/DebugData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ class DebugAddrWriter {
330330
protected:
331331
class AddressForDWOCU {
332332
public:
333-
AddressToIndexMap::iterator find(uint64_t Adddress) {
334-
return AddressToIndex.find(Adddress);
333+
AddressToIndexMap::iterator find(uint64_t Address) {
334+
return AddressToIndex.find(Address);
335335
}
336336
AddressToIndexMap::iterator end() { return AddressToIndex.end(); }
337337
AddressToIndexMap::iterator begin() { return AddressToIndex.begin(); }

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,14 @@ class MCPlusBuilder {
164164
void setTailCall(MCInst &Inst);
165165

166166
public:
167-
class InstructionIterator
168-
: public std::iterator<std::bidirectional_iterator_tag, MCInst> {
167+
class InstructionIterator {
169168
public:
169+
using iterator_category = std::bidirectional_iterator_tag;
170+
using value_type = MCInst;
171+
using difference_type = std::ptrdiff_t;
172+
using pointer = value_type *;
173+
using reference = value_type &;
174+
170175
class Impl {
171176
public:
172177
virtual Impl *Copy() const = 0;
@@ -1426,7 +1431,7 @@ class MCPlusBuilder {
14261431
return false;
14271432
}
14281433

1429-
/// Store \p Target absolute adddress to \p RegName
1434+
/// Store \p Target absolute address to \p RegName
14301435
virtual InstructionListType materializeAddress(const MCSymbol *Target,
14311436
MCContext *Ctx,
14321437
MCPhysReg RegName,

bolt/include/bolt/Passes/CacheMetrics.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,9 @@ namespace bolt {
2121
class BinaryFunction;
2222
namespace CacheMetrics {
2323

24-
/// Calculate various metrics related to instruction cache performance.
24+
/// Calculate and print various metrics related to instruction cache performance
2525
void printAll(const std::vector<BinaryFunction *> &BinaryFunctions);
2626

27-
/// Calculate Extended-TSP metric, which quantifies the expected number of
28-
/// i-cache misses for a given pair of basic blocks. The parameters are:
29-
/// - SrcAddr is the address of the source block;
30-
/// - SrcSize is the size of the source block;
31-
/// - DstAddr is the address of the destination block;
32-
/// - Count is the number of jumps between the pair of blocks.
33-
double extTSPScore(uint64_t SrcAddr, uint64_t SrcSize, uint64_t DstAddr,
34-
uint64_t Count);
35-
3627
} // namespace CacheMetrics
3728
} // namespace bolt
3829
} // namespace llvm

bolt/include/bolt/Passes/DataflowAnalysis.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,18 @@ class DataflowAnalysis {
439439
/// Define an iterator for navigating the expressions calculated by a
440440
/// dataflow analysis at each program point, when they are backed by a
441441
/// BitVector.
442-
class ExprIterator
443-
: public std::iterator<std::forward_iterator_tag, const MCInst *> {
442+
class ExprIterator {
444443
const BitVector *BV;
445444
const std::vector<MCInst *> &Expressions;
446445
int Idx;
447446

448447
public:
448+
using iterator_category = std::forward_iterator_tag;
449+
using value_type = const MCInst *;
450+
using difference_type = std::ptrdiff_t;
451+
using pointer = value_type *;
452+
using reference = value_type &;
453+
449454
ExprIterator &operator++() {
450455
assert(Idx != -1 && "Iterator already at the end");
451456
Idx = BV->find_next(Idx);

0 commit comments

Comments
 (0)