Skip to content

Commit 25b03eb

Browse files
committed
Merge branch 'main' into pauth-lld-relr & fix conflict after c258f57
2 parents 500cfcf + a27ab3f commit 25b03eb

File tree

2,637 files changed

+125953
-79345
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,637 files changed

+125953
-79345
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ env:
3838
# LLVM POST-BRANCH bump version
3939
# LLVM POST-BRANCH add compiler test for ToT - 1, e.g. "Clang 17"
4040
# LLVM RELEASE bump remove compiler ToT - 3, e.g. "Clang 15"
41-
LLVM_HEAD_VERSION: "18" # Used compiler, update POST-BRANCH.
42-
LLVM_PREVIOUS_VERSION: "17"
43-
LLVM_OLDEST_VERSION: "16"
41+
LLVM_HEAD_VERSION: "19" # Used compiler, update POST-BRANCH.
42+
LLVM_PREVIOUS_VERSION: "18"
43+
LLVM_OLDEST_VERSION: "17"
4444
GCC_STABLE_VERSION: "13"
45-
LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-18"
45+
LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-19"
4646
CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
4747

4848

@@ -59,8 +59,8 @@ jobs:
5959
'generic-cxx26',
6060
'generic-modules'
6161
]
62-
cc: [ 'clang-18' ]
63-
cxx: [ 'clang++-18' ]
62+
cc: [ 'clang-19' ]
63+
cxx: [ 'clang++-19' ]
6464
clang_tidy: [ 'ON' ]
6565
include:
6666
- config: 'generic-gcc'
@@ -100,22 +100,22 @@ jobs:
100100
'generic-cxx20',
101101
'generic-cxx23'
102102
]
103-
cc: [ 'clang-18' ]
104-
cxx: [ 'clang++-18' ]
103+
cc: [ 'clang-19' ]
104+
cxx: [ 'clang++-19' ]
105105
clang_tidy: [ 'ON' ]
106106
include:
107107
- config: 'generic-gcc-cxx11'
108108
cc: 'gcc-13'
109109
cxx: 'g++-13'
110110
clang_tidy: 'OFF'
111-
- config: 'generic-cxx23'
112-
cc: 'clang-16'
113-
cxx: 'clang++-16'
114-
clang_tidy: 'OFF'
115111
- config: 'generic-cxx23'
116112
cc: 'clang-17'
117113
cxx: 'clang++-17'
118114
clang_tidy: 'OFF'
115+
- config: 'generic-cxx26'
116+
cc: 'clang-18'
117+
cxx: 'clang++-18'
118+
clang_tidy: 'ON'
119119
steps:
120120
- uses: actions/checkout@v4
121121
- name: ${{ matrix.config }}
@@ -186,8 +186,8 @@ jobs:
186186
- name: ${{ matrix.config }}
187187
run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
188188
env:
189-
CC: clang-18
190-
CXX: clang++-18
189+
CC: clang-19
190+
CXX: clang++-19
191191
ENABLE_CLANG_TIDY: "OFF"
192192
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
193193
if: always()

.github/workflows/pr-code-format.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
name: "Check code formatting"
2+
3+
permissions:
4+
contents: read
5+
26
on:
37
pull_request:
48
branches:

.github/workflows/release-lit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
cd llvm/utils/lit
5959
# Remove 'dev' suffix from lit version.
6060
sed -i 's/ + "dev"//g' lit/__init__.py
61-
python3 setup.py sdist
61+
python3 setup.py sdist bdist_wheel
6262
6363
- name: Upload lit to test.pypi.org
6464
uses: pypa/gh-action-pypi-publish@release/v1

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,8 @@ class BinaryFunction {
14021402

14031403
/// Return true if the function has CFI instructions
14041404
bool hasCFI() const {
1405-
return !FrameInstructions.empty() || !CIEFrameInstructions.empty();
1405+
return !FrameInstructions.empty() || !CIEFrameInstructions.empty() ||
1406+
IsInjected;
14061407
}
14071408

14081409
/// Return unique number associated with the function.

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <unordered_map>
2020

2121
namespace llvm {
22+
class MCSymbol;
2223
class raw_ostream;
2324

2425
namespace object {
@@ -118,10 +119,12 @@ class BoltAddressTranslation {
118119
/// True if a given \p Address is a function with translation table entry.
119120
bool isBATFunction(uint64_t Address) const { return Maps.count(Address); }
120121

121-
/// Returns branch offsets grouped by containing basic block in a given
122-
/// function.
123-
std::unordered_map<uint32_t, std::vector<uint32_t>>
124-
getBFBranches(uint64_t FuncOutputAddress) const;
122+
/// For a given \p Symbol in the output binary and known \p InputOffset
123+
/// return a corresponding pair of parent BinaryFunction and secondary entry
124+
/// point in it.
125+
std::pair<const BinaryFunction *, unsigned>
126+
translateSymbol(const BinaryContext &BC, const MCSymbol &Symbol,
127+
uint32_t InputOffset) const;
125128

126129
private:
127130
/// Helper to update \p Map by inserting one or more BAT entries reflecting
@@ -158,6 +161,10 @@ class BoltAddressTranslation {
158161
/// Map a function to its secondary entry points vector
159162
std::unordered_map<uint64_t, std::vector<uint32_t>> SecondaryEntryPointsMap;
160163

164+
/// Return a secondary entry point ID for a function located at \p Address and
165+
/// \p Offset within that function.
166+
unsigned getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const;
167+
161168
/// Links outlined cold bocks to their original function
162169
std::map<uint64_t, uint64_t> ColdPartSource;
163170

@@ -181,7 +188,7 @@ class BoltAddressTranslation {
181188
EntryTy(unsigned Index, size_t Hash) : Index(Index), Hash(Hash) {}
182189
};
183190

184-
std::unordered_map<uint32_t, EntryTy> Map;
191+
std::map<uint32_t, EntryTy> Map;
185192
const EntryTy &getEntry(uint32_t BBInputOffset) const {
186193
auto It = Map.find(BBInputOffset);
187194
assert(It != Map.end());
@@ -206,6 +213,10 @@ class BoltAddressTranslation {
206213
}
207214

208215
size_t getNumBasicBlocks() const { return Map.size(); }
216+
217+
auto begin() const { return Map.begin(); }
218+
auto end() const { return Map.end(); }
219+
auto upper_bound(uint32_t Offset) const { return Map.upper_bound(Offset); }
209220
};
210221

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

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ class DataAggregator : public DataReader {
225225
/// Aggregation statistics
226226
uint64_t NumInvalidTraces{0};
227227
uint64_t NumLongRangeTraces{0};
228+
/// Specifies how many samples were recorded in cold areas if we are dealing
229+
/// with profiling data collected in a bolted binary. For LBRs, incremented
230+
/// for the source of the branch to avoid counting cold activity twice (one
231+
/// for source and another for destination).
228232
uint64_t NumColdSamples{0};
229233

230234
/// Looks into system PATH for Linux Perf and set up the aggregator to use it
@@ -245,14 +249,12 @@ class DataAggregator : public DataReader {
245249
/// disassembled BinaryFunctions
246250
BinaryFunction *getBinaryFunctionContainingAddress(uint64_t Address) const;
247251

252+
/// Perform BAT translation for a given \p Func and return the parent
253+
/// BinaryFunction or nullptr.
254+
BinaryFunction *getBATParentFunction(const BinaryFunction &Func) const;
255+
248256
/// Retrieve the location name to be used for samples recorded in \p Func.
249-
/// If doing BAT translation, link cold parts to the hot part names (used by
250-
/// the original binary). \p Count specifies how many samples were recorded
251-
/// at that location, so we can tally total activity in cold areas if we are
252-
/// dealing with profiling data collected in a bolted binary. For LBRs,
253-
/// \p Count should only be used for the source of the branch to avoid
254-
/// counting cold activity twice (one for source and another for destination).
255-
StringRef getLocationName(BinaryFunction &Func, uint64_t Count);
257+
StringRef getLocationName(const BinaryFunction &Func) const;
256258

257259
/// Semantic actions - parser hooks to interpret parsed perf samples
258260
/// Register a sample (non-LBR mode), i.e. a new hit at \p Address
@@ -467,9 +469,6 @@ class DataAggregator : public DataReader {
467469
std::error_code writeBATYAML(BinaryContext &BC,
468470
StringRef OutputFilename) const;
469471

470-
/// Fixup profile collected on BOLTed binary, namely handle split functions.
471-
void fixupBATProfile(BinaryContext &BC);
472-
473472
/// Filter out binaries based on PID
474473
void filterBinaryMMapInfo();
475474

bolt/include/bolt/Profile/YAMLProfileWriter.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace llvm {
1717
namespace bolt {
18+
class BoltAddressTranslation;
1819
class RewriteInstance;
1920

2021
class YAMLProfileWriter {
@@ -31,8 +32,16 @@ class YAMLProfileWriter {
3132
/// Save execution profile for that instance.
3233
std::error_code writeProfile(const RewriteInstance &RI);
3334

34-
static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF,
35-
bool UseDFS);
35+
static yaml::bolt::BinaryFunctionProfile
36+
convert(const BinaryFunction &BF, bool UseDFS,
37+
const BoltAddressTranslation *BAT = nullptr);
38+
39+
/// Set CallSiteInfo destination fields from \p Symbol and return a target
40+
/// BinaryFunction for that symbol.
41+
static const BinaryFunction *
42+
setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI,
43+
const MCSymbol *Symbol, const BoltAddressTranslation *BAT,
44+
uint32_t Offset = 0);
3645
};
3746

3847
} // namespace bolt

bolt/lib/Core/BinaryContext.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
555555
const uint64_t NextJTAddress,
556556
JumpTable::AddressesType *EntriesAsAddress,
557557
bool *HasEntryInFragment) const {
558+
// Target address of __builtin_unreachable.
559+
const uint64_t UnreachableAddress = BF.getAddress() + BF.getSize();
560+
558561
// Is one of the targets __builtin_unreachable?
559562
bool HasUnreachable = false;
560563

@@ -564,9 +567,15 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
564567
// Number of targets other than __builtin_unreachable.
565568
uint64_t NumRealEntries = 0;
566569

567-
auto addEntryAddress = [&](uint64_t EntryAddress) {
568-
if (EntriesAsAddress)
569-
EntriesAsAddress->emplace_back(EntryAddress);
570+
// Size of the jump table without trailing __builtin_unreachable entries.
571+
size_t TrimmedSize = 0;
572+
573+
auto addEntryAddress = [&](uint64_t EntryAddress, bool Unreachable = false) {
574+
if (!EntriesAsAddress)
575+
return;
576+
EntriesAsAddress->emplace_back(EntryAddress);
577+
if (!Unreachable)
578+
TrimmedSize = EntriesAsAddress->size();
570579
};
571580

572581
ErrorOr<const BinarySection &> Section = getSectionForAddress(Address);
@@ -618,8 +627,8 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
618627
: *getPointerAtAddress(EntryAddress);
619628

620629
// __builtin_unreachable() case.
621-
if (Value == BF.getAddress() + BF.getSize()) {
622-
addEntryAddress(Value);
630+
if (Value == UnreachableAddress) {
631+
addEntryAddress(Value, /*Unreachable*/ true);
623632
HasUnreachable = true;
624633
LLVM_DEBUG(dbgs() << formatv("OK: {0:x} __builtin_unreachable\n", Value));
625634
continue;
@@ -673,6 +682,13 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
673682
addEntryAddress(Value);
674683
}
675684

685+
// Trim direct/normal jump table to exclude trailing unreachable entries that
686+
// can collide with a function address.
687+
if (Type == JumpTable::JTT_NORMAL && EntriesAsAddress &&
688+
TrimmedSize != EntriesAsAddress->size() &&
689+
getBinaryFunctionAtAddress(UnreachableAddress))
690+
EntriesAsAddress->resize(TrimmedSize);
691+
676692
// It's a jump table if the number of real entries is more than 1, or there's
677693
// one real entry and one or more special targets. If there are only multiple
678694
// special targets, then it's not a jump table.

0 commit comments

Comments
 (0)