Skip to content

Commit 5de254f

Browse files
author
Simon Moll
committed
Merge 8dca38d of LLVM upstream into 'develop'
2 parents 2f4a3c6 + 8dca38d commit 5de254f

File tree

12,060 files changed

+640198
-429185
lines changed

Some content is hidden

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

12,060 files changed

+640198
-429185
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ on:
1919
types:
2020
- created
2121
- edited
22+
issues:
23+
types:
24+
- opened
2225

2326
env:
24-
COMMENT_BODY: ${{ github.event.comment.body }}
27+
COMMENT_BODY: ${{ github.event.action == 'opened' && github.event.issue.body || github.event.comment.body }}
2528

2629
jobs:
2730
backport-commits:
@@ -30,7 +33,7 @@ jobs:
3033
if: >-
3134
(github.repository == 'llvm/llvm-project') &&
3235
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
33-
contains(github.event.comment.body, '/cherry-pick')
36+
contains(github.event.action == 'opened' && github.event.issue.body || github.event.comment.body, '/cherry-pick')
3437
steps:
3538
- name: Fetch LLVM sources
3639
uses: actions/checkout@v2

.github/workflows/issue-subscriber.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ jobs:
1818
pip install -r requirements.txt
1919
2020
- 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 }}
2124
run: |
2225
./github-automation.py \
23-
--token ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }} \
26+
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
2427
issue-subscriber \
25-
--issue-number ${{ github.event.issue.number }} \
26-
--label-name ${{ github.event.label.name }}
28+
--issue-number '${{ github.event.issue.number }}' \
29+
--label-name "$LABEL_NAME"

.github/workflows/llvm-bugs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
to: "llvm-bugs@lists.llvm.org",
4949
subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
5050
template: "new-github-issue",
51+
'o:tracking-clicks': 'no',
5152
'h:X-Mailgun-Variables': JSON.stringify(payload)
5253
};
5354

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Combinations of both are possible too, see
1717
# https://git-scm.com/docs/gitmailmap for format details.
1818
#
19-
# You can commit changes for your own names and email addresses without review.
19+
# You can commit changes for your own names and email addresses without review.
2020
# If you want to add entries for other people, please have them review the
2121
# addition.
2222
#

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ This is an example work-flow and configuration to get and build the LLVM source:
102102

103103
* Running a serial build will be **slow**. To improve speed, try running a
104104
parallel build. That's done by default in Ninja; for ``make``, use the option
105-
``-j NNN``, where ``NNN`` is the number of parallel jobs, e.g. the number of
106-
CPUs you have.
105+
``-j NNN``, where ``NNN`` is the number of parallel jobs to run.
106+
In most cases, you get the best performance if you specify the number of CPU threads you have.
107+
On some Unix systems, you can specify this with ``-j$(nproc)``.
107108

108109
* For more information see [CMake](https://llvm.org/docs/CMake.html)
109110

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class BinaryContext {
211211
std::map<unsigned, DwarfLineTable> DwarfLineTablesCUMap;
212212

213213
public:
214-
static std::unique_ptr<BinaryContext>
214+
static Expected<std::unique_ptr<BinaryContext>>
215215
createBinaryContext(const ObjectFile *File, bool IsPIC,
216216
std::unique_ptr<DWARFContext> DwCtx);
217217

@@ -489,7 +489,9 @@ class BinaryContext {
489489
void adjustCodePadding();
490490

491491
/// Regular page size.
492-
static constexpr unsigned RegularPageSize = 0x1000;
492+
unsigned RegularPageSize{0x1000};
493+
static constexpr unsigned RegularPageSizeX86 = 0x1000;
494+
static constexpr unsigned RegularPageSizeAArch64 = 0x10000;
493495

494496
/// Huge page size to use.
495497
static constexpr unsigned HugePageSize = 0x200000;
@@ -1192,14 +1194,14 @@ class BinaryContext {
11921194
/*PIC=*/!HasFixedLoadAddress));
11931195
MCEInstance.LocalCtx->setObjectFileInfo(MCEInstance.LocalMOFI.get());
11941196
MCEInstance.MCE.reset(
1195-
TheTarget->createMCCodeEmitter(*MII, *MRI, *MCEInstance.LocalCtx));
1197+
TheTarget->createMCCodeEmitter(*MII, *MCEInstance.LocalCtx));
11961198
return MCEInstance;
11971199
}
11981200

11991201
/// Creating MCStreamer instance.
12001202
std::unique_ptr<MCStreamer>
12011203
createStreamer(llvm::raw_pwrite_stream &OS) const {
1202-
MCCodeEmitter *MCE = TheTarget->createMCCodeEmitter(*MII, *MRI, *Ctx);
1204+
MCCodeEmitter *MCE = TheTarget->createMCCodeEmitter(*MII, *Ctx);
12031205
MCAsmBackend *MAB =
12041206
TheTarget->createMCAsmBackend(*STI, *MRI, MCTargetOptions());
12051207
std::unique_ptr<MCObjectWriter> OW = MAB->createObjectWriter(OS);

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,10 +1299,11 @@ class BinaryFunction {
12991299
case ELF::R_X86_64_32:
13001300
case ELF::R_X86_64_32S:
13011301
case ELF::R_X86_64_64:
1302+
case ELF::R_X86_64_PC8:
1303+
case ELF::R_X86_64_PC32:
1304+
case ELF::R_X86_64_PC64:
13021305
Relocations[Offset] = Relocation{Offset, Symbol, RelType, Addend, Value};
13031306
return;
1304-
case ELF::R_X86_64_PC32:
1305-
case ELF::R_X86_64_PC8:
13061307
case ELF::R_X86_64_PLT32:
13071308
case ELF::R_X86_64_GOTPCRELX:
13081309
case ELF::R_X86_64_REX_GOTPCRELX:

bolt/include/bolt/Core/BinarySection.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ class BinarySection {
296296
return make_range(Relocations.begin(), Relocations.end());
297297
}
298298

299+
/// Iterate over all dynamic relocations for this section.
300+
iterator_range<RelocationSetType::iterator> dynamicRelocations() {
301+
return make_range(DynamicRelocations.begin(), DynamicRelocations.end());
302+
}
303+
304+
/// Iterate over all dynamic relocations for this section.
305+
iterator_range<RelocationSetType::const_iterator> dynamicRelocations() const {
306+
return make_range(DynamicRelocations.begin(), DynamicRelocations.end());
307+
}
308+
299309
/// Does this section have any non-pending relocations?
300310
bool hasRelocations() const { return !Relocations.empty(); }
301311

bolt/include/bolt/Core/DebugData.h

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,13 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
490490
PatchBaseClass,
491491
PatchValue32,
492492
PatchValue64to32,
493+
PatchValue32GenericSize,
493494
PatchValue64,
494495
PatchValueVariable,
495496
ReferencePatchValue,
496497
DWARFUnitOffsetBaseLabel,
497-
DestinationReferenceLabel
498+
DestinationReferenceLabel,
499+
NewDebugEntry
498500
};
499501

500502
struct Patch {
@@ -535,6 +537,22 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
535537
uint32_t Value;
536538
};
537539

540+
/// Patch for 4 byte entry, where original entry size is not 4 bytes or 8
541+
/// bytes.
542+
struct DebugPatch32GenericSize : public Patch {
543+
DebugPatch32GenericSize(uint32_t O, uint32_t V, uint32_t OVS)
544+
: Patch(O, DebugPatchKind::PatchValue32GenericSize) {
545+
Value = V;
546+
OldValueSize = OVS;
547+
}
548+
549+
static bool classof(const Patch *Writer) {
550+
return Writer->getKind() == DebugPatchKind::PatchValue32GenericSize;
551+
}
552+
uint32_t Value;
553+
uint32_t OldValueSize;
554+
};
555+
538556
struct DebugPatch64 : public Patch {
539557
DebugPatch64(uint32_t O, uint64_t V)
540558
: Patch(O, DebugPatchKind::PatchValue64) {
@@ -605,6 +623,22 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
605623
}
606624
};
607625

626+
struct NewDebugEntry : public Patch {
627+
NewDebugEntry() = delete;
628+
NewDebugEntry(uint32_t O, std::string &&V)
629+
: Patch(O, DebugPatchKind::NewDebugEntry) {
630+
CurrentOrder = NewDebugEntry::OrderCounter++;
631+
Value = std::move(V);
632+
}
633+
634+
static bool classof(const Patch *Writer) {
635+
return Writer->getKind() == DebugPatchKind::NewDebugEntry;
636+
}
637+
static uint32_t OrderCounter;
638+
uint32_t CurrentOrder;
639+
std::string Value;
640+
};
641+
608642
virtual PatcherKind getKind() const override {
609643
return PatcherKind::DebugInfoBinaryPatcher;
610644
}
@@ -646,6 +680,12 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
646680
void addReferenceToPatch(uint64_t Offset, uint32_t DestinationOffset,
647681
uint32_t OldValueSize, dwarf::Form Form);
648682

683+
/// Inserts a new uint32_t \p Value at the end of \p DIE .
684+
void insertNewEntry(const DWARFDie &DIE, uint32_t);
685+
686+
/// Inserts a new encoded \p Value at the end of \p DIE .
687+
void insertNewEntry(const DWARFDie &DIE, std::string &&Value);
688+
649689
/// Clears unordered set for DestinationLabels.
650690
void clearDestinationLabels() { DestinationLabels.clear(); }
651691

@@ -670,6 +710,9 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
670710
case DebugPatchKind::PatchValue64to32:
671711
delete reinterpret_cast<DebugPatch64to32 *>(P);
672712
break;
713+
case DebugPatchKind::PatchValue32GenericSize:
714+
delete reinterpret_cast<DebugPatch32GenericSize *>(P);
715+
break;
673716
case DebugPatchKind::PatchValue64:
674717
delete reinterpret_cast<DebugPatch64 *>(P);
675718
break;
@@ -685,6 +728,9 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
685728
case DebugPatchKind::DestinationReferenceLabel:
686729
delete reinterpret_cast<DestinationReferenceLabel *>(P);
687730
break;
731+
case DebugPatchKind::NewDebugEntry:
732+
delete reinterpret_cast<NewDebugEntry *>(P);
733+
break;
688734
}
689735
}
690736
};
@@ -728,10 +774,19 @@ class DebugAbbrevWriter {
728774
uint8_t NewAttrForm;
729775
};
730776

777+
struct AbbrevEntry {
778+
dwarf::Attribute Attr;
779+
dwarf::Form Form;
780+
};
781+
731782
using PatchesTy = std::unordered_map<const DWARFAbbreviationDeclaration *,
732783
SmallVector<PatchInfo, 2>>;
733784
std::unordered_map<const DWARFUnit *, PatchesTy> Patches;
734785

786+
using AbbrevEntryTy = std::unordered_map<const DWARFAbbreviationDeclaration *,
787+
SmallVector<AbbrevEntry, 2>>;
788+
std::unordered_map<const DWARFUnit *, AbbrevEntryTy> NewAbbrevEntries;
789+
735790
/// DWARF context containing abbreviations.
736791
DWARFContext &Context;
737792

@@ -777,6 +832,27 @@ class DebugAbbrevWriter {
777832
PatchInfo{AttrTag, NewAttrTag, NewAttrForm});
778833
}
779834

835+
/// Adds attribute \p AttrTag and \p NewAttrForm in abbreviation declaration
836+
/// \p Abbrev belonging to CU \p Unit .
837+
void addAttribute(const DWARFUnit &Unit,
838+
const DWARFAbbreviationDeclaration *Abbrev,
839+
dwarf::Attribute AttrTag, dwarf::Form AttrForm) {
840+
assert(&Unit.getContext() == &Context &&
841+
"cannot update attribute from a different DWARF context");
842+
std::lock_guard<std::mutex> Lock(WriterMutex);
843+
bool AlreadyAdded = false;
844+
for (AbbrevEntry &E : NewAbbrevEntries[&Unit][Abbrev])
845+
if (E.Attr == AttrTag) {
846+
AlreadyAdded = true;
847+
break;
848+
}
849+
850+
if (AlreadyAdded)
851+
return;
852+
NewAbbrevEntries[&Unit][Abbrev].emplace_back(
853+
AbbrevEntry{AttrTag, AttrForm});
854+
}
855+
780856
/// Return a buffer with concatenated abbrev sections for all CUs and TUs
781857
/// in the associated DWARF context. Section offsets could be queried using
782858
/// getAbbreviationsOffsetForUnit() interface. For DWP, we are using DWOId
@@ -882,6 +958,17 @@ class DwarfLineTable {
882958
}
883959
};
884960

961+
struct AttrInfo {
962+
DWARFFormValue V;
963+
uint64_t Offset;
964+
uint32_t Size; // Size of the attribute.
965+
};
966+
967+
Optional<AttrInfo>
968+
findAttributeInfo(const DWARFDie DIE,
969+
const DWARFAbbreviationDeclaration *AbbrevDecl,
970+
uint32_t Index);
971+
885972
} // namespace bolt
886973
} // namespace llvm
887974

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class MCPlusBuilder {
7474
AllocatorIdTy MaxAllocatorId = 0;
7575

7676
/// We encode Index and Value into a 64-bit immediate operand value.
77-
static int64_t encodeAnnotationImm(unsigned Index, int64_t Value) {
78-
assert(Index < 256 && "annotation index max value exceeded");
79-
assert((Value == (Value << 8) >> 8) && "annotation value out of range");
77+
static int64_t encodeAnnotationImm(uint8_t Index, int64_t Value) {
78+
if (LLVM_UNLIKELY(Value != extractAnnotationValue(Value)))
79+
report_fatal_error("annotation value out of range");
8080

8181
Value &= 0xff'ffff'ffff'ffff;
8282
Value |= (int64_t)Index << 56;
@@ -85,14 +85,13 @@ class MCPlusBuilder {
8585
}
8686

8787
/// Extract annotation index from immediate operand value.
88-
static unsigned extractAnnotationIndex(int64_t ImmValue) {
88+
static uint8_t extractAnnotationIndex(int64_t ImmValue) {
8989
return ImmValue >> 56;
9090
}
9191

9292
/// Extract annotation value from immediate operand value.
9393
static int64_t extractAnnotationValue(int64_t ImmValue) {
94-
ImmValue &= 0xff'ffff'ffff'ffff;
95-
return (ImmValue << 8) >> 8;
94+
return SignExtend64<56>(ImmValue & 0xff'ffff'ffff'ffffULL);
9695
}
9796

9897
MCInst *getAnnotationInst(const MCInst &Inst) const {
@@ -425,9 +424,7 @@ class MCPlusBuilder {
425424

426425
/// Return a register number that is guaranteed to not match with
427426
/// any real register on the underlying architecture.
428-
virtual MCPhysReg getNoRegister() const {
429-
llvm_unreachable("not implemented");
430-
}
427+
MCPhysReg getNoRegister() const { return MCRegister::NoRegister; }
431428

432429
/// Return a register corresponding to a function integer argument \p ArgNo
433430
/// if the argument is passed in a register. Or return the result of
@@ -1295,6 +1292,16 @@ class MCPlusBuilder {
12951292
return false;
12961293
}
12971294

1295+
/// Convert a move instruction into a conditional move instruction, given a
1296+
/// condition code.
1297+
virtual bool
1298+
convertMoveToConditionalMove(MCInst &Inst, unsigned CC,
1299+
bool AllowStackMemOp = false,
1300+
bool AllowBasePtrStackMemOp = false) const {
1301+
llvm_unreachable("not implemented");
1302+
return false;
1303+
}
1304+
12981305
/// Lower a tail call instruction \p Inst if required by target.
12991306
virtual bool lowerTailCall(MCInst &Inst) {
13001307
llvm_unreachable("not implemented");
@@ -1328,6 +1335,16 @@ class MCPlusBuilder {
13281335
return IndirectBranchType::UNKNOWN;
13291336
}
13301337

1338+
/// Analyze branch \p Instruction in PLT section and try to determine
1339+
/// associated got entry address.
1340+
virtual uint64_t analyzePLTEntry(MCInst &Instruction,
1341+
InstructionIterator Begin,
1342+
InstructionIterator End,
1343+
uint64_t BeginPC) const {
1344+
llvm_unreachable("not implemented");
1345+
return 0;
1346+
}
1347+
13311348
virtual bool analyzeVirtualMethodCall(InstructionIterator Begin,
13321349
InstructionIterator End,
13331350
std::vector<MCInst *> &MethodFetchInsns,

0 commit comments

Comments
 (0)