Skip to content

Commit bd6fe32

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-scalar-ph-phi-for
2 parents 1ea4a7c + 93869df commit bd6fe32

File tree

1,223 files changed

+25578
-11246
lines changed

Some content is hidden

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

1,223 files changed

+25578
-11246
lines changed

.github/new-prs-labeler.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,29 @@ backend:AArch64:
775775
- clang/include/clang/Sema/SemaARM.h
776776
- clang/lib/Sema/SemaARM.cpp
777777

778+
backend:Hexagon:
779+
- clang/include/clang/Basic/BuiltinsHexagon*.def
780+
- clang/include/clang/Sema/SemaHexagon.h
781+
- clang/lib/Basic/Targets/Hexagon.*
782+
- clang/lib/CodeGen/Targets/Hexagon.cpp
783+
- clang/lib/Driver/ToolChains/Hexagon.*
784+
- clang/lib/Sema/SemaHexagon.cpp
785+
- lld/ELF/Arch/Hexagon.cpp
786+
- lldb/source/Plugins/ABI/Hexagon/**
787+
- lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/**
788+
- llvm/include/llvm/BinaryFormat/ELFRelocs/Hexagon.def
789+
- llvm/include/llvm/IR/IntrinsicsHexagon*
790+
- llvm/include/llvm/Support/Hexagon*
791+
- llvm/lib/Support/Hexagon*
792+
- llvm/lib/Target/Hexagon/**
793+
- llvm/test/CodeGen/Hexagon/**
794+
- llvm/test/CodeGen/*/Hexagon/**
795+
- llvm/test/DebugInfo/*/Hexagon/**
796+
- llvm/test/Transforms/*/Hexagon
797+
- llvm/test/MC/Disassembler/Hexagon/**
798+
- llvm/test/MC/Hexagon/**
799+
- llvm/test/tools/llvm-objdump/ELF/Hexagon/**
800+
778801
backend:loongarch:
779802
- llvm/include/llvm/IR/IntrinsicsLoongArch.td
780803
- llvm/test/MC/LoongArch/**

bolt/include/bolt/Profile/YAMLProfileReader.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,29 @@ class YAMLProfileReader : public ProfileReaderBase {
7373
bool parseFunctionProfile(BinaryFunction &Function,
7474
const yaml::bolt::BinaryFunctionProfile &YamlBF);
7575

76+
/// Checks if a function profile matches a binary function.
77+
bool profileMatches(const yaml::bolt::BinaryFunctionProfile &Profile,
78+
const BinaryFunction &BF);
79+
7680
/// Infer function profile from stale data (collected on older binaries).
7781
bool inferStaleProfile(BinaryFunction &Function,
7882
const yaml::bolt::BinaryFunctionProfile &YamlBF);
7983

8084
/// Initialize maps for profile matching.
8185
void buildNameMaps(BinaryContext &BC);
8286

87+
/// Matches functions using exact name.
88+
size_t matchWithExactName();
89+
90+
/// Matches function using LTO comomon name.
91+
size_t matchWithLTOCommonName();
92+
93+
/// Matches functions using exact hash.
94+
size_t matchWithHash(BinaryContext &BC);
95+
96+
/// Matches functions with similarly named profiled functions.
97+
size_t matchWithNameSimilarity(BinaryContext &BC);
98+
8399
/// Update matched YAML -> BinaryFunction pair.
84100
void matchProfileToFunction(yaml::bolt::BinaryFunctionProfile &YamlBF,
85101
BinaryFunction &BF) {
@@ -93,9 +109,6 @@ class YAMLProfileReader : public ProfileReaderBase {
93109
ProfiledFunctions.emplace(&BF);
94110
}
95111

96-
/// Matches functions with similarly named profiled functions.
97-
uint64_t matchWithNameSimilarity(BinaryContext &BC);
98-
99112
/// Check if the profile uses an event with a given \p Name.
100113
bool usesEvent(StringRef Name) const;
101114
};

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,7 @@ struct CFISnapshot {
25382538
case MCCFIInstruction::OpWindowSave:
25392539
case MCCFIInstruction::OpNegateRAState:
25402540
case MCCFIInstruction::OpLLVMDefAspaceCfa:
2541+
case MCCFIInstruction::OpLabel:
25412542
llvm_unreachable("unsupported CFI opcode");
25422543
break;
25432544
case MCCFIInstruction::OpRememberState:
@@ -2675,6 +2676,7 @@ struct CFISnapshotDiff : public CFISnapshot {
26752676
case MCCFIInstruction::OpWindowSave:
26762677
case MCCFIInstruction::OpNegateRAState:
26772678
case MCCFIInstruction::OpLLVMDefAspaceCfa:
2679+
case MCCFIInstruction::OpLabel:
26782680
llvm_unreachable("unsupported CFI opcode");
26792681
return false;
26802682
case MCCFIInstruction::OpRememberState:
@@ -2823,6 +2825,7 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
28232825
case MCCFIInstruction::OpWindowSave:
28242826
case MCCFIInstruction::OpNegateRAState:
28252827
case MCCFIInstruction::OpLLVMDefAspaceCfa:
2828+
case MCCFIInstruction::OpLabel:
28262829
llvm_unreachable("unsupported CFI opcode");
28272830
break;
28282831
case MCCFIInstruction::OpGnuArgsSize:

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
129129
LLVM_DEBUG(dbgs() << " Cold part\n");
130130
for (const FunctionFragment &FF :
131131
Function.getLayout().getSplitFragments()) {
132+
// Skip empty fragments to avoid adding zero-address entries to maps.
133+
if (FF.empty())
134+
continue;
132135
ColdPartSource.emplace(FF.getAddress(), Function.getOutputAddress());
133136
Map.clear();
134137
for (const BinaryBasicBlock *const BB : FF)

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 97 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) {
342342
return Error::success();
343343
}
344344

345+
bool YAMLProfileReader::profileMatches(
346+
const yaml::bolt::BinaryFunctionProfile &Profile, const BinaryFunction &BF) {
347+
if (opts::IgnoreHash)
348+
return Profile.NumBasicBlocks == BF.size();
349+
return Profile.Hash == static_cast<uint64_t>(BF.getHash());
350+
}
351+
345352
bool YAMLProfileReader::mayHaveProfileData(const BinaryFunction &BF) {
346353
if (opts::MatchProfileWithFunctionHash)
347354
return true;
@@ -358,8 +365,92 @@ bool YAMLProfileReader::mayHaveProfileData(const BinaryFunction &BF) {
358365
return false;
359366
}
360367

361-
uint64_t YAMLProfileReader::matchWithNameSimilarity(BinaryContext &BC) {
362-
uint64_t MatchedWithNameSimilarity = 0;
368+
size_t YAMLProfileReader::matchWithExactName() {
369+
size_t MatchedWithExactName = 0;
370+
// This first pass assigns profiles that match 100% by name and by hash.
371+
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs)) {
372+
if (!BF)
373+
continue;
374+
BinaryFunction &Function = *BF;
375+
// Clear function call count that may have been set while pre-processing
376+
// the profile.
377+
Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE);
378+
379+
if (profileMatches(YamlBF, Function)) {
380+
matchProfileToFunction(YamlBF, Function);
381+
++MatchedWithExactName;
382+
}
383+
}
384+
return MatchedWithExactName;
385+
}
386+
387+
size_t YAMLProfileReader::matchWithHash(BinaryContext &BC) {
388+
// Iterates through profiled functions to match the first binary function with
389+
// the same exact hash. Serves to match identical, renamed functions.
390+
// Collisions are possible where multiple functions share the same exact hash.
391+
size_t MatchedWithHash = 0;
392+
if (opts::MatchProfileWithFunctionHash) {
393+
DenseMap<size_t, BinaryFunction *> StrictHashToBF;
394+
StrictHashToBF.reserve(BC.getBinaryFunctions().size());
395+
396+
for (auto &[_, BF] : BC.getBinaryFunctions())
397+
StrictHashToBF[BF.getHash()] = &BF;
398+
399+
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
400+
if (YamlBF.Used)
401+
continue;
402+
auto It = StrictHashToBF.find(YamlBF.Hash);
403+
if (It != StrictHashToBF.end() && !ProfiledFunctions.count(It->second)) {
404+
BinaryFunction *BF = It->second;
405+
matchProfileToFunction(YamlBF, *BF);
406+
++MatchedWithHash;
407+
}
408+
}
409+
}
410+
return MatchedWithHash;
411+
}
412+
413+
size_t YAMLProfileReader::matchWithLTOCommonName() {
414+
// This second pass allows name ambiguity for LTO private functions.
415+
size_t MatchedWithLTOCommonName = 0;
416+
for (const auto &[CommonName, LTOProfiles] : LTOCommonNameMap) {
417+
if (!LTOCommonNameFunctionMap.contains(CommonName))
418+
continue;
419+
std::unordered_set<BinaryFunction *> &Functions =
420+
LTOCommonNameFunctionMap[CommonName];
421+
// Return true if a given profile is matched to one of BinaryFunctions with
422+
// matching LTO common name.
423+
auto matchProfile = [&](yaml::bolt::BinaryFunctionProfile *YamlBF) {
424+
if (YamlBF->Used)
425+
return false;
426+
for (BinaryFunction *BF : Functions) {
427+
if (!ProfiledFunctions.count(BF) && profileMatches(*YamlBF, *BF)) {
428+
matchProfileToFunction(*YamlBF, *BF);
429+
++MatchedWithLTOCommonName;
430+
return true;
431+
}
432+
}
433+
return false;
434+
};
435+
bool ProfileMatched = llvm::any_of(LTOProfiles, matchProfile);
436+
437+
// If there's only one function with a given name, try to match it
438+
// partially.
439+
if (!ProfileMatched && LTOProfiles.size() == 1 && Functions.size() == 1 &&
440+
!LTOProfiles.front()->Used &&
441+
!ProfiledFunctions.count(*Functions.begin())) {
442+
matchProfileToFunction(*LTOProfiles.front(), **Functions.begin());
443+
++MatchedWithLTOCommonName;
444+
}
445+
}
446+
return MatchedWithLTOCommonName;
447+
}
448+
449+
size_t YAMLProfileReader::matchWithNameSimilarity(BinaryContext &BC) {
450+
if (opts::NameSimilarityFunctionMatchingThreshold == 0)
451+
return 0;
452+
453+
size_t MatchedWithNameSimilarity = 0;
363454
ItaniumPartialDemangler Demangler;
364455

365456
// Demangle and derive namespace from function name.
@@ -477,17 +568,6 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
477568
}
478569
YamlProfileToFunction.resize(YamlBP.Functions.size() + 1);
479570

480-
auto profileMatches = [](const yaml::bolt::BinaryFunctionProfile &Profile,
481-
BinaryFunction &BF) {
482-
if (opts::IgnoreHash)
483-
return Profile.NumBasicBlocks == BF.size();
484-
return Profile.Hash == static_cast<uint64_t>(BF.getHash());
485-
};
486-
487-
uint64_t MatchedWithExactName = 0;
488-
uint64_t MatchedWithHash = 0;
489-
uint64_t MatchedWithLTOCommonName = 0;
490-
491571
// Computes hash for binary functions.
492572
if (opts::MatchProfileWithFunctionHash) {
493573
for (auto &[_, BF] : BC.getBinaryFunctions()) {
@@ -501,84 +581,15 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
501581
}
502582
}
503583

504-
// This first pass assigns profiles that match 100% by name and by hash.
505-
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs)) {
506-
if (!BF)
507-
continue;
508-
BinaryFunction &Function = *BF;
509-
// Clear function call count that may have been set while pre-processing
510-
// the profile.
511-
Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE);
512-
513-
if (profileMatches(YamlBF, Function)) {
514-
matchProfileToFunction(YamlBF, Function);
515-
++MatchedWithExactName;
516-
}
517-
}
518-
519-
// Iterates through profiled functions to match the first binary function with
520-
// the same exact hash. Serves to match identical, renamed functions.
521-
// Collisions are possible where multiple functions share the same exact hash.
522-
if (opts::MatchProfileWithFunctionHash) {
523-
DenseMap<size_t, BinaryFunction *> StrictHashToBF;
524-
StrictHashToBF.reserve(BC.getBinaryFunctions().size());
525-
526-
for (auto &[_, BF] : BC.getBinaryFunctions())
527-
StrictHashToBF[BF.getHash()] = &BF;
528-
529-
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
530-
if (YamlBF.Used)
531-
continue;
532-
auto It = StrictHashToBF.find(YamlBF.Hash);
533-
if (It != StrictHashToBF.end() && !ProfiledFunctions.count(It->second)) {
534-
BinaryFunction *BF = It->second;
535-
matchProfileToFunction(YamlBF, *BF);
536-
++MatchedWithHash;
537-
}
538-
}
539-
}
540-
541-
// This second pass allows name ambiguity for LTO private functions.
542-
for (const auto &[CommonName, LTOProfiles] : LTOCommonNameMap) {
543-
if (!LTOCommonNameFunctionMap.contains(CommonName))
544-
continue;
545-
std::unordered_set<BinaryFunction *> &Functions =
546-
LTOCommonNameFunctionMap[CommonName];
547-
// Return true if a given profile is matched to one of BinaryFunctions with
548-
// matching LTO common name.
549-
auto matchProfile = [&](yaml::bolt::BinaryFunctionProfile *YamlBF) {
550-
if (YamlBF->Used)
551-
return false;
552-
for (BinaryFunction *BF : Functions) {
553-
if (!ProfiledFunctions.count(BF) && profileMatches(*YamlBF, *BF)) {
554-
matchProfileToFunction(*YamlBF, *BF);
555-
++MatchedWithLTOCommonName;
556-
return true;
557-
}
558-
}
559-
return false;
560-
};
561-
bool ProfileMatched = llvm::any_of(LTOProfiles, matchProfile);
562-
563-
// If there's only one function with a given name, try to match it
564-
// partially.
565-
if (!ProfileMatched && LTOProfiles.size() == 1 && Functions.size() == 1 &&
566-
!LTOProfiles.front()->Used &&
567-
!ProfiledFunctions.count(*Functions.begin())) {
568-
matchProfileToFunction(*LTOProfiles.front(), **Functions.begin());
569-
++MatchedWithLTOCommonName;
570-
}
571-
}
584+
const size_t MatchedWithExactName = matchWithExactName();
585+
const size_t MatchedWithHash = matchWithHash(BC);
586+
const size_t MatchedWithLTOCommonName = matchWithLTOCommonName();
587+
const size_t MatchedWithNameSimilarity = matchWithNameSimilarity(BC);
572588

573589
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs))
574590
if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF))
575591
matchProfileToFunction(YamlBF, *BF);
576592

577-
// Uses name similarity to match functions that were not matched by name.
578-
uint64_t MatchedWithNameSimilarity =
579-
opts::NameSimilarityFunctionMatchingThreshold > 0
580-
? matchWithNameSimilarity(BC)
581-
: 0;
582593

583594
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions)
584595
if (!YamlBF.Used && opts::Verbosity >= 1)

bolt/test/X86/register-fragments-bolt-symbols.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
# PREAGGWARM: B X:0 #chain.warm# 1 0
1414
# RUN: perf2bolt %t.warm.bolt -p %t.preagg.warm --pa -o %t.warm.fdata -w %t.warm.yaml \
1515
# RUN: -v=1 | FileCheck %s --check-prefix=CHECK-BOLT-WARM
16+
# RUN: FileCheck %s --input-file %t.warm.fdata --check-prefix=CHECK-FDATA-WARM
17+
# RUN: FileCheck %s --input-file %t.warm.yaml --check-prefix=CHECK-YAML-WARM
1618

1719
# CHECK-BOLT-WARM: marking chain.warm/1(*2) as a fragment of chain
20+
# CHECK-FDATA-WARM: chain
21+
# CHECK-YAML-WARM: chain
1822

1923
# RUN: sed -i 's|chain|chain/2|g' %t.fdata
2024
# RUN: llvm-objcopy --localize-symbol=chain %t.main.o

0 commit comments

Comments
 (0)