Skip to content

Commit bc81973

Browse files
committed
Merge remote-tracking branch 'origin/sycl-web' into llvmspirv_pulldown
2 parents f2a2de3 + 13f6d40 commit bc81973

File tree

2,429 files changed

+55433
-26373
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,429 files changed

+55433
-26373
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ function compute-projects-to-test() {
8585
done
8686
}
8787

88+
function compute-runtimes-to-test() {
89+
projects=${@}
90+
for project in ${projects}; do
91+
case ${project} in
92+
clang)
93+
for p in libcxx libcxxabi libunwind; do
94+
echo $p
95+
done
96+
;;
97+
*)
98+
# Nothing to do
99+
;;
100+
esac
101+
done
102+
}
103+
88104
function add-dependencies() {
89105
projects=${@}
90106
for project in ${projects}; do
@@ -178,6 +194,15 @@ function check-targets() {
178194
cross-project-tests)
179195
echo "check-cross-project"
180196
;;
197+
libcxx)
198+
echo "check-cxx"
199+
;;
200+
libcxxabi)
201+
echo "check-cxxabi"
202+
;;
203+
libunwind)
204+
echo "check-unwind"
205+
;;
181206
lldb)
182207
echo "check-all" # TODO: check-lldb may not include all the LLDB tests?
183208
;;
@@ -207,17 +232,6 @@ if echo "$modified_dirs" | grep -q -E "^(libcxx|libcxxabi|libunwind|runtimes|cma
207232
EOF
208233
fi
209234

210-
# If clang changed.
211-
if echo "$modified_dirs" | grep -q -E "^(clang)$"; then
212-
cat <<EOF
213-
- trigger: "clang-ci"
214-
build:
215-
message: "${buildMessage}"
216-
commit: "${BUILDKITE_COMMIT}"
217-
branch: "${BUILDKITE_BRANCH}"
218-
EOF
219-
fi
220-
221235
# Generic pipeline for projects that have not defined custom steps.
222236
#
223237
# Individual projects should instead define the pre-commit CI tests that suits their
@@ -231,6 +245,10 @@ linux_projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_pro
231245
linux_check_targets=$(check-targets ${linux_projects_to_test} | sort | uniq)
232246
linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
233247

248+
linux_runtimes_to_test=$(compute-runtimes-to-test ${linux_projects_to_test})
249+
linux_runtime_check_targets=$(check-targets ${linux_runtimes_to_test} | sort | uniq)
250+
linux_runtimes=$(echo ${linux_runtimes_to_test} | sort | uniq)
251+
234252
windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
235253
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
236254
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
@@ -255,7 +273,7 @@ if [[ "${linux_projects}" != "" ]]; then
255273
CC: 'clang'
256274
CXX: 'clang++'
257275
commands:
258-
- './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})"'
276+
- './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"'
259277
EOF
260278
fi
261279

.ci/monolithic-linux.sh

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set -o pipefail
1818

1919
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
2020
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
21+
INSTALL_DIR="${BUILD_DIR}/install"
2122
rm -rf "${BUILD_DIR}"
2223

2324
ccache --zero-stats
@@ -49,8 +50,79 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4950
-D LLVM_ENABLE_LLD=ON \
5051
-D CMAKE_CXX_FLAGS=-gmlt \
5152
-D LLVM_CCACHE_BUILD=ON \
52-
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
53+
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
54+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
5355

5456
echo "--- ninja"
5557
# Targets are not escaped as they are passed as separate arguments.
5658
ninja -C "${BUILD_DIR}" -k 0 ${targets}
59+
60+
runtimes="${3}"
61+
runtime_targets="${4}"
62+
63+
# Compiling runtimes with just-built Clang and running their tests
64+
# as an additional testing for Clang.
65+
if [[ "${runtimes}" != "" ]]; then
66+
if [[ "${runtime_targets}" == "" ]]; then
67+
echo "Runtimes to build are specified, but targets are not."
68+
exit 1
69+
fi
70+
71+
echo "--- ninja install-clang"
72+
73+
ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
74+
75+
RUNTIMES_BUILD_DIR="${MONOREPO_ROOT}/build-runtimes"
76+
INSTALL_DIR="${BUILD_DIR}/install"
77+
mkdir -p ${RUNTIMES_BUILD_DIR}
78+
79+
echo "--- cmake runtimes C++03"
80+
81+
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
82+
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
83+
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
84+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
85+
-D LIBCXX_CXX_ABI=libcxxabi \
86+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
87+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
88+
-D LIBCXX_TEST_PARAMS="std=c++03" \
89+
-D LIBCXXABI_TEST_PARAMS="std=c++03"
90+
91+
echo "--- ninja runtimes C++03"
92+
93+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
94+
95+
echo "--- cmake runtimes C++26"
96+
97+
rm -rf "${RUNTIMES_BUILD_DIR}"
98+
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
99+
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
100+
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
101+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
102+
-D LIBCXX_CXX_ABI=libcxxabi \
103+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
104+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
105+
-D LIBCXX_TEST_PARAMS="std=c++26" \
106+
-D LIBCXXABI_TEST_PARAMS="std=c++26"
107+
108+
echo "--- ninja runtimes C++26"
109+
110+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
111+
112+
echo "--- cmake runtimes clang modules"
113+
114+
rm -rf "${RUNTIMES_BUILD_DIR}"
115+
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
116+
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
117+
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
118+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
119+
-D LIBCXX_CXX_ABI=libcxxabi \
120+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
121+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
122+
-D LIBCXX_TEST_PARAMS="enable_modules=clang" \
123+
-D LIBCXXABI_TEST_PARAMS="enable_modules=clang"
124+
125+
echo "--- ninja runtimes clang modules"
126+
127+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
128+
fi

bolt/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
set(LLVM_SUBPROJECT_TITLE "BOLT")
2+
13
include(ExternalProject)
24

35
set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -121,7 +123,7 @@ option(BOLT_BUILD_TOOLS
121123
"Build the BOLT tools. If OFF, just generate build targets." ON)
122124

123125
add_custom_target(bolt)
124-
set_target_properties(bolt PROPERTIES FOLDER "BOLT")
126+
set_target_properties(bolt PROPERTIES FOLDER "BOLT/Metatargets")
125127
add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
126128

127129
include_directories(

bolt/cmake/modules/AddBOLT.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ include(LLVMDistributionSupport)
33

44
macro(add_bolt_executable name)
55
add_llvm_executable(${name} ${ARGN})
6-
set_target_properties(${name} PROPERTIES FOLDER "BOLT")
76
endmacro()
87

98
macro(add_bolt_tool name)

bolt/docs/BAT.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ equals output offset.
106106
`BRANCHENTRY` bit denotes whether a given offset pair is a control flow source
107107
(branch or call instruction). If not set, it signifies a control flow target
108108
(basic block offset).
109+
109110
`InputAddr` is omitted for equal offsets in input and output function. In this
110111
case, `BRANCHENTRY` bits are encoded separately in a `BranchEntries` bitvector.
111112

113+
Deleted basic blocks are emitted as having `OutputOffset` equal to the size of
114+
the function. They don't affect address translation and only participate in
115+
input basic block mapping.
116+
112117
### Secondary Entry Points table
113118
The table is emitted for hot fragments only. It contains `NumSecEntryPoints`
114119
offsets denoting secondary entry points, delta encoded, implicitly starting at zero.

bolt/docs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ if (LLVM_ENABLE_DOXYGEN)
7979
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
8080
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
8181
COMMENT "Generating bolt doxygen documentation." VERBATIM)
82+
set_target_properties(doxygen-bolt PROPERTIES FOLDER "BOLT/Docs")
8283

8384
if (LLVM_BUILD_DOCS)
8485
add_dependencies(doxygen doxygen-bolt)

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "bolt/Core/BinaryData.h"
1818
#include "bolt/Core/BinarySection.h"
1919
#include "bolt/Core/DebugData.h"
20+
#include "bolt/Core/DynoStats.h"
2021
#include "bolt/Core/JumpTable.h"
2122
#include "bolt/Core/MCPlusBuilder.h"
2223
#include "bolt/RuntimeLibs/RuntimeLibrary.h"
@@ -717,6 +718,9 @@ class BinaryContext {
717718
uint64_t NumStaleBlocksWithEqualIcount{0};
718719
} Stats;
719720

721+
// Original binary execution count stats.
722+
DynoStats InitialDynoStats;
723+
720724
// Address of the first allocated segment.
721725
uint64_t FirstAllocAddress{std::numeric_limits<uint64_t>::max()};
722726

@@ -1220,8 +1224,7 @@ class BinaryContext {
12201224

12211225
/// Return a signed value of \p Size stored at \p Address. The address has
12221226
/// to be a valid statically allocated address for the binary.
1223-
ErrorOr<uint64_t> getSignedValueAtAddress(uint64_t Address,
1224-
size_t Size) const;
1227+
ErrorOr<int64_t> getSignedValueAtAddress(uint64_t Address, size_t Size) const;
12251228

12261229
/// Special case of getUnsignedValueAtAddress() that uses a pointer size.
12271230
ErrorOr<uint64_t> getPointerAtAddress(uint64_t Address) const {

bolt/include/bolt/Passes/BinaryPasses.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,31 @@ class BinaryFunctionPass {
5353
virtual Error runOnFunctions(BinaryContext &BC) = 0;
5454
};
5555

56+
/// A pass to set initial program-wide dynostats.
57+
class DynoStatsSetPass : public BinaryFunctionPass {
58+
public:
59+
DynoStatsSetPass() : BinaryFunctionPass(false) {}
60+
61+
const char *getName() const override {
62+
return "set dyno-stats before optimizations";
63+
}
64+
65+
bool shouldPrint(const BinaryFunction &BF) const override { return false; }
66+
67+
Error runOnFunctions(BinaryContext &BC) override {
68+
BC.InitialDynoStats = getDynoStats(BC.getBinaryFunctions(), BC.isAArch64());
69+
return Error::success();
70+
}
71+
};
72+
5673
/// A pass to print program-wide dynostats.
5774
class DynoStatsPrintPass : public BinaryFunctionPass {
5875
protected:
59-
DynoStats PrevDynoStats;
6076
std::string Title;
6177

6278
public:
63-
DynoStatsPrintPass(const DynoStats &PrevDynoStats, const char *Title)
64-
: BinaryFunctionPass(false), PrevDynoStats(PrevDynoStats), Title(Title) {}
79+
DynoStatsPrintPass(const char *Title)
80+
: BinaryFunctionPass(false), Title(Title) {}
6581

6682
const char *getName() const override {
6783
return "print dyno-stats after optimizations";
@@ -70,6 +86,7 @@ class DynoStatsPrintPass : public BinaryFunctionPass {
7086
bool shouldPrint(const BinaryFunction &BF) const override { return false; }
7187

7288
Error runOnFunctions(BinaryContext &BC) override {
89+
const DynoStats PrevDynoStats = BC.InitialDynoStats;
7390
const DynoStats NewDynoStats =
7491
getDynoStats(BC.getBinaryFunctions(), BC.isAArch64());
7592
const bool Changed = (NewDynoStats != PrevDynoStats);

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BinaryFunction;
7070
class BoltAddressTranslation {
7171
public:
7272
// In-memory representation of the address translation table
73-
using MapTy = std::map<uint32_t, uint32_t>;
73+
using MapTy = std::multimap<uint32_t, uint32_t>;
7474

7575
// List of taken fall-throughs
7676
using FallthroughListTy = SmallVector<std::pair<uint64_t, uint64_t>, 16>;
@@ -218,6 +218,7 @@ class BoltAddressTranslation {
218218
auto begin() const { return Map.begin(); }
219219
auto end() const { return Map.end(); }
220220
auto upper_bound(uint32_t Offset) const { return Map.upper_bound(Offset); }
221+
auto size() const { return Map.size(); }
221222
};
222223

223224
/// Map function output address to its hash and basic blocks hash map.

bolt/lib/Core/BinaryContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ BinaryContext::BinaryContext(std::unique_ptr<MCContext> Ctx,
142142
AsmInfo(std::move(AsmInfo)), MII(std::move(MII)), STI(std::move(STI)),
143143
InstPrinter(std::move(InstPrinter)), MIA(std::move(MIA)),
144144
MIB(std::move(MIB)), MRI(std::move(MRI)), DisAsm(std::move(DisAsm)),
145-
Logger(Logger) {
145+
Logger(Logger), InitialDynoStats(isAArch64()) {
146146
Relocation::Arch = this->TheTriple->getArch();
147147
RegularPageSize = isAArch64() ? RegularPageSizeAArch64 : RegularPageSizeX86;
148148
PageAlign = opts::NoHugePages ? RegularPageSize : HugePageSize;
@@ -2217,8 +2217,8 @@ ErrorOr<uint64_t> BinaryContext::getUnsignedValueAtAddress(uint64_t Address,
22172217
return DE.getUnsigned(&ValueOffset, Size);
22182218
}
22192219

2220-
ErrorOr<uint64_t> BinaryContext::getSignedValueAtAddress(uint64_t Address,
2221-
size_t Size) const {
2220+
ErrorOr<int64_t> BinaryContext::getSignedValueAtAddress(uint64_t Address,
2221+
size_t Size) const {
22222222
const ErrorOr<const BinarySection &> Section = getSectionForAddress(Address);
22232223
if (!Section)
22242224
return std::make_error_code(std::errc::bad_address);

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -851,15 +851,19 @@ BinaryFunction::processIndirectBranch(MCInst &Instruction, unsigned Size,
851851
return IndirectBranchType::UNKNOWN;
852852
}
853853

854-
// RIP-relative addressing should be converted to symbol form by now
855-
// in processed instructions (but not in jump).
856-
if (DispExpr) {
854+
auto getExprValue = [&](const MCExpr *Expr) {
857855
const MCSymbol *TargetSym;
858856
uint64_t TargetOffset;
859-
std::tie(TargetSym, TargetOffset) = BC.MIB->getTargetSymbolInfo(DispExpr);
857+
std::tie(TargetSym, TargetOffset) = BC.MIB->getTargetSymbolInfo(Expr);
860858
ErrorOr<uint64_t> SymValueOrError = BC.getSymbolValue(*TargetSym);
861-
assert(SymValueOrError && "global symbol needs a value");
862-
ArrayStart = *SymValueOrError + TargetOffset;
859+
assert(SymValueOrError && "Global symbol needs a value");
860+
return *SymValueOrError + TargetOffset;
861+
};
862+
863+
// RIP-relative addressing should be converted to symbol form by now
864+
// in processed instructions (but not in jump).
865+
if (DispExpr) {
866+
ArrayStart = getExprValue(DispExpr);
863867
BaseRegNum = BC.MIB->getNoRegister();
864868
if (BC.isAArch64()) {
865869
ArrayStart &= ~0xFFFULL;
@@ -3698,6 +3702,13 @@ BinaryFunction::BasicBlockListType BinaryFunction::dfs() const {
36983702

36993703
size_t BinaryFunction::computeHash(bool UseDFS, HashFunction HashFunction,
37003704
OperandHashFuncTy OperandHashFunc) const {
3705+
LLVM_DEBUG({
3706+
dbgs() << "BOLT-DEBUG: computeHash " << getPrintName() << ' '
3707+
<< (UseDFS ? "dfs" : "bin") << " order "
3708+
<< (HashFunction == HashFunction::StdHash ? "std::hash" : "xxh3")
3709+
<< '\n';
3710+
});
3711+
37013712
if (size() == 0)
37023713
return 0;
37033714

bolt/lib/Core/DebugNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ void DWARF5AcceleratorTable::addUnit(DWARFUnit &Unit,
112112
// Returns true if DW_TAG_variable should be included in .debug-names based on
113113
// section 6.1.1.1 for DWARF5 spec.
114114
static bool shouldIncludeVariable(const DWARFUnit &Unit, const DIE &Die) {
115-
if (Die.findAttribute(dwarf::Attribute::DW_AT_declaration))
116-
return false;
117115
const DIEValue LocAttrInfo =
118116
Die.findAttribute(dwarf::Attribute::DW_AT_location);
119117
if (!LocAttrInfo)
@@ -148,6 +146,8 @@ static bool shouldIncludeVariable(const DWARFUnit &Unit, const DIE &Die) {
148146

149147
bool static canProcess(const DWARFUnit &Unit, const DIE &Die,
150148
std::string &NameToUse, const bool TagsOnly) {
149+
if (Die.findAttribute(dwarf::Attribute::DW_AT_declaration))
150+
return false;
151151
switch (Die.getTag()) {
152152
case dwarf::DW_TAG_base_type:
153153
case dwarf::DW_TAG_class_type:

0 commit comments

Comments
 (0)