Skip to content

Commit c181731

Browse files
Merge pull request #799 from zhiweij1/pulldown20230404
[SYCLomatic] Manually pulldown from sycl branch to SYCLomatic branch on 20230404
2 parents badea7f + f562191 commit c181731

File tree

11,024 files changed

+1443395
-208895
lines changed

Some content is hidden

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

11,024 files changed

+1443395
-208895
lines changed

.clang-tidy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
2-
WarningsAsErrors: 'llvm-*,misc-*,-misc-no-recursion,-misc-unused-parameters,readability-identifier-naming,-llvm-header-guard'
1+
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
32
CheckOptions:
43
- key: readability-identifier-naming.ClassCase
54
value: CamelCase

.mailmap

Lines changed: 1 addition & 0 deletions

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@ class BinaryBasicBlock {
427427
/// Return branch info corresponding to an edge going to \p Succ basic block.
428428
const BinaryBranchInfo &getBranchInfo(const BinaryBasicBlock &Succ) const;
429429

430-
/// Return branch info corresponding to an edge going to a basic block with
431-
/// label \p Label.
432-
BinaryBranchInfo &getBranchInfo(const MCSymbol *Label);
433-
434430
/// Set branch information for the outgoing edge to block \p Succ.
435431
void setSuccessorBranchInfo(const BinaryBasicBlock &Succ, uint64_t Count,
436432
uint64_t MispredictedCount) {

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ class BinaryContext {
366366
BinaryFunction *getBinaryFunctionContainingAddress(uint64_t Address,
367367
bool CheckPastEnd = false,
368368
bool UseMaxSize = false);
369+
const BinaryFunction *
370+
getBinaryFunctionContainingAddress(uint64_t Address,
371+
bool CheckPastEnd = false,
372+
bool UseMaxSize = false) const {
373+
return const_cast<BinaryContext *>(this)
374+
->getBinaryFunctionContainingAddress(Address, CheckPastEnd, UseMaxSize);
375+
}
369376

370377
/// Return a BinaryFunction that starts at a given \p Address.
371378
BinaryFunction *getBinaryFunctionAtAddress(uint64_t Address);
@@ -504,9 +511,11 @@ class BinaryContext {
504511
/// Optionally, populate \p Address from jump table entries. The entries
505512
/// could be partially populated if the jump table detection fails.
506513
bool analyzeJumpTable(const uint64_t Address,
507-
const JumpTable::JumpTableType Type, BinaryFunction &BF,
514+
const JumpTable::JumpTableType Type,
515+
const BinaryFunction &BF,
508516
const uint64_t NextJTAddress = 0,
509-
JumpTable::AddressesType *EntriesAsAddress = nullptr);
517+
JumpTable::AddressesType *EntriesAsAddress = nullptr,
518+
bool *HasEntryInFragment = nullptr) const;
510519

511520
/// After jump table locations are established, this function will populate
512521
/// their EntriesAsAddress based on memory contents.
@@ -1143,7 +1152,7 @@ class BinaryContext {
11431152

11441153
/// Return a relocation registered at a given \p Address, or nullptr if there
11451154
/// is no relocation at such address.
1146-
const Relocation *getRelocationAt(uint64_t Address);
1155+
const Relocation *getRelocationAt(uint64_t Address) const;
11471156

11481157
/// Register a presence of PC-relative relocation at the given \p Address.
11491158
void addPCRelativeDataRelocation(uint64_t Address) {

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 37 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ class BinaryFunction {
167167
/// List of relocations associated with data in the constant island
168168
std::map<uint64_t, Relocation> Relocations;
169169

170+
/// Set true if constant island contains dynamic relocations, which may
171+
/// happen if binary is linked with -z notext option.
172+
bool HasDynamicRelocations{false};
173+
170174
/// Offsets in function that are data values in a constant island identified
171175
/// after disassembling
172176
std::map<uint64_t, MCSymbol *> Offsets;
@@ -349,6 +353,9 @@ class BinaryFunction {
349353
/// This attribute is only valid when hasCFG() == true.
350354
bool HasCanonicalCFG{true};
351355

356+
/// True if another function body was merged into this one.
357+
bool HasFunctionsFoldedInto{false};
358+
352359
/// Name for the section this function code should reside in.
353360
std::string CodeSectionName;
354361

@@ -1226,96 +1233,11 @@ class BinaryFunction {
12261233
return InputOffsetToAddressMap;
12271234
}
12281235

1229-
void addRelocationAArch64(uint64_t Offset, MCSymbol *Symbol, uint64_t RelType,
1230-
uint64_t Addend, uint64_t Value, bool IsCI) {
1231-
std::map<uint64_t, Relocation> &Rels =
1232-
(IsCI) ? Islands->Relocations : Relocations;
1233-
switch (RelType) {
1234-
case ELF::R_AARCH64_ABS64:
1235-
case ELF::R_AARCH64_ABS32:
1236-
case ELF::R_AARCH64_ABS16:
1237-
case ELF::R_AARCH64_ADD_ABS_LO12_NC:
1238-
case ELF::R_AARCH64_ADR_GOT_PAGE:
1239-
case ELF::R_AARCH64_ADR_PREL_LO21:
1240-
case ELF::R_AARCH64_ADR_PREL_PG_HI21:
1241-
case ELF::R_AARCH64_ADR_PREL_PG_HI21_NC:
1242-
case ELF::R_AARCH64_LD64_GOT_LO12_NC:
1243-
case ELF::R_AARCH64_LDST8_ABS_LO12_NC:
1244-
case ELF::R_AARCH64_LDST16_ABS_LO12_NC:
1245-
case ELF::R_AARCH64_LDST32_ABS_LO12_NC:
1246-
case ELF::R_AARCH64_LDST64_ABS_LO12_NC:
1247-
case ELF::R_AARCH64_LDST128_ABS_LO12_NC:
1248-
case ELF::R_AARCH64_TLSDESC_ADD_LO12:
1249-
case ELF::R_AARCH64_TLSDESC_ADR_PAGE21:
1250-
case ELF::R_AARCH64_TLSDESC_ADR_PREL21:
1251-
case ELF::R_AARCH64_TLSDESC_LD64_LO12:
1252-
case ELF::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
1253-
case ELF::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
1254-
case ELF::R_AARCH64_MOVW_UABS_G0:
1255-
case ELF::R_AARCH64_MOVW_UABS_G0_NC:
1256-
case ELF::R_AARCH64_MOVW_UABS_G1:
1257-
case ELF::R_AARCH64_MOVW_UABS_G1_NC:
1258-
case ELF::R_AARCH64_MOVW_UABS_G2:
1259-
case ELF::R_AARCH64_MOVW_UABS_G2_NC:
1260-
case ELF::R_AARCH64_MOVW_UABS_G3:
1261-
case ELF::R_AARCH64_PREL16:
1262-
case ELF::R_AARCH64_PREL32:
1263-
case ELF::R_AARCH64_PREL64:
1264-
Rels[Offset] = Relocation{Offset, Symbol, RelType, Addend, Value};
1265-
return;
1266-
case ELF::R_AARCH64_CALL26:
1267-
case ELF::R_AARCH64_JUMP26:
1268-
case ELF::R_AARCH64_TSTBR14:
1269-
case ELF::R_AARCH64_CONDBR19:
1270-
case ELF::R_AARCH64_TLSDESC_CALL:
1271-
case ELF::R_AARCH64_TLSLE_ADD_TPREL_HI12:
1272-
case ELF::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
1273-
return;
1274-
default:
1275-
llvm_unreachable("Unexpected AArch64 relocation type in code");
1276-
}
1277-
}
1278-
1279-
void addRelocationX86(uint64_t Offset, MCSymbol *Symbol, uint64_t RelType,
1280-
uint64_t Addend, uint64_t Value) {
1281-
switch (RelType) {
1282-
case ELF::R_X86_64_8:
1283-
case ELF::R_X86_64_16:
1284-
case ELF::R_X86_64_32:
1285-
case ELF::R_X86_64_32S:
1286-
case ELF::R_X86_64_64:
1287-
case ELF::R_X86_64_PC8:
1288-
case ELF::R_X86_64_PC32:
1289-
case ELF::R_X86_64_PC64:
1290-
case ELF::R_X86_64_GOTPCRELX:
1291-
case ELF::R_X86_64_REX_GOTPCRELX:
1292-
Relocations[Offset] = Relocation{Offset, Symbol, RelType, Addend, Value};
1293-
return;
1294-
case ELF::R_X86_64_PLT32:
1295-
case ELF::R_X86_64_GOTPCREL:
1296-
case ELF::R_X86_64_TPOFF32:
1297-
case ELF::R_X86_64_GOTTPOFF:
1298-
return;
1299-
default:
1300-
llvm_unreachable("Unexpected x86 relocation type in code");
1301-
}
1302-
}
1303-
13041236
/// Register relocation type \p RelType at a given \p Address in the function
13051237
/// against \p Symbol.
13061238
/// Assert if the \p Address is not inside this function.
13071239
void addRelocation(uint64_t Address, MCSymbol *Symbol, uint64_t RelType,
1308-
uint64_t Addend, uint64_t Value) {
1309-
assert(Address >= getAddress() && Address < getAddress() + getMaxSize() &&
1310-
"address is outside of the function");
1311-
uint64_t Offset = Address - getAddress();
1312-
if (BC.isAArch64()) {
1313-
return addRelocationAArch64(Offset, Symbol, RelType, Addend, Value,
1314-
isInConstantIsland(Address));
1315-
}
1316-
1317-
return addRelocationX86(Offset, Symbol, RelType, Addend, Value);
1318-
}
1240+
uint64_t Addend, uint64_t Value);
13191241

13201242
/// Return the name of the section this function originated from.
13211243
std::optional<StringRef> getOriginSectionName() const {
@@ -1407,6 +1329,9 @@ class BinaryFunction {
14071329
/// Return true if the body of the function was merged into another function.
14081330
bool isFolded() const { return FoldedIntoFunction != nullptr; }
14091331

1332+
/// Return true if other functions were folded into this one.
1333+
bool hasFunctionsFoldedInto() const { return HasFunctionsFoldedInto; }
1334+
14101335
/// If this function was folded, return the function it was folded into.
14111336
BinaryFunction *getFoldedIntoFunction() const { return FoldedIntoFunction; }
14121337

@@ -1460,8 +1385,6 @@ class BinaryFunction {
14601385

14611386
ArrayRef<uint8_t> getLSDATypeIndexTable() const { return LSDATypeIndexTable; }
14621387

1463-
const LabelsMapType &getLabels() const { return Labels; }
1464-
14651388
IslandInfo &getIslandInfo() {
14661389
assert(Islands && "function expected to have constant islands");
14671390
return *Islands;
@@ -1770,6 +1693,9 @@ class BinaryFunction {
17701693

17711694
void setFolded(BinaryFunction *BF) { FoldedIntoFunction = BF; }
17721695

1696+
/// Indicate that another function body was merged with this function.
1697+
void setHasFunctionsFoldedInto() { HasFunctionsFoldedInto = true; }
1698+
17731699
BinaryFunction &setPersonalityFunction(uint64_t Addr) {
17741700
assert(!PersonalityFunction && "can't set personality function twice");
17751701
PersonalityFunction = BC.getOrCreateGlobalSymbol(Addr, "FUNCat");
@@ -1828,7 +1754,7 @@ class BinaryFunction {
18281754

18291755
/// Returns if this function is a child of \p Other function.
18301756
bool isChildOf(const BinaryFunction &Other) const {
1831-
return llvm::is_contained(ParentFragments, &Other);
1757+
return ParentFragments.contains(&Other);
18321758
}
18331759

18341760
/// Set the profile data for the number of times the function was called.
@@ -1938,6 +1864,28 @@ class BinaryFunction {
19381864
return Symbol;
19391865
}
19401866

1867+
/// Support dynamic relocations in constant islands, which may happen if
1868+
/// binary is linked with -z notext option.
1869+
void markIslandDynamicRelocationAtAddress(uint64_t Address) {
1870+
if (!isInConstantIsland(Address)) {
1871+
errs() << "BOLT-ERROR: dynamic relocation found for text section at 0x"
1872+
<< Twine::utohexstr(Address) << "\n";
1873+
exit(1);
1874+
}
1875+
1876+
// Mark island to have dynamic relocation
1877+
Islands->HasDynamicRelocations = true;
1878+
1879+
// Create island access, so we would emit the label and
1880+
// move binary data during updateOutputValues, making us emit
1881+
// dynamic relocation with the right offset value.
1882+
getOrCreateIslandAccess(Address);
1883+
}
1884+
1885+
bool hasDynamicRelocationAtIsland() const {
1886+
return !!(Islands && Islands->HasDynamicRelocations);
1887+
}
1888+
19411889
/// Called by an external function which wishes to emit references to constant
19421890
/// island symbols of this function. We create a proxy for it, so we emit
19431891
/// separate symbols when emitting our constant island on behalf of this other

bolt/include/bolt/Core/BinarySection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class BinarySection {
275275
bool isTBSS() const { return isBSS() && isTLS(); }
276276
bool isVirtual() const { return ELFType == ELF::SHT_NOBITS; }
277277
bool isRela() const { return ELFType == ELF::SHT_RELA; }
278+
bool isRelr() const { return ELFType == ELF::SHT_RELR; }
278279
bool isWritable() const { return (ELFFlags & ELF::SHF_WRITE); }
279280
bool isAllocatable() const {
280281
if (isELF()) {

bolt/include/bolt/Core/JumpTable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class JumpTable : public BinaryData {
6666
/// The type of this jump table.
6767
JumpTableType Type;
6868

69+
/// Whether this jump table has entries pointing to multiple functions.
70+
bool IsSplit{false};
71+
6972
/// All the entries as labels.
7073
std::vector<MCSymbol *> Entries;
7174

0 commit comments

Comments
 (0)