Skip to content

Commit 2ce8db6

Browse files
authored
Merge branch 'llvm:main' into update_release_to_os_logic
2 parents add8c65 + ad3ad15 commit 2ce8db6

File tree

2,921 files changed

+127725
-43887
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,921 files changed

+127725
-43887
lines changed

.github/new-prs-labeler.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ mlgo:
668668
- llvm/lib/CodeGen/ML*
669669
- llvm/unittests/CodeGen/ML*
670670
- llvm/test/CodeGen/MLRegAlloc/**
671-
- llvm/utils/mlgo-utils/*
671+
- llvm/utils/mlgo-utils/**
672672

673673
tools:llvm-exegesis:
674674
- llvm/tools/llvm-exegesis/**

.github/workflows/libcxx-build-and-test.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ jobs:
242242
- { config: mingw-dll, mingw: true }
243243
- { config: mingw-static, mingw: true }
244244
- { config: mingw-dll-i686, mingw: true }
245+
- { config: mingw-incomplete-sysroot, mingw: true }
245246
steps:
246247
- uses: actions/checkout@v4
247248
- name: Install dependencies
@@ -260,6 +261,12 @@ jobs:
260261
del llvm-mingw*.zip
261262
mv llvm-mingw* c:\llvm-mingw
262263
echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
264+
- name: Simulate a from-scratch build of llvm-mingw
265+
if: ${{ matrix.config == 'mingw-incomplete-sysroot' }}
266+
run: |
267+
rm -r c:\llvm-mingw\include\c++
268+
rm -r c:\llvm-mingw\*-w64-mingw32\lib\libc++*
269+
rm -r c:\llvm-mingw\*-w64-mingw32\lib\libunwind*
263270
- name: Add Git Bash to the path
264271
run: |
265272
echo "c:\Program Files\Git\usr\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append

.github/workflows/release-binaries.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,22 @@ jobs:
442442
name: ${{ needs.prepare.outputs.release-binary-filename }}-attestation
443443
path: ${{ needs.prepare.outputs.release-binary-filename }}.jsonl
444444

445+
- name: Checkout Release Scripts
446+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
447+
with:
448+
sparse-checkout: |
449+
llvm/utils/release/github-upload-release.py
450+
llvm/utils/git/requirements.txt
451+
sparse-checkout-cone-mode: false
452+
453+
- name: Install Python Requirements
454+
run: |
455+
pip install --require-hashes -r ./llvm/utils/git/requirements.txt
456+
445457
- name: Upload Release
446458
shell: bash
447459
run: |
448-
sudo apt install python3-github
449-
./llvm-project/llvm/utils/release/github-upload-release.py \
460+
./llvm/utils/release/github-upload-release.py \
450461
--token ${{ github.token }} \
451462
--release ${{ needs.prepare.outputs.release-version }} \
452463
upload \

bolt/include/bolt/Utils/Utils.h

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ std::string getEscapedName(const StringRef &Name);
4141
/// Return the unescaped name
4242
std::string getUnescapedName(const StringRef &Name);
4343

44+
/// Return a common part for a given \p Name wrt a given \p Suffixes list.
45+
/// Preserve the suffix if \p KeepSuffix is set, only dropping characters
46+
/// following it, otherwise drop the suffix as well.
47+
std::optional<StringRef> getCommonName(const StringRef Name, bool KeepSuffix,
48+
ArrayRef<StringRef> Suffixes);
4449
/// LTO-generated function names take a form:
4550
///
4651
/// <function_name>.lto_priv.<decimal_number>/...

bolt/lib/Profile/DataAggregator.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ MaxSamples("max-samples",
8888
cl::cat(AggregatorCategory));
8989

9090
extern cl::opt<opts::ProfileFormatKind> ProfileFormat;
91-
extern cl::opt<bool> ProfileUsePseudoProbes;
91+
extern cl::opt<bool> ProfileWritePseudoProbes;
9292
extern cl::opt<std::string> SaveProfile;
9393

9494
cl::opt<bool> ReadPreAggregated(
@@ -2300,7 +2300,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23002300
yaml::bolt::BinaryProfile BP;
23012301

23022302
const MCPseudoProbeDecoder *PseudoProbeDecoder =
2303-
opts::ProfileUsePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
2303+
opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
23042304

23052305
// Fill out the header info.
23062306
BP.Header.Version = 1;
@@ -2427,11 +2427,15 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
24272427
}
24282428
}
24292429
}
2430-
// Drop blocks without a hash, won't be useful for stale matching.
2431-
llvm::erase_if(YamlBF.Blocks,
2432-
[](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2433-
return YamlBB.Hash == (yaml::Hex64)0;
2434-
});
2430+
// Skip printing if there's no profile data
2431+
llvm::erase_if(
2432+
YamlBF.Blocks, [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2433+
auto HasCount = [](const auto &SI) { return SI.Count; };
2434+
bool HasAnyCount = YamlBB.ExecCount ||
2435+
llvm::any_of(YamlBB.Successors, HasCount) ||
2436+
llvm::any_of(YamlBB.CallSites, HasCount);
2437+
return !HasAnyCount;
2438+
});
24352439
BP.Functions.emplace_back(YamlBF);
24362440
}
24372441
}

bolt/lib/Profile/YAMLProfileReader.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ llvm::cl::opt<bool>
4949
llvm::cl::opt<bool> ProfileUseDFS("profile-use-dfs",
5050
cl::desc("use DFS order for YAML profile"),
5151
cl::Hidden, cl::cat(BoltOptCategory));
52-
53-
llvm::cl::opt<bool> ProfileUsePseudoProbes(
54-
"profile-use-pseudo-probes",
55-
cl::desc("Use pseudo probes for profile generation and matching"),
56-
cl::Hidden, cl::cat(BoltOptCategory));
5752
} // namespace opts
5853

5954
namespace llvm {

bolt/lib/Profile/YAMLProfileWriter.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "bolt/Profile/DataAggregator.h"
1414
#include "bolt/Profile/ProfileReaderBase.h"
1515
#include "bolt/Rewrite/RewriteInstance.h"
16+
#include "bolt/Utils/CommandLineOpts.h"
1617
#include "llvm/Support/CommandLine.h"
1718
#include "llvm/Support/FileSystem.h"
1819
#include "llvm/Support/raw_ostream.h"
@@ -21,8 +22,12 @@
2122
#define DEBUG_TYPE "bolt-prof"
2223

2324
namespace opts {
24-
extern llvm::cl::opt<bool> ProfileUseDFS;
25-
extern llvm::cl::opt<bool> ProfileUsePseudoProbes;
25+
using namespace llvm;
26+
extern cl::opt<bool> ProfileUseDFS;
27+
cl::opt<bool> ProfileWritePseudoProbes(
28+
"profile-write-pseudo-probes",
29+
cl::desc("Use pseudo probes in profile generation"), cl::Hidden,
30+
cl::cat(BoltOptCategory));
2631
} // namespace opts
2732

2833
namespace llvm {
@@ -59,7 +64,7 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS,
5964
yaml::bolt::BinaryFunctionProfile YamlBF;
6065
const BinaryContext &BC = BF.getBinaryContext();
6166
const MCPseudoProbeDecoder *PseudoProbeDecoder =
62-
opts::ProfileUsePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
67+
opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
6368

6469
const uint16_t LBRProfile = BF.getProfileFlags() & BinaryFunction::PF_LBR;
6570

bolt/lib/Rewrite/PseudoProbeRewriter.cpp

+41-15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "bolt/Rewrite/MetadataRewriter.h"
1515
#include "bolt/Rewrite/MetadataRewriters.h"
1616
#include "bolt/Utils/CommandLineOpts.h"
17+
#include "bolt/Utils/Utils.h"
1718
#include "llvm/IR/Function.h"
1819
#include "llvm/MC/MCPseudoProbe.h"
1920
#include "llvm/Support/CommandLine.h"
@@ -49,7 +50,7 @@ static cl::opt<PrintPseudoProbesOptions> PrintPseudoProbes(
4950
clEnumValN(PPP_All, "all", "enable all debugging printout")),
5051
cl::Hidden, cl::cat(BoltCategory));
5152

52-
extern cl::opt<bool> ProfileUsePseudoProbes;
53+
extern cl::opt<bool> ProfileWritePseudoProbes;
5354
} // namespace opts
5455

5556
namespace {
@@ -71,7 +72,8 @@ class PseudoProbeRewriter final : public MetadataRewriter {
7172

7273
/// Parse .pseudo_probe_desc section and .pseudo_probe section
7374
/// Setup Pseudo probe decoder
74-
void parsePseudoProbe();
75+
/// If \p ProfiledOnly is set, only parse records for functions with profile.
76+
void parsePseudoProbe(bool ProfiledOnly = false);
7577

7678
/// PseudoProbe decoder
7779
std::shared_ptr<MCPseudoProbeDecoder> ProbeDecoderPtr;
@@ -90,21 +92,21 @@ class PseudoProbeRewriter final : public MetadataRewriter {
9092
};
9193

9294
Error PseudoProbeRewriter::preCFGInitializer() {
93-
if (opts::ProfileUsePseudoProbes)
94-
parsePseudoProbe();
95+
if (opts::ProfileWritePseudoProbes)
96+
parsePseudoProbe(true);
9597

9698
return Error::success();
9799
}
98100

99101
Error PseudoProbeRewriter::postEmitFinalizer() {
100-
if (!opts::ProfileUsePseudoProbes)
102+
if (!opts::ProfileWritePseudoProbes)
101103
parsePseudoProbe();
102104
updatePseudoProbes();
103105

104106
return Error::success();
105107
}
106108

107-
void PseudoProbeRewriter::parsePseudoProbe() {
109+
void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
108110
MCPseudoProbeDecoder &ProbeDecoder(*ProbeDecoderPtr);
109111
PseudoProbeDescSection = BC.getUniqueSectionByName(".pseudo_probe_desc");
110112
PseudoProbeSection = BC.getUniqueSectionByName(".pseudo_probe");
@@ -133,10 +135,22 @@ void PseudoProbeRewriter::parsePseudoProbe() {
133135

134136
MCPseudoProbeDecoder::Uint64Set GuidFilter;
135137
MCPseudoProbeDecoder::Uint64Map FuncStartAddrs;
138+
SmallVector<StringRef, 0> Suffixes(
139+
{".destroy", ".resume", ".llvm.", ".cold", ".warm"});
136140
for (const BinaryFunction *F : BC.getAllBinaryFunctions()) {
141+
bool HasProfile = F->hasProfileAvailable();
137142
for (const MCSymbol *Sym : F->getSymbols()) {
138-
FuncStartAddrs[Function::getGUID(NameResolver::restore(Sym->getName()))] =
139-
F->getAddress();
143+
StringRef SymName = Sym->getName();
144+
for (auto Name : {std::optional(NameResolver::restore(SymName)),
145+
getCommonName(SymName, false, Suffixes)}) {
146+
if (!Name)
147+
continue;
148+
SymName = *Name;
149+
uint64_t GUID = Function::getGUID(SymName);
150+
FuncStartAddrs[GUID] = F->getAddress();
151+
if (ProfiledOnly && HasProfile)
152+
GuidFilter.insert(GUID);
153+
}
140154
}
141155
}
142156
Contents = PseudoProbeSection->getContents();
@@ -155,13 +169,25 @@ void PseudoProbeRewriter::parsePseudoProbe() {
155169
ProbeDecoder.printProbesForAllAddresses(outs());
156170
}
157171

158-
for (const auto &FuncDesc : ProbeDecoder.getGUID2FuncDescMap()) {
159-
uint64_t GUID = FuncDesc.FuncGUID;
160-
if (!FuncStartAddrs.contains(GUID))
161-
continue;
162-
BinaryFunction *BF = BC.getBinaryFunctionAtAddress(FuncStartAddrs[GUID]);
163-
assert(BF);
164-
BF->setGUID(GUID);
172+
const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap();
173+
// Checks GUID in GUID2Func and returns it if it's present or null otherwise.
174+
auto checkGUID = [&](StringRef SymName) -> uint64_t {
175+
uint64_t GUID = Function::getGUID(SymName);
176+
if (GUID2Func.find(GUID) == GUID2Func.end())
177+
return 0;
178+
return GUID;
179+
};
180+
for (BinaryFunction *F : BC.getAllBinaryFunctions()) {
181+
for (const MCSymbol *Sym : F->getSymbols()) {
182+
StringRef SymName = NameResolver::restore(Sym->getName());
183+
uint64_t GUID = checkGUID(SymName);
184+
std::optional<StringRef> CommonName =
185+
getCommonName(SymName, false, Suffixes);
186+
if (!GUID && CommonName)
187+
GUID = checkGUID(*CommonName);
188+
if (GUID)
189+
F->setGUID(GUID);
190+
}
165191
}
166192
}
167193

bolt/lib/Utils/Utils.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,21 @@ std::string getUnescapedName(const StringRef &Name) {
6666
return Output;
6767
}
6868

69-
std::optional<StringRef> getLTOCommonName(const StringRef Name) {
70-
for (StringRef Suffix : {".__uniq.", ".lto_priv.", ".constprop.", ".llvm."}) {
69+
std::optional<StringRef> getCommonName(const StringRef Name, bool KeepSuffix,
70+
ArrayRef<StringRef> Suffixes) {
71+
for (StringRef Suffix : Suffixes) {
7172
size_t LTOSuffixPos = Name.find(Suffix);
7273
if (LTOSuffixPos != StringRef::npos)
73-
return Name.substr(0, LTOSuffixPos + Suffix.size());
74+
return Name.substr(0, LTOSuffixPos + (KeepSuffix ? Suffix.size() : 0));
7475
}
7576
return std::nullopt;
7677
}
7778

79+
std::optional<StringRef> getLTOCommonName(const StringRef Name) {
80+
return getCommonName(Name, true,
81+
{".__uniq.", ".lto_priv.", ".constprop.", ".llvm."});
82+
}
83+
7884
std::optional<uint8_t> readDWARFExpressionTargetReg(StringRef ExprBytes) {
7985
uint8_t Opcode = ExprBytes[0];
8086
if (Opcode == dwarf::DW_CFA_def_cfa_expression)

bolt/test/X86/pseudoprobe-decoding-inline.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
# PREAGG: B X:0 #main# 1 0
77
## Check pseudo-probes in regular YAML profile (non-BOLTed binary)
88
# RUN: link_fdata %s %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin %t.preagg PREAGG
9-
# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata --profile-use-pseudo-probes
9+
# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata --profile-write-pseudo-probes
1010
# RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-YAML
1111
## Check pseudo-probes in BAT YAML profile (BOLTed binary)
1212
# RUN: link_fdata %s %t.bolt %t.preagg2 PREAGG
13-
# RUN: perf2bolt %t.bolt -p %t.preagg2 --pa -w %t.yaml2 -o %t.fdata2 --profile-use-pseudo-probes
13+
# RUN: perf2bolt %t.bolt -p %t.preagg2 --pa -w %t.yaml2 -o %t.fdata2 --profile-write-pseudo-probes
1414
# RUN: FileCheck --input-file %t.yaml2 %s --check-prefix CHECK-YAML
1515
# CHECK-YAML: name: bar
1616
# CHECK-YAML: - bid: 0
@@ -30,7 +30,7 @@
3030
# CHECK-YAML: guid: 0xDB956436E78DD5FA
3131
# CHECK-YAML: pseudo_probe_desc_hash: 0x10000FFFFFFFF
3232
#
33-
## Check that without --profile-use-pseudo-probes option, no pseudo probes are
33+
## Check that without --profile-write-pseudo-probes option, no pseudo probes are
3434
## generated
3535
# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata
3636
# RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-NO-OPT

0 commit comments

Comments
 (0)