Skip to content

Commit e283f6d

Browse files
committed
Merge branch 'main' into do-not-rely-on-offsets-in-lto-tests
2 parents e2063ce + 7e6c1bd commit e283f6d

File tree

3,940 files changed

+138762
-65148
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,940 files changed

+138762
-65148
lines changed

.ci/compute_projects.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
".ci": {"llvm", "clang", "lld", "lldb"},
5858
}
5959

60+
# This mapping describes runtimes that should be enabled for a specific project,
61+
# but not necessarily run for testing. The only case of this currently is lldb
62+
# which needs some runtimes enabled for tests.
63+
DEPENDENT_RUNTIMES_TO_BUILD = {"lldb": {"libcxx", "libcxxabi", "libunwind"}}
64+
65+
# This mapping describes runtimes that should be tested when the key project is
66+
# touched.
6067
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
6168

6269
EXCLUDE_LINUX = {
@@ -180,16 +187,20 @@ def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
180187
def _compute_runtimes_to_test(projects_to_test: Set[str]) -> Set[str]:
181188
runtimes_to_test = set()
182189
for project_to_test in projects_to_test:
183-
if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST:
184-
continue
185-
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[project_to_test])
190+
if project_to_test in DEPENDENT_RUNTIMES_TO_TEST:
191+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[project_to_test])
192+
if project_to_test in DEPENDENT_RUNTIMES_TO_BUILD:
193+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_BUILD[project_to_test])
186194
return runtimes_to_test
187195

188196

189-
def _compute_runtime_check_targets(runtimes_to_test: Set[str]) -> Set[str]:
197+
def _compute_runtime_check_targets(projects_to_test: Set[str]) -> Set[str]:
190198
check_targets = set()
191-
for runtime_to_test in runtimes_to_test:
192-
check_targets.add(PROJECT_CHECK_TARGETS[runtime_to_test])
199+
for project_to_test in projects_to_test:
200+
if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST:
201+
continue
202+
for runtime_to_test in DEPENDENT_RUNTIMES_TO_TEST[project_to_test]:
203+
check_targets.add(PROJECT_CHECK_TARGETS[runtime_to_test])
193204
return check_targets
194205

195206

@@ -216,16 +227,16 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
216227
projects_to_test = _compute_projects_to_test(modified_projects, platform)
217228
projects_to_build = _compute_projects_to_build(projects_to_test)
218229
projects_check_targets = _compute_project_check_targets(projects_to_test)
219-
runtimes_to_test = _compute_runtimes_to_test(projects_to_test)
220-
runtimes_check_targets = _compute_runtime_check_targets(runtimes_to_test)
230+
runtimes_to_build = _compute_runtimes_to_test(projects_to_test)
231+
runtimes_check_targets = _compute_runtime_check_targets(projects_to_test)
221232
# We use a semicolon to separate the projects/runtimes as they get passed
222233
# to the CMake invocation and thus we need to use the CMake list separator
223234
# (;). We use spaces to separate the check targets as they end up getting
224235
# passed to ninja.
225236
return {
226237
"projects_to_build": ";".join(sorted(projects_to_build)),
227238
"project_check_targets": " ".join(sorted(projects_check_targets)),
228-
"runtimes_to_build": ";".join(sorted(runtimes_to_test)),
239+
"runtimes_to_build": ";".join(sorted(runtimes_to_build)),
229240
"runtimes_check_targets": " ".join(sorted(runtimes_check_targets)),
230241
}
231242

.ci/compute_projects_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ def test_ci(self):
205205
"check-cxx check-cxxabi check-unwind",
206206
)
207207

208+
def test_lldb(self):
209+
env_variables = compute_projects.get_env_variables(
210+
["lldb/CMakeLists.txt"], "Linux"
211+
)
212+
self.assertEqual(env_variables["projects_to_build"], "clang;lldb;llvm")
213+
self.assertEqual(env_variables["project_check_targets"], "check-lldb")
214+
self.assertEqual(
215+
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
216+
)
217+
self.assertEqual(env_variables["runtimes_check_targets"], "")
218+
208219

209220
if __name__ == "__main__":
210221
unittest.main()

.ci/monolithic-linux.sh

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ trap at-exit EXIT
5555

5656
projects="${1}"
5757
targets="${2}"
58+
runtimes="${3}"
59+
runtime_targets="${4}"
5860

5961
lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests"
6062

@@ -70,7 +72,7 @@ export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
7072
# It will not be built unless it is used.
7173
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
7274
-D LLVM_ENABLE_PROJECTS="${projects}" \
73-
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
75+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
7476
-G Ninja \
7577
-D CMAKE_PREFIX_PATH="${HOME}/.local" \
7678
-D CMAKE_BUILD_TYPE=Release \
@@ -91,62 +93,28 @@ echo "--- ninja"
9193
# Targets are not escaped as they are passed as separate arguments.
9294
ninja -C "${BUILD_DIR}" -k 0 ${targets}
9395

94-
runtimes="${3}"
95-
runtime_targets="${4}"
96-
9796
# Compiling runtimes with just-built Clang and running their tests
9897
# as an additional testing for Clang.
99-
if [[ "${runtimes}" != "" ]]; then
100-
if [[ "${runtime_targets}" == "" ]]; then
101-
echo "Runtimes to build are specified, but targets are not."
102-
exit 1
103-
fi
104-
105-
echo "--- ninja install-clang"
106-
107-
ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
108-
109-
RUNTIMES_BUILD_DIR="${MONOREPO_ROOT}/build-runtimes"
110-
INSTALL_DIR="${BUILD_DIR}/install"
111-
mkdir -p ${RUNTIMES_BUILD_DIR}
112-
98+
if [[ "${runtimes_targets}" != "" ]]; then
11399
echo "--- cmake runtimes C++26"
114100

115-
rm -rf "${RUNTIMES_BUILD_DIR}"
116-
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
117-
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
118-
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
119-
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
120-
-D LIBCXX_CXX_ABI=libcxxabi \
121-
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
122-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
123-
-D LIBCXX_TEST_PARAMS="std=c++26" \
124-
-D LIBCXXABI_TEST_PARAMS="std=c++26" \
125-
-D LLVM_LIT_ARGS="${lit_args}"
101+
cmake \
102+
-D LIBCXX_TEST_PARAMS="std=c++26" \
103+
-D LIBCXXABI_TEST_PARAMS="std=c++26" \
104+
"${BUILD_DIR}"
126105

127106
echo "--- ninja runtimes C++26"
128107

129-
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
108+
ninja -C "${BUILD_DIR}" ${runtime_targets}
130109

131110
echo "--- cmake runtimes clang modules"
132111

133-
# We don't need to do a clean build of runtimes, because LIBCXX_TEST_PARAMS
134-
# and LIBCXXABI_TEST_PARAMS only affect lit configuration, which successfully
135-
# propagates without a clean build. Other that those two variables, builds
136-
# are supposed to be the same.
137-
138-
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
139-
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
140-
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
141-
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
142-
-D LIBCXX_CXX_ABI=libcxxabi \
143-
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
144-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
145-
-D LIBCXX_TEST_PARAMS="enable_modules=clang" \
146-
-D LIBCXXABI_TEST_PARAMS="enable_modules=clang" \
147-
-D LLVM_LIT_ARGS="${lit_args}"
112+
cmake \
113+
-D LIBCXX_TEST_PARAMS="enable_modules=clang" \
114+
-D LIBCXXABI_TEST_PARAMS="enable_modules=clang" \
115+
"${BUILD_DIR}"
148116

149117
echo "--- ninja runtimes clang modules"
150118

151-
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
119+
ninja -C "${BUILD_DIR}" ${runtime_targets}
152120
fi

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ d33bf2e9df578ff7e44fd22504d6ad5a122b7ee6
100100

101101
# [lldb][NFC] clang-format MainLoopPosix.cpp
102102
66bdbfbaa08fa3d8e64a7fe136a8fb717f5cdbb7
103+
104+
# [clang-tidy][NFC] Run clang-format on "clang-tools-extra/clang-tidy"
105+
65d66625b3e2b8322ed99d82edabecbafcd0885b
106+
ce46adb8b7ce645353eccaedf31ed9765dab77bb
107+
68070f908bb7ac5f0b5fa9722caa504ecf723f6b
108+
5213c57cb1f0d78aad9a253b7f6a2b62ff4c7859

.github/workflows/email-check.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ jobs:
3232
COMMENT: >-
3333
⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.<br/>
3434
Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account.<br/>
35-
See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information.
35+
See [LLVM Developer Policy](https://llvm.org/docs/DeveloperPolicy.html#email-addresses) and
36+
[LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information.
3637
run: |
3738
cat << EOF > comments
3839
[{"body" : "$COMMENT"}]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
cxx: [ 'clang++-21' ]
5353
include:
5454
- config: 'generic-gcc'
55-
cc: 'gcc-14'
56-
cxx: 'g++-14'
55+
cc: 'gcc-15'
56+
cxx: 'g++-15'
5757
steps:
5858
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5959
- name: ${{ matrix.config }}.${{ matrix.cxx }}
@@ -92,8 +92,8 @@ jobs:
9292
cxx: [ 'clang++-21' ]
9393
include:
9494
- config: 'generic-gcc-cxx11'
95-
cc: 'gcc-14'
96-
cxx: 'g++-14'
95+
cc: 'gcc-15'
96+
cxx: 'g++-15'
9797
- config: 'generic-cxx26'
9898
cc: 'clang-20'
9999
cxx: 'clang++-20'

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ class BinaryBasicBlock {
5252
uint64_t MispredictedCount; /// number of branches mispredicted
5353

5454
bool operator<(const BinaryBranchInfo &Other) const {
55-
return (Count < Other.Count) ||
56-
(Count == Other.Count &&
57-
MispredictedCount < Other.MispredictedCount);
55+
return std::tie(Count, MispredictedCount) <
56+
std::tie(Other.Count, Other.MispredictedCount);
5857
}
5958
};
6059

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ class BinaryFunction {
388388
/// The profile data for the number of times the function was executed.
389389
uint64_t ExecutionCount{COUNT_NO_PROFILE};
390390

391+
/// Profile data for the number of times this function was entered from
392+
/// external code (DSO, JIT, etc).
393+
uint64_t ExternEntryCount{0};
394+
391395
/// Profile match ratio.
392396
float ProfileMatchRatio{0.0f};
393397

@@ -1877,6 +1881,10 @@ class BinaryFunction {
18771881
return *this;
18781882
}
18791883

1884+
/// Set the profile data for the number of times the function was entered from
1885+
/// external code (DSO/JIT).
1886+
void setExternEntryCount(uint64_t Count) { ExternEntryCount = Count; }
1887+
18801888
/// Adjust execution count for the function by a given \p Count. The value
18811889
/// \p Count will be subtracted from the current function count.
18821890
///
@@ -1904,6 +1912,10 @@ class BinaryFunction {
19041912
/// Return COUNT_NO_PROFILE if there's no profile info.
19051913
uint64_t getExecutionCount() const { return ExecutionCount; }
19061914

1915+
/// Return the profile information about the number of times the function was
1916+
/// entered from external code (DSO/JIT).
1917+
uint64_t getExternEntryCount() const { return ExternEntryCount; }
1918+
19071919
/// Return the raw profile information about the number of branch
19081920
/// executions corresponding to this function.
19091921
uint64_t getRawSampleCount() const { return RawSampleCount; }

bolt/include/bolt/Passes/PAuthGadgetScanner.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ struct MCInstInBFReference {
7777
return BF == RHS.BF && Offset == RHS.Offset;
7878
}
7979
bool operator<(const MCInstInBFReference &RHS) const {
80-
if (BF != RHS.BF)
81-
return BF < RHS.BF;
82-
return Offset < RHS.Offset;
80+
return std::tie(BF, Offset) < std::tie(RHS.BF, RHS.Offset);
8381
}
8482
operator MCInst &() const {
8583
assert(BF != nullptr);

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class DataAggregator : public DataReader {
7878
static bool checkPerfDataMagic(StringRef FileName);
7979

8080
private:
81+
struct LBREntry {
82+
uint64_t From;
83+
uint64_t To;
84+
bool Mispred;
85+
};
86+
friend raw_ostream &operator<<(raw_ostream &OS, const LBREntry &);
87+
8188
struct PerfBranchSample {
8289
SmallVector<LBREntry, 32> LBR;
8390
};
@@ -92,24 +99,28 @@ class DataAggregator : public DataReader {
9299
uint64_t Addr;
93100
};
94101

102+
/// Container for the unit of branch data.
103+
/// Backwards compatible with legacy use for branches and fall-throughs:
104+
/// - if \p Branch is FT_ONLY or FT_EXTERNAL_ORIGIN, the trace only
105+
/// contains fall-through data,
106+
/// - if \p To is BR_ONLY, the trace only contains branch data.
95107
struct Trace {
108+
static constexpr const uint64_t EXTERNAL = 0ULL;
109+
static constexpr const uint64_t BR_ONLY = -1ULL;
110+
static constexpr const uint64_t FT_ONLY = -1ULL;
111+
static constexpr const uint64_t FT_EXTERNAL_ORIGIN = -2ULL;
112+
113+
uint64_t Branch;
96114
uint64_t From;
97115
uint64_t To;
98-
Trace(uint64_t From, uint64_t To) : From(From), To(To) {}
99-
bool operator==(const Trace &Other) const {
100-
return From == Other.From && To == Other.To;
101-
}
116+
auto tie() const { return std::tie(Branch, From, To); }
117+
bool operator==(const Trace &Other) const { return tie() == Other.tie(); }
118+
bool operator<(const Trace &Other) const { return tie() < Other.tie(); }
102119
};
120+
friend raw_ostream &operator<<(raw_ostream &OS, const Trace &);
103121

104122
struct TraceHash {
105-
size_t operator()(const Trace &L) const {
106-
return std::hash<uint64_t>()(L.From << 32 | L.To);
107-
}
108-
};
109-
110-
struct FTInfo {
111-
uint64_t InternCount{0};
112-
uint64_t ExternCount{0};
123+
size_t operator()(const Trace &L) const { return hash_combine(L.tie()); }
113124
};
114125

115126
struct TakenBranchInfo {
@@ -119,8 +130,8 @@ class DataAggregator : public DataReader {
119130

120131
/// Intermediate storage for profile data. We save the results of parsing
121132
/// and use them later for processing and assigning profile.
122-
std::unordered_map<Trace, TakenBranchInfo, TraceHash> BranchLBRs;
123-
std::unordered_map<Trace, FTInfo, TraceHash> FallthroughLBRs;
133+
std::unordered_map<Trace, TakenBranchInfo, TraceHash> TraceMap;
134+
std::vector<std::pair<Trace, TakenBranchInfo>> Traces;
124135
std::unordered_map<uint64_t, uint64_t> BasicSamples;
125136
std::vector<PerfMemSample> MemSamples;
126137

@@ -193,8 +204,8 @@ class DataAggregator : public DataReader {
193204
/// Return a vector of offsets corresponding to a trace in a function
194205
/// if the trace is valid, std::nullopt otherwise.
195206
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
196-
getFallthroughsInTrace(BinaryFunction &BF, const LBREntry &First,
197-
const LBREntry &Second, uint64_t Count = 1) const;
207+
getFallthroughsInTrace(BinaryFunction &BF, const Trace &Trace,
208+
uint64_t Count) const;
198209

199210
/// Record external entry into the function \p BF.
200211
///
@@ -258,8 +269,7 @@ class DataAggregator : public DataReader {
258269
bool doBranch(uint64_t From, uint64_t To, uint64_t Count, uint64_t Mispreds);
259270

260271
/// Register a trace between two LBR entries supplied in execution order.
261-
bool doTrace(const LBREntry &First, const LBREntry &Second,
262-
uint64_t Count = 1);
272+
bool doTrace(const Trace &Trace, uint64_t Count);
263273

264274
/// Parser helpers
265275
/// Return false if we exhausted our parser buffer and finished parsing
@@ -476,7 +486,6 @@ class DataAggregator : public DataReader {
476486

477487
/// Debugging dump methods
478488
void dump() const;
479-
void dump(const LBREntry &LBR) const;
480489
void dump(const PerfBranchSample &Sample) const;
481490
void dump(const PerfMemSample &Sample) const;
482491

@@ -504,6 +513,27 @@ class DataAggregator : public DataReader {
504513

505514
friend class YAMLProfileWriter;
506515
};
516+
517+
inline raw_ostream &operator<<(raw_ostream &OS,
518+
const DataAggregator::LBREntry &L) {
519+
OS << formatv("{0:x} -> {1:x}/{2}", L.From, L.To, L.Mispred ? 'M' : 'P');
520+
return OS;
521+
}
522+
523+
inline raw_ostream &operator<<(raw_ostream &OS,
524+
const DataAggregator::Trace &T) {
525+
switch (T.Branch) {
526+
case DataAggregator::Trace::FT_ONLY:
527+
case DataAggregator::Trace::FT_EXTERNAL_ORIGIN:
528+
break;
529+
default:
530+
OS << Twine::utohexstr(T.Branch) << " -> ";
531+
}
532+
OS << Twine::utohexstr(T.From);
533+
if (T.To != DataAggregator::Trace::BR_ONLY)
534+
OS << " ... " << Twine::utohexstr(T.To);
535+
return OS;
536+
}
507537
} // namespace bolt
508538
} // namespace llvm
509539

0 commit comments

Comments
 (0)