Skip to content

Commit 26c8c65

Browse files
authored
merge main into amd-staging (llvm#3084)
2 parents 7056682 + 5e694f2 commit 26c8c65

File tree

294 files changed

+4499
-1219
lines changed

Some content is hidden

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

294 files changed

+4499
-1219
lines changed

bolt/runtime/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ set(BOLT_RT_FLAGS
3535
-fno-exceptions
3636
-fno-rtti
3737
-fno-stack-protector
38-
-fPIC)
38+
-fPIC
39+
# Runtime currently assumes omitted frame pointers for functions marked __attribute((naked)).
40+
# Protect against distros adding -fno-omit-frame-pointer and compiling with GCC.
41+
# Refs: llvm/llvm-project#148595 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882
42+
-fomit-frame-pointer
43+
)
3944
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
4045
set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS}
4146
-mno-sse

bolt/runtime/instr.cpp

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,13 @@ struct FunctionDescription {
568568
/// should be straightforward as most data is POD or an array of POD elements.
569569
/// This metadata is used to reconstruct function CFGs.
570570
struct ProfileWriterContext {
571-
IndCallDescription *IndCallDescriptions;
572-
IndCallTargetDescription *IndCallTargets;
573-
uint8_t *FuncDescriptions;
574-
char *Strings; // String table with function names used in this binary
571+
const IndCallDescription *IndCallDescriptions;
572+
const IndCallTargetDescription *IndCallTargets;
573+
const uint8_t *FuncDescriptions;
574+
const char *Strings; // String table with function names used in this binary
575575
int FileDesc; // File descriptor for the file on disk backing this
576576
// information in memory via mmap
577-
void *MMapPtr; // The mmap ptr
577+
const void *MMapPtr; // The mmap ptr
578578
int MMapSize; // The mmap size
579579

580580
/// Hash table storing all possible call destinations to detect untracked
@@ -721,7 +721,7 @@ static char *getBinaryPath() {
721721

722722
ProfileWriterContext readDescriptions() {
723723
ProfileWriterContext Result;
724-
char *BinPath = getBinaryPath();
724+
const char *BinPath = getBinaryPath();
725725
assert(BinPath && BinPath[0] != '\0', "failed to find binary path");
726726

727727
uint64_t FD = __open(BinPath, O_RDONLY,
@@ -732,23 +732,24 @@ ProfileWriterContext readDescriptions() {
732732

733733
// mmap our binary to memory
734734
uint64_t Size = __lseek(FD, 0, SEEK_END);
735-
uint8_t *BinContents = reinterpret_cast<uint8_t *>(
735+
const uint8_t *BinContents = reinterpret_cast<uint8_t *>(
736736
__mmap(0, Size, PROT_READ, MAP_PRIVATE, FD, 0));
737737
assert(BinContents != MAP_FAILED, "readDescriptions: Failed to mmap self!");
738738
Result.MMapPtr = BinContents;
739739
Result.MMapSize = Size;
740-
Elf64_Ehdr *Hdr = reinterpret_cast<Elf64_Ehdr *>(BinContents);
741-
Elf64_Shdr *Shdr = reinterpret_cast<Elf64_Shdr *>(BinContents + Hdr->e_shoff);
742-
Elf64_Shdr *StringTblHeader = reinterpret_cast<Elf64_Shdr *>(
740+
const Elf64_Ehdr *Hdr = reinterpret_cast<const Elf64_Ehdr *>(BinContents);
741+
const Elf64_Shdr *Shdr =
742+
reinterpret_cast<const Elf64_Shdr *>(BinContents + Hdr->e_shoff);
743+
const Elf64_Shdr *StringTblHeader = reinterpret_cast<const Elf64_Shdr *>(
743744
BinContents + Hdr->e_shoff + Hdr->e_shstrndx * Hdr->e_shentsize);
744745

745746
// Find .bolt.instr.tables with the data we need and set pointers to it
746747
for (int I = 0; I < Hdr->e_shnum; ++I) {
747-
char *SecName = reinterpret_cast<char *>(
748+
const char *SecName = reinterpret_cast<const char *>(
748749
BinContents + StringTblHeader->sh_offset + Shdr->sh_name);
749750
if (compareStr(SecName, ".bolt.instr.tables", 64) != 0) {
750-
Shdr = reinterpret_cast<Elf64_Shdr *>(BinContents + Hdr->e_shoff +
751-
(I + 1) * Hdr->e_shentsize);
751+
Shdr = reinterpret_cast<const Elf64_Shdr *>(BinContents + Hdr->e_shoff +
752+
(I + 1) * Hdr->e_shentsize);
752753
continue;
753754
}
754755
// Actual contents of the ELF note start after offset 20 decimal:
@@ -758,19 +759,19 @@ ProfileWriterContext readDescriptions() {
758759
// Offset 12: Producer name (BOLT\0) (5 bytes + align to 4-byte boundary)
759760
// Offset 20: Contents
760761
uint32_t IndCallDescSize =
761-
*reinterpret_cast<uint32_t *>(BinContents + Shdr->sh_offset + 20);
762-
uint32_t IndCallTargetDescSize = *reinterpret_cast<uint32_t *>(
762+
*reinterpret_cast<const uint32_t *>(BinContents + Shdr->sh_offset + 20);
763+
uint32_t IndCallTargetDescSize = *reinterpret_cast<const uint32_t *>(
763764
BinContents + Shdr->sh_offset + 24 + IndCallDescSize);
764-
uint32_t FuncDescSize =
765-
*reinterpret_cast<uint32_t *>(BinContents + Shdr->sh_offset + 28 +
766-
IndCallDescSize + IndCallTargetDescSize);
767-
Result.IndCallDescriptions = reinterpret_cast<IndCallDescription *>(
765+
uint32_t FuncDescSize = *reinterpret_cast<const uint32_t *>(
766+
BinContents + Shdr->sh_offset + 28 + IndCallDescSize +
767+
IndCallTargetDescSize);
768+
Result.IndCallDescriptions = reinterpret_cast<const IndCallDescription *>(
768769
BinContents + Shdr->sh_offset + 24);
769-
Result.IndCallTargets = reinterpret_cast<IndCallTargetDescription *>(
770+
Result.IndCallTargets = reinterpret_cast<const IndCallTargetDescription *>(
770771
BinContents + Shdr->sh_offset + 28 + IndCallDescSize);
771772
Result.FuncDescriptions = BinContents + Shdr->sh_offset + 32 +
772773
IndCallDescSize + IndCallTargetDescSize;
773-
Result.Strings = reinterpret_cast<char *>(
774+
Result.Strings = reinterpret_cast<const char *>(
774775
BinContents + Shdr->sh_offset + 32 + IndCallDescSize +
775776
IndCallTargetDescSize + FuncDescSize);
776777
return Result;
@@ -814,13 +815,14 @@ void printStats(const ProfileWriterContext &Ctx) {
814815
strCopy(StatPtr,
815816
"\nBOLT INSTRUMENTATION RUNTIME STATISTICS\n\nIndCallDescSize: ");
816817
StatPtr = intToStr(StatPtr,
817-
Ctx.FuncDescriptions -
818-
reinterpret_cast<uint8_t *>(Ctx.IndCallDescriptions),
818+
Ctx.FuncDescriptions - reinterpret_cast<const uint8_t *>(
819+
Ctx.IndCallDescriptions),
819820
10);
820821
StatPtr = strCopy(StatPtr, "\nFuncDescSize: ");
821-
StatPtr = intToStr(
822-
StatPtr,
823-
reinterpret_cast<uint8_t *>(Ctx.Strings) - Ctx.FuncDescriptions, 10);
822+
StatPtr = intToStr(StatPtr,
823+
reinterpret_cast<const uint8_t *>(Ctx.Strings) -
824+
Ctx.FuncDescriptions,
825+
10);
824826
StatPtr = strCopy(StatPtr, "\n__bolt_instr_num_ind_calls: ");
825827
StatPtr = intToStr(StatPtr, __bolt_instr_num_ind_calls, 10);
826828
StatPtr = strCopy(StatPtr, "\n__bolt_instr_num_funcs: ");
@@ -1549,7 +1551,7 @@ __bolt_instr_data_dump(int FD) {
15491551
Ctx.CallFlowTable->forEachElement(visitCallFlowEntry, FD, &Ctx);
15501552

15511553
__fsync(FD);
1552-
__munmap(Ctx.MMapPtr, Ctx.MMapSize);
1554+
__munmap((void *)Ctx.MMapPtr, Ctx.MMapSize);
15531555
__close(Ctx.FileDesc);
15541556
HashAlloc.destroy();
15551557
GlobalWriteProfileMutex->release();
@@ -1756,7 +1758,7 @@ extern "C" __attribute((naked)) void __bolt_instr_start()
17561758
"jal x1, __bolt_instr_setup\n"
17571759
RESTORE_ALL
17581760
"setup_symbol:\n"
1759-
"auipc x5, %%pcrel_hi(__bolt_start_trampoline)\n"
1761+
"auipc x5, %%pcrel_hi(__bolt_start_trampoline)\n"
17601762
"addi x5, x5, %%pcrel_lo(setup_symbol)\n"
17611763
"jr x5\n"
17621764
:::);
@@ -1788,8 +1790,8 @@ extern "C" void __bolt_instr_fini() {
17881790
__asm__ __volatile__(
17891791
SAVE_ALL
17901792
"fini_symbol:\n"
1791-
"auipc x5, %%pcrel_hi(__bolt_fini_trampoline)\n"
1792-
"addi x5, x5, %%pcrel_lo(fini_symbol)\n"
1793+
"auipc x5, %%pcrel_hi(__bolt_fini_trampoline)\n"
1794+
"addi x5, x5, %%pcrel_lo(fini_symbol)\n"
17931795
"jalr x1, 0(x5)\n"
17941796
RESTORE_ALL
17951797
:::);

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,20 @@ getCheckNames(const ClangTidyOptions &Options,
505505
return Factory.getCheckNames();
506506
}
507507

508+
void filterCheckOptions(ClangTidyOptions &Options,
509+
const std::vector<std::string> &EnabledChecks) {
510+
ClangTidyOptions::OptionMap FilteredOptions;
511+
for (const auto &[OptionName, Value] : Options.CheckOptions) {
512+
const size_t CheckNameEndPos = OptionName.find('.');
513+
if (CheckNameEndPos == StringRef::npos)
514+
continue;
515+
const StringRef CheckName = OptionName.substr(0, CheckNameEndPos);
516+
if (llvm::binary_search(EnabledChecks, CheckName))
517+
FilteredOptions[OptionName] = Value;
518+
}
519+
Options.CheckOptions = std::move(FilteredOptions);
520+
}
521+
508522
ClangTidyOptions::OptionMap
509523
getCheckOptions(const ClangTidyOptions &Options,
510524
bool AllowEnablingAnalyzerAlphaCheckers) {

clang-tools-extra/clang-tidy/ClangTidy.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ ClangTidyOptions::OptionMap
7676
getCheckOptions(const ClangTidyOptions &Options,
7777
bool AllowEnablingAnalyzerAlphaCheckers);
7878

79+
/// Filters CheckOptions in \p Options to only include options specified in
80+
/// the \p EnabledChecks which is a sorted vector.
81+
void filterCheckOptions(ClangTidyOptions &Options,
82+
const std::vector<std::string> &EnabledChecks);
83+
7984
/// Run a set of clang-tidy checks on a set of files.
8085
///
8186
/// \param EnableCheckProfile If provided, it enables check profile collection

clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,10 @@ int clangTidyMain(int argc, const char **argv) {
659659
if (DumpConfig) {
660660
EffectiveOptions.CheckOptions =
661661
getCheckOptions(EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
662-
llvm::outs() << configurationAsText(ClangTidyOptions::getDefaults().merge(
663-
EffectiveOptions, 0))
664-
<< "\n";
662+
ClangTidyOptions OptionsToDump =
663+
ClangTidyOptions::getDefaults().merge(EffectiveOptions, 0);
664+
filterCheckOptions(OptionsToDump, EnabledChecks);
665+
llvm::outs() << configurationAsText(OptionsToDump) << "\n";
665666
return 0;
666667
}
667668

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ Improvements to clang-tidy
108108
- Improved :program:`clang-tidy-diff.py` script. Add the `-warnings-as-errors`
109109
argument to treat warnings as errors.
110110

111+
- Improved :program:`clang-tidy` to show `CheckOptions` only for checks enabled
112+
in `Checks` when running ``--dump-config``.
113+
111114
- Fixed bug in :program:`clang-tidy` by which `HeaderFilterRegex` did not take
112115
effect when passed via the `.clang-tidy` file.
113116

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: clang-tidy -checks='-*,misc-unused-parameters' -dump-config %s -- 2>/dev/null | FileCheck %s --check-prefix=CHECK
2+
// RUN: clang-tidy -checks='-*' -dump-config %s -- 2>/dev/null | FileCheck %s --check-prefix=CHECK-DISABLED
3+
4+
// CHECK: CheckOptions:
5+
// CHECK-NEXT: misc-unused-parameters.IgnoreVirtual: 'false'
6+
// CHECK-NEXT: misc-unused-parameters.StrictMode: 'false'
7+
// CHECK-NEXT: SystemHeaders: false
8+
9+
// CHECK-DISABLED: CheckOptions: {}
10+
// CHECK-DISABLED-NEXT: SystemHeaders: false
11+
12+
int main() { return 0; }

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4975,6 +4975,12 @@ the configuration (without a prefix: ``Auto``).
49754975
A(z); -> z;
49764976
A(a, b); // will not be expanded.
49774977

4978+
.. _MacrosSkippedByRemoveParentheses:
4979+
4980+
**MacrosSkippedByRemoveParentheses** (``List of Strings``) :versionbadge:`clang-format 21` :ref:`<MacrosSkippedByRemoveParentheses>`
4981+
A vector of function-like macros whose invocations should be skipped by
4982+
``RemoveParentheses``.
4983+
49784984
.. _MainIncludeChar:
49794985

49804986
**MainIncludeChar** (``MainIncludeCharDiscriminator``) :versionbadge:`clang-format 19` :ref:`<MainIncludeChar>`

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ New Compiler Flags
376376

377377
- New option ``-ignore-pch`` added to disable precompiled headers. It overrides ``-emit-pch`` and ``-include-pch``. (#GH142409, `PCHDocs <https://clang.llvm.org/docs/UsersManual.html#ignoring-a-pch-file>`_).
378378

379+
- New options ``-g[no-]key-instructions`` added, disabled by default. Reduces jumpiness of debug stepping for optimized code in some debuggers (not LLDB at this time). Not recommended for use without optimizations. DWARF only. Note both the positive and negative flags imply ``-g``.
380+
379381
Deprecated Compiler Flags
380382
-------------------------
381383

@@ -891,7 +893,7 @@ Bug Fixes to C++ Support
891893
- Clang no longer crashes when trying to unify the types of arrays with
892894
certain differences in qualifiers (this could happen during template argument
893895
deduction or when building a ternary operator). (#GH97005)
894-
- Fixed type alias CTAD issues involving default template arguments. (#GH134471)
896+
- Fixed type alias CTAD issues involving default template arguments. (#GH133132), (#GH134471)
895897
- Fixed CTAD issues when initializing anonymous fields with designated initializers. (#GH67173)
896898
- The initialization kind of elements of structured bindings
897899
direct-list-initialized from an array is corrected to direct-initialization.
@@ -972,6 +974,8 @@ Bug Fixes to C++ Support
972974
(#GH135281)
973975
- Fix a crash in the presence of invalid base classes. (#GH147186)
974976
- Fix a crash with NTTP when instantiating local class.
977+
- Fixed a crash involving list-initialization of an empty class with a
978+
non-empty initializer list. (#GH147949)
975979

976980
Bug Fixes to AST Handling
977981
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1156,6 +1160,8 @@ clang-format
11561160
``enum`` enumerator lists.
11571161
- Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
11581162
- Add ``SpaceAfterOperatorKeyword`` option.
1163+
- Add ``MacrosSkippedByRemoveParentheses`` option so that their invocations are
1164+
skipped by ``RemoveParentheses``.
11591165

11601166
clang-refactor
11611167
--------------

clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ class Comparator {
312312
Self *self() { return reinterpret_cast<Self *>(this); }
313313

314314
public:
315-
bool compareByCase(const SExpr *E1, const SExpr* E2) {
315+
bool compare(const SExpr *E1, const SExpr *E2) {
316+
if (E1->opcode() != E2->opcode())
317+
return false;
316318
switch (E1->opcode()) {
317319
#define TIL_OPCODE_DEF(X) \
318320
case COP_##X: \
@@ -338,12 +340,6 @@ class EqualsComparator : public Comparator<EqualsComparator> {
338340
bool compareStrings (StringRef s, StringRef r) { return s == r; }
339341
bool comparePointers(const void* P, const void* Q) { return P == Q; }
340342

341-
bool compare(const SExpr *E1, const SExpr* E2) {
342-
if (E1->opcode() != E2->opcode())
343-
return false;
344-
return compareByCase(E1, E2);
345-
}
346-
347343
// TODO -- handle alpha-renaming of variables
348344
void enterScope(const Variable *V1, const Variable *V2) {}
349345
void leaveScope() {}
@@ -377,9 +373,7 @@ class MatchComparator : public Comparator<MatchComparator> {
377373
if (E1->opcode() == COP_Wildcard || E2->opcode() == COP_Wildcard)
378374
return true;
379375
// otherwise normal equality.
380-
if (E1->opcode() != E2->opcode())
381-
return false;
382-
return compareByCase(E1, E2);
376+
return Comparator::compare(E1, E2);
383377
}
384378

385379
// TODO -- handle alpha-renaming of variables

0 commit comments

Comments
 (0)