Skip to content

Commit bf1cd99

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into fdate
2 parents 9589699 + a604c4b commit bf1cd99

File tree

2,522 files changed

+77510
-20642
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,522 files changed

+77510
-20642
lines changed

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,33 @@ jobs:
1111
- name: Fetch LLVM sources
1212
uses: actions/checkout@v4
1313
with:
14-
fetch-depth: 2 # Fetches only the last 2 commits
14+
ref: ${{ github.event.pull_request.head.sha }}
15+
16+
- name: Checkout through merge base
17+
uses: rmacklin/fetch-through-merge-base@v0
18+
with:
19+
base_ref: ${{ github.event.pull_request.base.ref }}
20+
head_ref: ${{ github.event.pull_request.head.sha }}
21+
deepen_length: 500
1522

1623
- name: Get changed files
1724
id: changed-files
1825
uses: tj-actions/changed-files@v39
1926
with:
2027
separator: ","
21-
fetch_depth: 2000 # Fetches only the last 2000 commits
28+
skip_initial_fetch: true
29+
30+
# We need to make sure that we aren't executing/using any code from the
31+
# PR for security reasons as we're using pull_request_target. Checkout
32+
# the target branch with the necessary files.
33+
- name: Fetch code formatting utils
34+
uses: actions/checkout@v4
35+
with:
36+
sparse-checkout: |
37+
llvm/utils/git/requirements_formatting.txt
38+
llvm/utils/git/code-format-helper.py
39+
sparse-checkout-cone-mode: false
40+
path: code-format-tools
2241

2342
- name: "Listed files"
2443
run: |
@@ -35,10 +54,10 @@ jobs:
3554
with:
3655
python-version: '3.11'
3756
cache: 'pip'
38-
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
57+
cache-dependency-path: 'code-format-tools/llvm/utils/git/requirements_formatting.txt'
3958

4059
- name: Install python dependencies
41-
run: pip install -r llvm/utils/git/requirements_formatting.txt
60+
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
4261

4362
- name: Run code formatter
4463
env:
@@ -47,7 +66,7 @@ jobs:
4766
END_REV: ${{ github.event.pull_request.head.sha }}
4867
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
4968
run: |
50-
python llvm/utils/git/code-format-helper.py \
69+
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
5170
--token ${{ secrets.GITHUB_TOKEN }} \
5271
--issue-number $GITHUB_PR_NUMBER \
5372
--start-rev $START_REV \

bolt/docs/doxygen.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ PREDEFINED =
19541954
EXPAND_AS_DEFINED =
19551955

19561956
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
1957-
# remove all refrences to function-like macros that are alone on a line, have an
1957+
# remove all references to function-like macros that are alone on a line, have an
19581958
# all uppercase name, and do not end with a semicolon. Such function macros are
19591959
# typically used for boiler-plate code, and will confuse the parser if not
19601960
# removed.

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,15 @@ class BinaryContext {
680680
/// the execution of the binary is completed.
681681
std::optional<uint64_t> FiniFunctionAddress;
682682

683+
/// DT_FINI.
684+
std::optional<uint64_t> FiniAddress;
685+
686+
/// DT_FINI_ARRAY. Only used when DT_FINI is not set.
687+
std::optional<uint64_t> FiniArrayAddress;
688+
689+
/// DT_FINI_ARRAYSZ. Only used when DT_FINI is not set.
690+
std::optional<uint64_t> FiniArraySize;
691+
683692
/// Page alignment used for code layout.
684693
uint64_t PageAlign{HugePageSize};
685694

@@ -941,7 +950,7 @@ class BinaryContext {
941950
bool registerFragment(BinaryFunction &TargetFunction,
942951
BinaryFunction &Function) const;
943952

944-
/// Add unterprocedural reference for \p Function to \p Address
953+
/// Add interprocedural reference for \p Function to \p Address
945954
void addInterproceduralReference(BinaryFunction *Function, uint64_t Address) {
946955
InterproceduralReferences.push_back({Function, Address});
947956
}

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,8 @@ class BinaryFunction {
14451445

14461446
/// Rebuilds BBs layout, ignoring dead BBs. Returns the number of removed
14471447
/// BBs and the removed number of bytes of code.
1448-
std::pair<unsigned, uint64_t> eraseInvalidBBs();
1448+
std::pair<unsigned, uint64_t>
1449+
eraseInvalidBBs(const MCCodeEmitter *Emitter = nullptr);
14491450

14501451
/// Get the relative order between two basic blocks in the original
14511452
/// layout. The result is > 0 if B occurs before A and < 0 if B
@@ -2172,7 +2173,7 @@ class BinaryFunction {
21722173
/// is corrupted. If it is unable to fix it, it returns false.
21732174
bool finalizeCFIState();
21742175

2175-
/// Return true if this function needs an address-transaltion table after
2176+
/// Return true if this function needs an address-translation table after
21762177
/// its code emission.
21772178
bool requiresAddressTranslation() const;
21782179

bolt/include/bolt/Core/BinarySection.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class BinarySection {
127127
return *ContentsOrErr;
128128
}
129129

130-
/// Get the set of relocations refering to data in this section that
130+
/// Get the set of relocations referring to data in this section that
131131
/// has been reordered. The relocation offsets will be modified to
132132
/// reflect the new data locations.
133133
RelocationSetType reorderRelocations(bool Inplace) const;
@@ -375,8 +375,12 @@ class BinarySection {
375375
/// Add a dynamic relocation at the given /p Offset.
376376
void addDynamicRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
377377
uint64_t Addend, uint64_t Value = 0) {
378-
assert(Offset < getSize() && "offset not within section bounds");
379-
DynamicRelocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
378+
addDynamicRelocation(Relocation{Offset, Symbol, Type, Addend, Value});
379+
}
380+
381+
void addDynamicRelocation(const Relocation &Reloc) {
382+
assert(Reloc.Offset < getSize() && "offset not within section bounds");
383+
DynamicRelocations.emplace(Reloc);
380384
}
381385

382386
/// Add relocation against the original contents of this section.
@@ -410,6 +414,18 @@ class BinarySection {
410414
return Itr != DynamicRelocations.end() ? &*Itr : nullptr;
411415
}
412416

417+
std::optional<Relocation> takeDynamicRelocationAt(uint64_t Offset) {
418+
Relocation Key{Offset, 0, 0, 0, 0};
419+
auto Itr = DynamicRelocations.find(Key);
420+
421+
if (Itr == DynamicRelocations.end())
422+
return std::nullopt;
423+
424+
Relocation Reloc = *Itr;
425+
DynamicRelocations.erase(Itr);
426+
return Reloc;
427+
}
428+
413429
uint64_t hash(const BinaryData &BD) const {
414430
std::map<const BinaryData *, uint64_t> Cache;
415431
return hash(BD, Cache);

bolt/include/bolt/Core/DebugData.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ std::optional<AttrInfo> findAttributeInfo(const DWARFDie DIE,
6464
dwarf::Attribute Attr);
6565

6666
// DWARF5 Header in order of encoding.
67-
// Types represent encodnig sizes.
67+
// Types represent encoding sizes.
6868
using UnitLengthType = uint32_t;
6969
using VersionType = uint16_t;
7070
using AddressSizeType = uint8_t;
@@ -372,13 +372,13 @@ class DebugAddrWriter {
372372
}
373373

374374
/// Updates AddressToIndex Map.
375-
/// Follows the same symantics as unordered map [].
375+
/// Follows the same semantics as unordered map [].
376376
void updateAddressToIndex(uint64_t Address, uint32_t Index) {
377377
AddressToIndex[Address] = Index;
378378
}
379379

380380
/// Updates IndexToAddress Map.
381-
/// Follows the same symantics as unordered map [].
381+
/// Follows the same semantics as unordered map [].
382382
void updateIndexToAddrss(uint64_t Address, uint32_t Index) {
383383
IndexToAddress[Index] = Address;
384384
}
@@ -474,7 +474,7 @@ class DebugStrWriter {
474474
}
475475

476476
/// Adds string to .debug_str.
477-
/// On first invokation it initializes internal data stractures.
477+
/// On first invocation it initializes internal data structures.
478478
uint32_t addString(StringRef Str);
479479

480480
/// Returns False if no strings were added to .debug_str.
@@ -485,7 +485,7 @@ class DebugStrWriter {
485485
std::mutex WriterMutex;
486486
/// Initializes Buffer and Stream.
487487
void initialize();
488-
/// Creats internal data stractures.
488+
/// Creates internal data structures.
489489
void create();
490490
std::unique_ptr<DebugStrBufferVector> StrBuffer;
491491
std::unique_ptr<raw_svector_ostream> StrStream;
@@ -585,7 +585,7 @@ class DebugLoclistWriter : public DebugLocWriter {
585585
void finalize(DIEBuilder &DIEBldr, DIE &Die) override;
586586

587587
/// Returns CU ID.
588-
/// For Skelton CU it is a CU Offset.
588+
/// For Skeleton CU it is a CU Offset.
589589
/// For DWO CU it is a DWO ID.
590590
uint64_t getCUID() const {
591591
return CU.isDWOUnit() ? *CU.getDWOId() : CU.getOffset();

bolt/include/bolt/Core/DynoStats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class DynoStats {
121121
/// Maps instruction opcodes to:
122122
/// 1. Accumulated executed instruction counts.
123123
/// 2. a multimap that records highest execution counts, function names,
124-
/// and BB offsets where intructions of these opcodes occur.
124+
/// and BB offsets where instructions of these opcodes occur.
125125
using MaxOpcodeHistogramTy =
126126
std::multimap<uint64_t, std::pair<StringRef, uint32_t>>;
127127
using OpcodeHistogramTy =

bolt/include/bolt/Core/Exceptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class EHFrameParser {
7777
/// void PatcherCallback(uint64_t Value, uint64_t Offset, uint64_t Type);
7878
///
7979
/// where Value is a value of the reference, Offset - is an offset into the
80-
/// frame data at which the reference occured, and Type is a DWARF encoding
80+
/// frame data at which the reference occurred, and Type is a DWARF encoding
8181
/// type of the reference.
8282
static Error parse(DWARFDataExtractor Data, uint64_t EHFrameAddress,
8383
PatcherCallbackTy PatcherCallback);

bolt/include/bolt/Core/MCPlus.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ namespace MCPlus {
3232
/// pad and the uint64_t represents the action.
3333
using MCLandingPad = std::pair<const MCSymbol *, uint64_t>;
3434

35-
/// An extension to MCInst is provided via an extra operand of type MCInst with
36-
/// ANNOTATION_LABEL opcode (i.e. we are tying an annotation instruction to an
37-
/// existing one). The annotation instruction contains a list of Immediate
38-
/// operands. Each operand either contains a value, or is a pointer to
39-
/// an instance of class MCAnnotation.
35+
/// An extension to MCInst is provided via extra operands, i.e. operands that
36+
/// are not used in the instruction assembly. Any kind of metadata can be
37+
/// attached to MCInst with this "annotation" extension using MCPlusBuilder
38+
/// interface.
39+
//
40+
/// The first extra operand must be of type kInst with an empty (nullptr)
41+
/// value. The kInst operand type is unused on most non-VLIW architectures.
42+
/// We use it to mark the beginning of annotations operands. The rest of the
43+
/// operands are of Immediate type with annotation info encoded into the value
44+
/// of the immediate.
4045
///
4146
/// There are 2 distinct groups of annotations. The first group is a first-class
4247
/// annotation that affects semantics of the instruction, such as an
@@ -55,7 +60,7 @@ using MCLandingPad = std::pair<const MCSymbol *, uint64_t>;
5560
/// of their corresponding operand.
5661
///
5762
/// Annotations in the second group could be addressed either by name, or by
58-
/// by and index which could be queried by providing a name.
63+
/// by index which could be queried by providing the name.
5964
class MCAnnotation {
6065
public:
6166
enum Kind {
@@ -106,10 +111,11 @@ template <typename ValueType> class MCSimpleAnnotation : public MCAnnotation {
106111
/// Return a number of operands in \Inst excluding operands representing
107112
/// annotations.
108113
inline unsigned getNumPrimeOperands(const MCInst &Inst) {
109-
if (Inst.getNumOperands() > 0 && std::prev(Inst.end())->isInst()) {
110-
assert(std::prev(Inst.end())->getInst()->getOpcode() ==
111-
TargetOpcode::ANNOTATION_LABEL);
112-
return Inst.getNumOperands() - 1;
114+
for (signed I = Inst.getNumOperands() - 1; I >= 0; --I) {
115+
if (Inst.getOperand(I).isInst())
116+
return I;
117+
if (!Inst.getOperand(I).isImm())
118+
return Inst.getNumOperands();
113119
}
114120
return Inst.getNumOperands();
115121
}

0 commit comments

Comments
 (0)