Skip to content

Commit 2ab1d52

Browse files
authored
Merge pull request #140 from sx-aurora-dev/feature/merge-upstream-20220117
Feature/merge upstream 20220117
2 parents 1391300 + 03fcab4 commit 2ab1d52

File tree

3,121 files changed

+93911
-67950
lines changed

Some content is hidden

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

3,121 files changed

+93911
-67950
lines changed

.github/workflows/issue-subscriber.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,16 @@ 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+
chmod a+x github-automation.py
17+
pip install PyGithub
18+
1319
- name: Update watchers
14-
uses: actions/github-script@v5
15-
with:
16-
github-token: ${{ secrets.ISSUE_MENTION_SECRET }}
17-
script: |
18-
const teamname = "issue-subscribers-" + context.payload.label.name.replace(/ /g, "-").replace(":","-").replace("/","-");
19-
const comment = "@llvm/" + teamname;
20-
try {
21-
// This will throw an exception if the team does not exist and no
22-
// comment will be created.
23-
team = await github.rest.teams.getByName({
24-
org: context.repo.owner,
25-
team_slug: teamname
26-
});
27-
github.rest.issues.createComment({
28-
issue_number: context.issue.number,
29-
owner: context.repo.owner,
30-
repo: context.repo.repo,
31-
body: comment
32-
});
33-
} catch (e){
34-
console.log(e);
35-
}
20+
run: |
21+
./github-automation.py \
22+
--token ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }} \
23+
issue-subscriber \
24+
--issue-number ${{ github.event.issue.number }} \
25+
--label-name ${{ github.event.label.name }}

bolt/CMakeLists.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,33 @@ if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
99
set(BOLT_ENABLE_RUNTIME ON)
1010
endif()
1111

12+
set(BOLT_CLANG_EXE "" CACHE FILEPATH "Path to clang executable for the target \
13+
architecture for use in BOLT tests")
14+
set(BOLT_LLD_EXE "" CACHE FILEPATH "Path to lld executable for the target \
15+
architecture for use in BOLT tests")
16+
1217
set(BOLT_INCLUDE_TESTS OFF)
1318
if (LLVM_INCLUDE_TESTS)
14-
string(FIND "${LLVM_ENABLE_PROJECTS}" "clang" POSITION)
15-
if (NOT ${POSITION} EQUAL -1)
16-
string(FIND "${LLVM_ENABLE_PROJECTS}" "lld" POSITION)
17-
if (NOT ${POSITION} EQUAL -1)
19+
if ("clang" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_CLANG_EXE)
20+
if ("clang" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_CLANG_EXE)
21+
message(WARNING "BOLT_CLANG_EXE is set and clang project is enabled. \
22+
BOLT_CLANG_EXE will be used for BOLT tests.")
23+
endif()
24+
if ("lld" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_LLD_EXE)
25+
if ("lld" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_LLD_EXE)
26+
message(WARNING "BOLT_LLD_EXE is set and lld project is enabled. \
27+
BOLT_LLD_EXE will be used for BOLT tests.")
28+
endif()
1829
set(BOLT_INCLUDE_TESTS ON)
1930
else()
20-
message(WARNING "Not including BOLT tests since lld is disabled")
31+
message(WARNING "Not including BOLT tests since lld is disabled. \
32+
Enable lld in LLVM_ENABLE_PROJECTS or provide a path to lld binary \
33+
in BOLT_LLD_EXE.")
2134
endif()
2235
else()
23-
message(WARNING "Not including BOLT tests since clang is disabled")
36+
message(WARNING "Not including BOLT tests since clang is disabled. \
37+
Enable clang in LLVM_ENABLE_PROJECTS or provide a path to clang \
38+
binary in BOLT_CLANG_EXE.")
2439
endif()
2540
endif()
2641

bolt/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ encounter any issues.
3737

3838
### Docker Image
3939

40-
You can build and use the docker image containing BOLT using our [docker file](./bolt/utils/docker/Dockerfile).
40+
You can build and use the docker image containing BOLT using our [docker file](utils/docker/Dockerfile).
4141
Alternatively, you can build BOLT manually using the steps below.
4242

4343
### Manual Build
@@ -77,7 +77,7 @@ Or if you rather use tcmalloc:
7777

7878
## Usage
7979

80-
For a complete practical guide of using BOLT see [Optimizing Clang with BOLT](./bolt/docs/OptimizingClang.md).
80+
For a complete practical guide of using BOLT see [Optimizing Clang with BOLT](docs/OptimizingClang.md).
8181

8282
### Step 0
8383

bolt/include/bolt/Core/DebugData.h

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,6 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
498498
Patch(uint32_t O, DebugPatchKind K) : Offset(O), Kind(K) {}
499499
DebugPatchKind getKind() const { return Kind; }
500500

501-
virtual ~Patch(){};
502-
503501
static bool classof(const Patch *Writer) {
504502
return Writer->getKind() == DebugPatchKind::PatchBaseClass;
505503
}
@@ -656,9 +654,42 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
656654
std::unordered_map<uint32_t, uint32_t> computeNewOffsets();
657655

658656
private:
657+
struct PatchDeleter {
658+
void operator()(Patch *P) const {
659+
Patch *Pp = reinterpret_cast<Patch *>(P);
660+
switch (Pp->Kind) {
661+
default:
662+
llvm_unreachable(
663+
"Not all delete instances handled for Patch derived classes");
664+
case DebugPatchKind::PatchValue32:
665+
delete reinterpret_cast<DebugPatch32 *>(P);
666+
break;
667+
case DebugPatchKind::PatchValue64to32:
668+
delete reinterpret_cast<DebugPatch64to32 *>(P);
669+
break;
670+
case DebugPatchKind::PatchValue64:
671+
delete reinterpret_cast<DebugPatch64 *>(P);
672+
break;
673+
case DebugPatchKind::PatchValueVariable:
674+
delete reinterpret_cast<DebugPatchVariableSize *>(P);
675+
break;
676+
case DebugPatchKind::ReferencePatchValue:
677+
delete reinterpret_cast<DebugPatchReference *>(P);
678+
break;
679+
case DebugPatchKind::DWARFUnitOffsetBaseLabel:
680+
delete reinterpret_cast<DWARFUnitOffsetBaseLabel *>(P);
681+
break;
682+
case DebugPatchKind::DestinationReferenceLabel:
683+
delete reinterpret_cast<DestinationReferenceLabel *>(P);
684+
break;
685+
}
686+
}
687+
};
688+
using UniquePatchPtrType = std::unique_ptr<Patch, PatchDeleter>;
689+
659690
uint64_t DWPUnitOffset{0};
660691
uint32_t ChangeInSize{0};
661-
std::vector<std::unique_ptr<Patch>> DebugPatches;
692+
std::vector<UniquePatchPtrType> DebugPatches;
662693
/// Mutex used for parallel processing of debug info.
663694
std::mutex WriterMutex;
664695
/// Stores fully resolved addresses of DIEs that are being referenced.

bolt/include/bolt/Passes/ReorderUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ClusterPairCacheThreadSafe {
142142
private:
143143
size_t Size;
144144
std::vector<ValueType> Cache;
145-
std::vector<bool> Valid;
145+
BitVector Valid;
146146

147147
size_t index(const Cluster *First, const Cluster *Second) const {
148148
return (First->id() * Size) + Second->id();

bolt/include/bolt/Passes/ShrinkWrapping.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class ShrinkWrapping {
295295
/// of moving this Callee-Saved Reg
296296
DenseMap<unsigned, std::vector<uint32_t>> DeletedPushCFIs;
297297
DenseMap<unsigned, std::vector<uint32_t>> DeletedPopCFIs;
298-
std::vector<bool> HasDeletedOffsetCFIs;
298+
BitVector HasDeletedOffsetCFIs;
299299
SmallPtrSet<const MCCFIInstruction *, 16> UpdatedCFIs;
300300
std::vector<BitVector> UsesByReg;
301301
std::vector<int64_t> PushOffsetByReg;

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,8 @@ class RewriteInstance {
279279

280280
/// Return a list of all sections to include in the output binary.
281281
/// Populate \p NewSectionIndex with a map of input to output indices.
282-
template <typename ELFT,
283-
typename ELFShdrTy = typename object::ELFObjectFile<ELFT>::Elf_Shdr>
284-
std::vector<ELFShdrTy>
282+
template <typename ELFT>
283+
std::vector<typename object::ELFObjectFile<ELFT>::Elf_Shdr>
285284
getOutputSections(object::ELFObjectFile<ELFT> *File,
286285
std::vector<uint32_t> &NewSectionIndex);
287286

@@ -293,13 +292,12 @@ class RewriteInstance {
293292
/// based on the input file symbol table passed in \p SymTabSection.
294293
/// \p IsDynSym is set to true for dynamic symbol table since we
295294
/// are updating it in-place with minimal modifications.
296-
template <typename ELFT,
297-
typename ELFShdrTy = typename object::ELFObjectFile<ELFT>::Elf_Shdr,
298-
typename WriteFuncTy, typename StrTabFuncTy>
299-
void updateELFSymbolTable(object::ELFObjectFile<ELFT> *File, bool IsDynSym,
300-
const ELFShdrTy &SymTabSection,
301-
const std::vector<uint32_t> &NewSectionIndex,
302-
WriteFuncTy Write, StrTabFuncTy AddToStrTab);
295+
template <typename ELFT, typename WriteFuncTy, typename StrTabFuncTy>
296+
void updateELFSymbolTable(
297+
object::ELFObjectFile<ELFT> *File, bool IsDynSym,
298+
const typename object::ELFObjectFile<ELFT>::Elf_Shdr &SymTabSection,
299+
const std::vector<uint32_t> &NewSectionIndex, WriteFuncTy Write,
300+
StrTabFuncTy AddToStrTab);
303301

304302
/// Add a notes section containing the BOLT revision and command line options.
305303
void addBoltInfoSection();

bolt/lib/Core/DebugData.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ DebugAddrWriter *DebugLoclistWriter::AddrWriter = nullptr;
367367
void DebugInfoBinaryPatcher::addUnitBaseOffsetLabel(uint64_t Offset) {
368368
Offset -= DWPUnitOffset;
369369
std::lock_guard<std::mutex> Lock(WriterMutex);
370-
DebugPatches.emplace_back(std::make_unique<DWARFUnitOffsetBaseLabel>(Offset));
370+
DebugPatches.emplace_back(new DWARFUnitOffsetBaseLabel(Offset));
371371
}
372372

373373
void DebugInfoBinaryPatcher::addDestinationReferenceLabel(uint64_t Offset) {
@@ -377,8 +377,7 @@ void DebugInfoBinaryPatcher::addDestinationReferenceLabel(uint64_t Offset) {
377377
if (!RetVal.second)
378378
return;
379379

380-
DebugPatches.emplace_back(
381-
std::make_unique<DestinationReferenceLabel>(Offset));
380+
DebugPatches.emplace_back(new DestinationReferenceLabel(Offset));
382381
}
383382

384383
void DebugInfoBinaryPatcher::addReferenceToPatch(uint64_t Offset,
@@ -388,33 +387,32 @@ void DebugInfoBinaryPatcher::addReferenceToPatch(uint64_t Offset,
388387
Offset -= DWPUnitOffset;
389388
DestinationOffset -= DWPUnitOffset;
390389
std::lock_guard<std::mutex> Lock(WriterMutex);
391-
DebugPatches.emplace_back(std::make_unique<DebugPatchReference>(
392-
Offset, OldValueSize, DestinationOffset, Form));
390+
DebugPatches.emplace_back(
391+
new DebugPatchReference(Offset, OldValueSize, DestinationOffset, Form));
393392
}
394393

395394
void DebugInfoBinaryPatcher::addUDataPatch(uint64_t Offset, uint64_t NewValue,
396395
uint32_t OldValueSize) {
397396
Offset -= DWPUnitOffset;
398397
std::lock_guard<std::mutex> Lock(WriterMutex);
399398
DebugPatches.emplace_back(
400-
std::make_unique<DebugPatchVariableSize>(Offset, OldValueSize, NewValue));
399+
new DebugPatchVariableSize(Offset, OldValueSize, NewValue));
401400
}
402401

403402
void DebugInfoBinaryPatcher::addLE64Patch(uint64_t Offset, uint64_t NewValue) {
404403
Offset -= DWPUnitOffset;
405404
std::lock_guard<std::mutex> Lock(WriterMutex);
406-
DebugPatches.emplace_back(std::make_unique<DebugPatch64>(Offset, NewValue));
405+
DebugPatches.emplace_back(new DebugPatch64(Offset, NewValue));
407406
}
408407

409408
void DebugInfoBinaryPatcher::addLE32Patch(uint64_t Offset, uint32_t NewValue,
410409
uint32_t OldValueSize) {
411410
Offset -= DWPUnitOffset;
412411
std::lock_guard<std::mutex> Lock(WriterMutex);
413412
if (OldValueSize == 4)
414-
DebugPatches.emplace_back(std::make_unique<DebugPatch32>(Offset, NewValue));
413+
DebugPatches.emplace_back(new DebugPatch32(Offset, NewValue));
415414
else
416-
DebugPatches.emplace_back(
417-
std::make_unique<DebugPatch64to32>(Offset, NewValue));
415+
DebugPatches.emplace_back(new DebugPatch64to32(Offset, NewValue));
418416
}
419417

420418
void SimpleBinaryPatcher::addBinaryPatch(uint64_t Offset,
@@ -477,15 +475,14 @@ std::string SimpleBinaryPatcher::patchBinary(StringRef BinaryContents) {
477475
std::unordered_map<uint32_t, uint32_t>
478476
DebugInfoBinaryPatcher::computeNewOffsets() {
479477
std::unordered_map<uint32_t, uint32_t> CUMap;
480-
std::sort(
481-
DebugPatches.begin(), DebugPatches.end(),
482-
[](const std::unique_ptr<Patch> &V1, const std::unique_ptr<Patch> &V2) {
483-
return V1.get()->Offset < V2.get()->Offset;
484-
});
478+
std::sort(DebugPatches.begin(), DebugPatches.end(),
479+
[](const UniquePatchPtrType &V1, const UniquePatchPtrType &V2) {
480+
return V1.get()->Offset < V2.get()->Offset;
481+
});
485482

486483
// Calculating changes in .debug_info size from Patches to build a map of old
487484
// to updated reference destination offsets.
488-
for (std::unique_ptr<Patch> &PatchBase : DebugPatches) {
485+
for (UniquePatchPtrType &PatchBase : DebugPatches) {
489486
Patch *P = PatchBase.get();
490487
switch (P->Kind) {
491488
default:
@@ -546,7 +543,7 @@ std::string DebugInfoBinaryPatcher::patchBinary(StringRef BinaryContents) {
546543

547544
// Applying all the patches replacing current entry.
548545
// This might change the size of .debug_info section.
549-
for (const std::unique_ptr<Patch> &PatchBase : DebugPatches) {
546+
for (const UniquePatchPtrType &PatchBase : DebugPatches) {
550547
Patch *P = PatchBase.get();
551548
switch (P->Kind) {
552549
default:

bolt/lib/Passes/ReorderAlgorithm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ void TSPReorderAlgorithm::reorderBasicBlocks(const BinaryFunction &BF,
477477
// Define final function layout based on layout that maximizes weight
478478
uint64_t Last = BestLast;
479479
uint64_t Set = BestSet;
480-
std::vector<bool> Visited;
480+
BitVector Visited;
481481
Visited.resize(N);
482482
Visited[Last] = true;
483483
Order.push_back(IndexToBB[Last]);

bolt/lib/Passes/ShrinkWrapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ void ShrinkWrapping::rebuildCFI() {
19511951
}
19521952

19531953
bool ShrinkWrapping::perform() {
1954-
HasDeletedOffsetCFIs = std::vector<bool>(BC.MRI->getNumRegs(), false);
1954+
HasDeletedOffsetCFIs = BitVector(BC.MRI->getNumRegs(), false);
19551955
PushOffsetByReg = std::vector<int64_t>(BC.MRI->getNumRegs(), 0LL);
19561956
PopOffsetByReg = std::vector<int64_t>(BC.MRI->getNumRegs(), 0LL);
19571957
DomOrder = std::vector<MCPhysReg>(BC.MRI->getNumRegs(), 0);

0 commit comments

Comments
 (0)