Skip to content

Commit f498b76

Browse files
committed
Merge branch 'main' into branch-protection-pauthabi
2 parents eae6f7c + 8afb395 commit f498b76

File tree

861 files changed

+38468
-13516
lines changed

Some content is hidden

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

861 files changed

+38468
-13516
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ b9079baaddfed5e604fbfaa1d81a7a1c38e78c26
8484

8585
# [libc++][NFC] Run clang-format on libcxx/include again (#95874)
8686
e2c2ffbe7a1b5d9e32a2ce64279475b50c4cba5b
87+
88+
# [lldb][nfc] Deindent ProcessGDBRemote::SetThreadStopInfo by two levels
89+
b32931c5b32eb0d2cf37d688b34f8548c9674c19

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class RewriteInstance {
490490
std::unordered_map<const MCSymbol *, uint32_t> SymbolIndex;
491491

492492
/// Store all non-zero symbols in this map for a quick address lookup.
493-
std::map<uint64_t, llvm::object::SymbolRef> FileSymRefs;
493+
std::multimap<uint64_t, llvm::object::SymbolRef> FileSymRefs;
494494

495495
/// FILE symbols used for disambiguating split function parents.
496496
std::vector<ELFSymbolRef> FileSymbols;

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ void RewriteInstance::discoverFileObjects() {
886886
if (SymName == "__hot_start" || SymName == "__hot_end")
887887
continue;
888888

889-
FileSymRefs[SymbolAddress] = Symbol;
889+
FileSymRefs.emplace(SymbolAddress, Symbol);
890890

891891
// Skip section symbols that will be registered by disassemblePLT().
892892
if (SymbolType == SymbolRef::ST_Debug) {
@@ -1052,7 +1052,9 @@ void RewriteInstance::discoverFileObjects() {
10521052

10531053
// Remove the symbol from FileSymRefs so that we can skip it from
10541054
// in the future.
1055-
auto SI = FileSymRefs.find(SymbolAddress);
1055+
auto SI = llvm::find_if(
1056+
llvm::make_range(FileSymRefs.equal_range(SymbolAddress)),
1057+
[&](auto SymIt) { return SymIt.second == Symbol; });
10561058
assert(SI != FileSymRefs.end() && "symbol expected to be present");
10571059
assert(SI->second == Symbol && "wrong symbol found");
10581060
FileSymRefs.erase(SI);
@@ -1260,6 +1262,7 @@ void RewriteInstance::discoverFileObjects() {
12601262

12611263
registerFragments();
12621264
FileSymbols.clear();
1265+
FileSymRefs.clear();
12631266

12641267
discoverBOLTReserved();
12651268
}
@@ -1429,11 +1432,17 @@ void RewriteInstance::registerFragments() {
14291432
// of the last local symbol.
14301433
ELFSymbolRef LocalSymEnd = ELF64LEFile->toSymbolRef(SymTab, SymTab->sh_info);
14311434

1432-
for (auto &[ParentName, BF] : AmbiguousFragments) {
1435+
for (auto &Fragment : AmbiguousFragments) {
1436+
const StringRef &ParentName = Fragment.first;
1437+
BinaryFunction *BF = Fragment.second;
14331438
const uint64_t Address = BF->getAddress();
14341439

14351440
// Get fragment's own symbol
1436-
const auto SymIt = FileSymRefs.find(Address);
1441+
const auto SymIt = llvm::find_if(
1442+
llvm::make_range(FileSymRefs.equal_range(Address)), [&](auto SI) {
1443+
StringRef Name = cantFail(SI.second.getName());
1444+
return Name.contains(ParentName);
1445+
});
14371446
if (SymIt == FileSymRefs.end()) {
14381447
BC->errs()
14391448
<< "BOLT-ERROR: symbol lookup failed for function at address 0x"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#--- file1
2+
.file "file1.cpp"
3+
.section .text.cold
4+
.type __func.cold.0, @function
5+
__func.cold.0:
6+
ud2
7+
.size __func.cold.0, .-__func.cold.0
8+
.section .text
9+
.type __func, @function
10+
__func:
11+
ud2
12+
.size __func, .-__func
13+
14+
#--- file2
15+
.file "file2.cpp"
16+
.section .text.cold
17+
.type __func.cold.0, @function
18+
__func.cold.0:
19+
ud2
20+
.size __func.cold.0, .-__func.cold.0
21+
.section .text
22+
.type __func, @function
23+
__func:
24+
ud2
25+
.size __func, .-__func
26+
27+
#--- file3
28+
.file "file3.cpp"
29+
.section .text.cold
30+
.type __func.cold.0, @function
31+
__func.cold.0:
32+
ud2
33+
.size __func.cold.0, .-__func.cold.0
34+
.section .text
35+
.type __func, @function
36+
__func:
37+
ud2
38+
.size __func, .-__func
39+
40+
#--- file4
41+
.file "file4.cpp"
42+
.section .text.cold
43+
.type __func.cold.0, @function
44+
__func.cold.0:
45+
ud2
46+
.size __func.cold.0, .-__func.cold.0
47+
.section .text
48+
.type __func, @function
49+
__func:
50+
ud2
51+
.size __func, .-__func
52+
53+
#--- file5
54+
.file "bolt-pseudo.o"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SECTIONS {
2+
. = 0x10000;
3+
.text : { *(.text) }
4+
. = 0x20000;
5+
.text.cold : { *(.text.cold) }
6+
}

bolt/test/X86/ambiguous_fragment.test

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## This reproduces a bug with misidentification of a parent fragment.
2+
3+
RUN: split-file %p/Inputs/ambiguous_fragment.s %t
4+
5+
RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %t/file1 -o %t1.o
6+
RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %t/file2 -o %t2.o
7+
RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %t/file3 -o %t3.o
8+
RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %t/file4 -o %t4.o
9+
RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %t/file5 -o %t5.o
10+
11+
RUN: ld.lld %t1.o %t2.o %t3.o %t4.o %t5.o -o %t.exe \
12+
RUN: --script %p/Inputs/ambiguous_fragment.script
13+
14+
RUN: llvm-objcopy %t.exe %t.exe2 \
15+
RUN: --add-symbol=_Zfunc.cold.0=.text.cold:0x4,local,function \
16+
RUN: --add-symbol=_Zfunc=.text:0xc,function
17+
18+
RUN: llvm-objdump --syms %t.exe2 | FileCheck %s --check-prefix=CHECK-SYMS
19+
20+
RUN: link_fdata %s %t.exe2 %t.preagg PREAGG
21+
RUN: perf2bolt -v=1 %t.exe2 -p %t.preagg --pa -o %t.fdata -w %t.yaml | FileCheck %s
22+
23+
# PREAGG: B X:0 #__func# 1 0
24+
25+
CHECK-SYMS: 0000000000020004 {{.*}} __func.cold.0
26+
CHECK-SYMS: 0000000000020004 {{.*}} _Zfunc.cold.0
27+
28+
CHECK-NOT: BOLT-ERROR: parent function not found for __func.cold.0
29+
CHECK: BOLT-INFO: marking __func.cold.0/3(*4) as a fragment of __func/4(*3)
30+
CHECK-NEXT: BOLT-INFO: marking __func.cold.0/1(*2) as a fragment of __func/1(*2)
31+
CHECK-NEXT: BOLT-INFO: marking __func.cold.0/2(*2) as a fragment of __func/2(*2)
32+
CHECK-NEXT: BOLT-INFO: marking __func.cold.0/3(*4) as a fragment of __func/3(*2)
33+
CHECK-NEXT: BOLT-INFO: marking __func.cold.0/4(*2) as a fragment of __func/4(*3)

clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -48,97 +48,97 @@ UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
4848
ClangTidyContext *Context)
4949
: ClangTidyCheck(Name, Context),
5050
CheckedFunctions(utils::options::parseStringList(
51-
Options.get("CheckedFunctions", "::std::async$;"
52-
"::std::launder$;"
53-
"::std::remove$;"
54-
"::std::remove_if$;"
55-
"::std::unique$;"
56-
"::std::unique_ptr::release$;"
57-
"::std::basic_string::empty$;"
58-
"::std::vector::empty$;"
59-
"::std::back_inserter$;"
60-
"::std::distance$;"
61-
"::std::find$;"
62-
"::std::find_if$;"
63-
"::std::inserter$;"
64-
"::std::lower_bound$;"
65-
"::std::make_pair$;"
66-
"::std::map::count$;"
67-
"::std::map::find$;"
68-
"::std::map::lower_bound$;"
69-
"::std::multimap::equal_range$;"
70-
"::std::multimap::upper_bound$;"
71-
"::std::set::count$;"
72-
"::std::set::find$;"
73-
"::std::setfill$;"
74-
"::std::setprecision$;"
75-
"::std::setw$;"
76-
"::std::upper_bound$;"
77-
"::std::vector::at$;"
51+
Options.get("CheckedFunctions", "^::std::async$;"
52+
"^::std::launder$;"
53+
"^::std::remove$;"
54+
"^::std::remove_if$;"
55+
"^::std::unique$;"
56+
"^::std::unique_ptr::release$;"
57+
"^::std::basic_string::empty$;"
58+
"^::std::vector::empty$;"
59+
"^::std::back_inserter$;"
60+
"^::std::distance$;"
61+
"^::std::find$;"
62+
"^::std::find_if$;"
63+
"^::std::inserter$;"
64+
"^::std::lower_bound$;"
65+
"^::std::make_pair$;"
66+
"^::std::map::count$;"
67+
"^::std::map::find$;"
68+
"^::std::map::lower_bound$;"
69+
"^::std::multimap::equal_range$;"
70+
"^::std::multimap::upper_bound$;"
71+
"^::std::set::count$;"
72+
"^::std::set::find$;"
73+
"^::std::setfill$;"
74+
"^::std::setprecision$;"
75+
"^::std::setw$;"
76+
"^::std::upper_bound$;"
77+
"^::std::vector::at$;"
7878
// C standard library
79-
"::bsearch$;"
80-
"::ferror$;"
81-
"::feof$;"
82-
"::isalnum$;"
83-
"::isalpha$;"
84-
"::isblank$;"
85-
"::iscntrl$;"
86-
"::isdigit$;"
87-
"::isgraph$;"
88-
"::islower$;"
89-
"::isprint$;"
90-
"::ispunct$;"
91-
"::isspace$;"
92-
"::isupper$;"
93-
"::iswalnum$;"
94-
"::iswprint$;"
95-
"::iswspace$;"
96-
"::isxdigit$;"
97-
"::memchr$;"
98-
"::memcmp$;"
99-
"::strcmp$;"
100-
"::strcoll$;"
101-
"::strncmp$;"
102-
"::strpbrk$;"
103-
"::strrchr$;"
104-
"::strspn$;"
105-
"::strstr$;"
106-
"::wcscmp$;"
79+
"^::bsearch$;"
80+
"^::ferror$;"
81+
"^::feof$;"
82+
"^::isalnum$;"
83+
"^::isalpha$;"
84+
"^::isblank$;"
85+
"^::iscntrl$;"
86+
"^::isdigit$;"
87+
"^::isgraph$;"
88+
"^::islower$;"
89+
"^::isprint$;"
90+
"^::ispunct$;"
91+
"^::isspace$;"
92+
"^::isupper$;"
93+
"^::iswalnum$;"
94+
"^::iswprint$;"
95+
"^::iswspace$;"
96+
"^::isxdigit$;"
97+
"^::memchr$;"
98+
"^::memcmp$;"
99+
"^::strcmp$;"
100+
"^::strcoll$;"
101+
"^::strncmp$;"
102+
"^::strpbrk$;"
103+
"^::strrchr$;"
104+
"^::strspn$;"
105+
"^::strstr$;"
106+
"^::wcscmp$;"
107107
// POSIX
108-
"::access$;"
109-
"::bind$;"
110-
"::connect$;"
111-
"::difftime$;"
112-
"::dlsym$;"
113-
"::fnmatch$;"
114-
"::getaddrinfo$;"
115-
"::getopt$;"
116-
"::htonl$;"
117-
"::htons$;"
118-
"::iconv_open$;"
119-
"::inet_addr$;"
120-
"::isascii$;"
121-
"::isatty$;"
122-
"::mmap$;"
123-
"::newlocale$;"
124-
"::openat$;"
125-
"::pathconf$;"
126-
"::pthread_equal$;"
127-
"::pthread_getspecific$;"
128-
"::pthread_mutex_trylock$;"
129-
"::readdir$;"
130-
"::readlink$;"
131-
"::recvmsg$;"
132-
"::regexec$;"
133-
"::scandir$;"
134-
"::semget$;"
135-
"::setjmp$;"
136-
"::shm_open$;"
137-
"::shmget$;"
138-
"::sigismember$;"
139-
"::strcasecmp$;"
140-
"::strsignal$;"
141-
"::ttyname"))),
108+
"^::access$;"
109+
"^::bind$;"
110+
"^::connect$;"
111+
"^::difftime$;"
112+
"^::dlsym$;"
113+
"^::fnmatch$;"
114+
"^::getaddrinfo$;"
115+
"^::getopt$;"
116+
"^::htonl$;"
117+
"^::htons$;"
118+
"^::iconv_open$;"
119+
"^::inet_addr$;"
120+
"^::isascii$;"
121+
"^::isatty$;"
122+
"^::mmap$;"
123+
"^::newlocale$;"
124+
"^::openat$;"
125+
"^::pathconf$;"
126+
"^::pthread_equal$;"
127+
"^::pthread_getspecific$;"
128+
"^::pthread_mutex_trylock$;"
129+
"^::readdir$;"
130+
"^::readlink$;"
131+
"^::recvmsg$;"
132+
"^::regexec$;"
133+
"^::scandir$;"
134+
"^::semget$;"
135+
"^::setjmp$;"
136+
"^::shm_open$;"
137+
"^::shmget$;"
138+
"^::sigismember$;"
139+
"^::strcasecmp$;"
140+
"^::strsignal$;"
141+
"^::ttyname"))),
142142
CheckedReturnTypes(utils::options::parseStringList(
143143
Options.get("CheckedReturnTypes", "::std::error_code$;"
144144
"::std::error_condition$;"

clang-tools-extra/clang-tidy/modernize/UseRangesCheck.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ static constexpr const char *TwoRangeNames[] = {
9696
"is_permutation",
9797
};
9898

99+
static constexpr const char *SinglePivotRangeNames[] = {"rotate", "rotate_copy",
100+
"inplace_merge"};
101+
99102
namespace {
100103
class StdReplacer : public utils::UseRangesCheck::Replacer {
101104
public:
@@ -141,13 +144,19 @@ utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {
141144
// Func(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2,...).
142145
static const Signature TwoRangeArgs = {{0}, {2}};
143146

147+
// template<typename Iter> Func(Iter first, Iter pivot, Iter last,...).
148+
static const Signature SinglePivotRange = {{0, 2}};
149+
144150
static const Signature SingleRangeFunc[] = {SingleRangeArgs};
145151

146152
static const Signature TwoRangeFunc[] = {TwoRangeArgs};
147153

154+
static const Signature SinglePivotFunc[] = {SinglePivotRange};
155+
148156
static const std::pair<ArrayRef<Signature>, ArrayRef<const char *>>
149157
AlgorithmNames[] = {{SingleRangeFunc, SingleRangeNames},
150-
{TwoRangeFunc, TwoRangeNames}};
158+
{TwoRangeFunc, TwoRangeNames},
159+
{SinglePivotFunc, SinglePivotRangeNames}};
151160
SmallString<64> Buff;
152161
for (const auto &[Signatures, Values] : AlgorithmNames) {
153162
auto Replacer = llvm::makeIntrusiveRefCnt<StdAlgorithmReplacer>(

clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,13 @@ void UseStdFormatCheck::registerPPCallbacks(const SourceManager &SM,
4747
}
4848

4949
void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
50-
auto CharPointerType =
51-
hasType(pointerType(pointee(matchers::isSimpleChar())));
5250
Finder->addMatcher(
53-
callExpr(
54-
argumentCountAtLeast(1), hasArgument(0, stringLiteral(isOrdinary())),
55-
callee(functionDecl(
56-
unless(cxxMethodDecl()), hasParameter(0, CharPointerType),
57-
matchers::matchesAnyListedName(StrFormatLikeFunctions))
58-
.bind("func_decl")))
51+
callExpr(argumentCountAtLeast(1),
52+
hasArgument(0, stringLiteral(isOrdinary())),
53+
callee(functionDecl(unless(cxxMethodDecl()),
54+
matchers::matchesAnyListedName(
55+
StrFormatLikeFunctions))
56+
.bind("func_decl")))
5957
.bind("strformat"),
6058
this);
6159
}

0 commit comments

Comments
 (0)