Skip to content

Commit c094c90

Browse files
authored
Merge pull request flang-compiler#248 from TIFitis/amd-trunk-dev
Merge attempt by ../aomp/trunk/merge_from_main.sh into branch amd-trunk-dev
2 parents 10b3505 + 3d8a1c9 commit c094c90

File tree

3,428 files changed

+119767
-44868
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,428 files changed

+119767
-44868
lines changed

.github/new-prs-labeler.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
clang:dataflow:
2-
- clang/**/Analysis/**/*
2+
- clang/include/clang/Analysis/FlowSensitive/**/*
3+
- clang/lib/Analysis/FlowSensitive/**/*
4+
- clang/unittests/Analysis/FlowSensitive/**/*
5+
- clang/docs/DataFlowAnalysisIntro.md
6+
- clang/docs/DataFlowAnalysisIntroImages/**/*
37

48
clang:frontend:
59
- clang/lib/AST/**/*

.github/workflows/issue-subscriber.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
steps:
1616
- name: Setup Automation Script
1717
run: |
18-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/"$GITHUB_SHA"/llvm/utils/git/github-automation.py
19-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/"$GITHUB_SHA"/llvm/utils/git/requirements.txt
18+
curl -O -L --fail https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/"$GITHUB_SHA"/llvm/utils/git/github-automation.py
19+
curl -O -L --fail https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/"$GITHUB_SHA"/llvm/utils/git/requirements.txt
2020
chmod a+x github-automation.py
2121
pip install -r requirements.txt
2222

.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 \

.github/workflows/pr-subscriber.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
steps:
1616
- name: Setup Automation Script
1717
run: |
18-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/github-automation.py
19-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/requirements.txt
20-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/.github/workflows/pr-subscriber-wait.py
18+
curl -O -L --fail https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/github-automation.py
19+
curl -O -L --fail https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/requirements.txt
2120
chmod a+x github-automation.py
2221
pip install -r requirements.txt
2322

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: 12 additions & 3 deletions
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
}
@@ -1230,8 +1239,8 @@ class BinaryContext {
12301239
uint64_t
12311240
computeInstructionSize(const MCInst &Inst,
12321241
const MCCodeEmitter *Emitter = nullptr) const {
1233-
if (auto Size = MIB->getAnnotationWithDefault<uint32_t>(Inst, "Size"))
1234-
return Size;
1242+
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
1243+
return *Size;
12351244

12361245
if (!Emitter)
12371246
Emitter = this->MCE.get();

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 7 additions & 11 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

@@ -2309,15 +2310,10 @@ class BinaryFunction {
23092310
/// removed.
23102311
uint64_t translateInputToOutputAddress(uint64_t Address) const;
23112312

2312-
/// Take address ranges corresponding to the input binary and translate
2313-
/// them to address ranges in the output binary.
2314-
DebugAddressRangesVector translateInputToOutputRanges(
2315-
const DWARFAddressRangesVector &InputRanges) const;
2316-
2317-
/// Similar to translateInputToOutputRanges() but operates on location lists
2318-
/// and moves associated data to output location lists.
2319-
DebugLocationsVector
2320-
translateInputToOutputLocationList(const DebugLocationsVector &InputLL) const;
2313+
/// Translate a contiguous range of addresses in the input binary into a set
2314+
/// of ranges in the output binary.
2315+
DebugAddressRangesVector
2316+
translateInputToOutputRange(DebugAddressRange InRange) const;
23212317

23222318
/// Return true if the function is an AArch64 linker inserted veneer
23232319
bool isAArch64Veneer() const;

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: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/CodeGen/DIE.h"
1919
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
2020
#include "llvm/MC/MCDwarf.h"
21+
#include "llvm/Support/FormatVariadic.h"
2122
#include "llvm/Support/SMLoc.h"
2223
#include "llvm/Support/raw_ostream.h"
2324
#include <cstdint>
@@ -63,7 +64,7 @@ std::optional<AttrInfo> findAttributeInfo(const DWARFDie DIE,
6364
dwarf::Attribute Attr);
6465

6566
// DWARF5 Header in order of encoding.
66-
// Types represent encodnig sizes.
67+
// Types represent encoding sizes.
6768
using UnitLengthType = uint32_t;
6869
using VersionType = uint16_t;
6970
using AddressSizeType = uint8_t;
@@ -95,6 +96,12 @@ static inline bool operator<(const DebugAddressRange &LHS,
9596
return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC);
9697
}
9798

99+
inline raw_ostream &operator<<(raw_ostream &OS,
100+
const DebugAddressRange &Range) {
101+
OS << formatv("[{0:x}, {1:x})", Range.LowPC, Range.HighPC);
102+
return OS;
103+
}
104+
98105
/// DebugAddressRangesVector - represents a set of absolute address ranges.
99106
using DebugAddressRangesVector = SmallVector<DebugAddressRange, 2>;
100107

@@ -106,6 +113,18 @@ struct DebugLocationEntry {
106113
SmallVector<uint8_t, 4> Expr;
107114
};
108115

116+
inline raw_ostream &operator<<(raw_ostream &OS,
117+
const DebugLocationEntry &Entry) {
118+
OS << formatv("[{0:x}, {1:x}) : [", Entry.LowPC, Entry.HighPC);
119+
const char *Sep = "";
120+
for (unsigned Byte : Entry.Expr) {
121+
OS << Sep << Byte;
122+
Sep = ", ";
123+
}
124+
OS << "]";
125+
return OS;
126+
}
127+
109128
using DebugLocationsVector = SmallVector<DebugLocationEntry, 4>;
110129

111130
/// References a row in a DWARFDebugLine::LineTable by the DWARF
@@ -353,13 +372,13 @@ class DebugAddrWriter {
353372
}
354373

355374
/// Updates AddressToIndex Map.
356-
/// Follows the same symantics as unordered map [].
375+
/// Follows the same semantics as unordered map [].
357376
void updateAddressToIndex(uint64_t Address, uint32_t Index) {
358377
AddressToIndex[Address] = Index;
359378
}
360379

361380
/// Updates IndexToAddress Map.
362-
/// Follows the same symantics as unordered map [].
381+
/// Follows the same semantics as unordered map [].
363382
void updateIndexToAddrss(uint64_t Address, uint32_t Index) {
364383
IndexToAddress[Index] = Address;
365384
}
@@ -455,7 +474,7 @@ class DebugStrWriter {
455474
}
456475

457476
/// Adds string to .debug_str.
458-
/// On first invokation it initializes internal data stractures.
477+
/// On first invocation it initializes internal data structures.
459478
uint32_t addString(StringRef Str);
460479

461480
/// Returns False if no strings were added to .debug_str.
@@ -466,7 +485,7 @@ class DebugStrWriter {
466485
std::mutex WriterMutex;
467486
/// Initializes Buffer and Stream.
468487
void initialize();
469-
/// Creats internal data stractures.
488+
/// Creates internal data structures.
470489
void create();
471490
std::unique_ptr<DebugStrBufferVector> StrBuffer;
472491
std::unique_ptr<raw_svector_ostream> StrStream;
@@ -566,7 +585,7 @@ class DebugLoclistWriter : public DebugLocWriter {
566585
void finalize(DIEBuilder &DIEBldr, DIE &Die) override;
567586

568587
/// Returns CU ID.
569-
/// For Skelton CU it is a CU Offset.
588+
/// For Skeleton CU it is a CU Offset.
570589
/// For DWO CU it is a DWO ID.
571590
uint64_t getCUID() const {
572591
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: 17 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 {
@@ -67,6 +72,7 @@ class MCAnnotation {
6772
kConditionalTailCall, /// CTC.
6873
kOffset, /// Offset in the function.
6974
kLabel, /// MCSymbol pointing to this instruction.
75+
kSize, /// Size of the instruction.
7076
kGeneric /// First generic annotation.
7177
};
7278

@@ -106,10 +112,11 @@ template <typename ValueType> class MCSimpleAnnotation : public MCAnnotation {
106112
/// Return a number of operands in \Inst excluding operands representing
107113
/// annotations.
108114
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;
115+
for (signed I = Inst.getNumOperands() - 1; I >= 0; --I) {
116+
if (Inst.getOperand(I).isInst())
117+
return I;
118+
if (!Inst.getOperand(I).isImm())
119+
return Inst.getNumOperands();
113120
}
114121
return Inst.getNumOperands();
115122
}

0 commit comments

Comments
 (0)