Skip to content

Commit 178ff26

Browse files
authored
Merge branch 'main' into users/kparzysz/e02-iterable-enum
2 parents 8312ca4 + b470ac4 commit 178ff26

File tree

1,558 files changed

+59922
-45898
lines changed

Some content is hidden

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

1,558 files changed

+59922
-45898
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
/clang/www/cxx_dr_status.html @Endilll
3232
/clang/www/make_cxx_dr_status @Endilll
3333

34-
/clang/include/clang/CIR @lanza @bcardosolopes
35-
/clang/lib/CIR @lanza @bcardosolopes
36-
/clang/tools/cir-* @lanza @bcardosolopes
34+
/clang/include/clang/CIR @lanza @bcardosolopes @xlauko @andykaylor
35+
/clang/lib/CIR @lanza @bcardosolopes @xlauko @andykaylor
36+
/clang/tools/cir-* @lanza @bcardosolopes @xlauko @andykaylor
3737

3838
/lldb/ @JDevlieghere
3939

.github/workflows/build-ci-container-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
jobs:
2121
build-ci-container-windows:
2222
if: github.repository_owner == 'llvm'
23-
runs-on: windows-2019
23+
runs-on: windows-2022
2424
outputs:
2525
container-name: ${{ steps.vars.outputs.container-name }}
2626
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
@@ -34,7 +34,7 @@ jobs:
3434
id: vars
3535
run: |
3636
$tag = [int64](Get-Date -UFormat %s)
37-
$container_name="ghcr.io/$env:GITHUB_REPOSITORY_OWNER/ci-windows-2019"
37+
$container_name="ghcr.io/$env:GITHUB_REPOSITORY_OWNER/ci-windows-2022"
3838
echo "container-name=${container_name}" >> $env:GITHUB_OUTPUT
3939
echo "container-name-tag=${container_name}:${tag}" >> $env:GITHUB_OUTPUT
4040
echo "container-filename=ci-windows-${tag}.tar" >> $env:GITHUB_OUTPUT
@@ -58,7 +58,7 @@ jobs:
5858
- build-ci-container-windows
5959
permissions:
6060
packages: write
61-
runs-on: windows-2019
61+
runs-on: windows-2022
6262
env:
6363
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6464
steps:

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Agent image for LLVM org cluster.
22
# .net 4.8 is required by chocolately package manager.
3-
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
3+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022
44

55
# Restore the default Windows shell for correct batch processing.
66
SHELL ["cmd", "/S", "/C"]
@@ -39,11 +39,16 @@ RUN regsvr32 /S "C:\BuildTools\DIA SDK\bin\amd64\msdia140.dll" & \
3939

4040
# install tools as described in https://llvm.org/docs/GettingStartedVS.html
4141
# and a few more that were not documented...
42-
RUN choco install -y ninja git sccache
4342
# Pin an older version of Python; the current Python 3.10 fails when
4443
# doing "pip install" for the other dependencies, as it fails to find libxml
4544
# while compiling some package.
46-
RUN choco install -y python3 --version 3.9.7
45+
# We version pin the other packages as well to ensure the container build is as
46+
# reproducible as possible to prevent issues when upgrading only part of the
47+
# container.
48+
RUN choco install -y ninja --version 1.13.1 && \
49+
choco install -y git --version 2.50.1 && \
50+
choco install -y sccache --version 0.10.0 && \
51+
choco install -y python3 --version 3.9.7
4752

4853
# Testing requires psutil
4954
RUN pip install psutil

.github/workflows/premerge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
if: >-
7777
github.repository_owner == 'llvm' &&
7878
(github.event_name != 'pull_request' || github.event.action != 'closed')
79-
runs-on: llvm-premerge-windows-runners
79+
runs-on: llvm-premerge-windows-2022-runners
8080
defaults:
8181
run:
8282
shell: bash

bolt/lib/Core/BinaryFunctionCallGraph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ buildCallGraph(BinaryContext &BC, CgFilterFunction Filter, bool CgFromPerfData,
200200
if (CSI.Symbol)
201201
Counts.emplace_back(CSI.Symbol, CSI.Count);
202202
} else {
203-
const uint64_t Count = BB->getExecutionCount();
203+
const uint64_t Count = BC.MIB->getAnnotationWithDefault(
204+
Inst, "Count", BB->getExecutionCount());
204205
Counts.emplace_back(DstSym, Count);
205206
}
206207

bolt/runtime/instr.cpp

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,15 @@ bool parseAddressRange(const char *Str, uint64_t &StartAddress,
672672
return true;
673673
}
674674

675+
static constexpr uint32_t NameMax = 4096;
676+
static char TargetPath[NameMax] = {};
677+
675678
/// Get full path to the real binary by getting current virtual address
676679
/// and searching for the appropriate link in address range in
677680
/// /proc/self/map_files
678681
static char *getBinaryPath() {
679682
const uint32_t BufSize = 1024;
680-
const uint32_t NameMax = 4096;
681683
const char DirPath[] = "/proc/self/map_files/";
682-
static char TargetPath[NameMax] = {};
683684
char Buf[BufSize];
684685

685686
if (__bolt_instr_binpath[0] != '\0')
@@ -719,22 +720,31 @@ static char *getBinaryPath() {
719720
return nullptr;
720721
}
721722

722-
ProfileWriterContext readDescriptions() {
723+
ProfileWriterContext readDescriptions(const uint8_t *BinContents,
724+
uint64_t Size) {
723725
ProfileWriterContext Result;
724-
const char *BinPath = getBinaryPath();
725-
assert(BinPath && BinPath[0] != '\0', "failed to find binary path");
726726

727-
uint64_t FD = __open(BinPath, O_RDONLY,
728-
/*mode=*/0666);
729-
assert(static_cast<int64_t>(FD) >= 0, "failed to open binary path");
727+
assert((BinContents == nullptr) == (Size == 0),
728+
"either empty or valid library content buffer");
729+
730+
if (BinContents) {
731+
Result.FileDesc = -1;
732+
} else {
733+
const char *BinPath = getBinaryPath();
734+
assert(BinPath && BinPath[0] != '\0', "failed to find binary path");
730735

731-
Result.FileDesc = FD;
736+
uint64_t FD = __open(BinPath, O_RDONLY,
737+
/*mode=*/0666);
738+
assert(static_cast<int64_t>(FD) >= 0, "failed to open binary path");
732739

733-
// mmap our binary to memory
734-
uint64_t Size = __lseek(FD, 0, SEEK_END);
735-
const uint8_t *BinContents = reinterpret_cast<uint8_t *>(
736-
__mmap(0, Size, PROT_READ, MAP_PRIVATE, FD, 0));
737-
assert(BinContents != MAP_FAILED, "readDescriptions: Failed to mmap self!");
740+
Result.FileDesc = FD;
741+
742+
// mmap our binary to memory
743+
Size = __lseek(FD, 0, SEEK_END);
744+
BinContents = reinterpret_cast<uint8_t *>(
745+
__mmap(0, Size, PROT_READ, MAP_PRIVATE, FD, 0));
746+
assert(BinContents != MAP_FAILED, "readDescriptions: Failed to mmap self!");
747+
}
738748
Result.MMapPtr = BinContents;
739749
Result.MMapSize = Size;
740750
const Elf64_Ehdr *Hdr = reinterpret_cast<const Elf64_Ehdr *>(BinContents);
@@ -1509,7 +1519,7 @@ extern "C" void __bolt_instr_clear_counters() {
15091519
}
15101520

15111521
/// This is the entry point for profile writing.
1512-
/// There are three ways of getting here:
1522+
/// There are four ways of getting here:
15131523
///
15141524
/// * Program execution ended, finalization methods are running and BOLT
15151525
/// hooked into FINI from your binary dynamic section;
@@ -1518,9 +1528,18 @@ extern "C" void __bolt_instr_clear_counters() {
15181528
/// * BOLT prints this function address so you can attach a debugger and
15191529
/// call this function directly to get your profile written to disk
15201530
/// on demand.
1531+
/// * Application can, at interesting runtime point, iterate through all
1532+
/// the loaded native libraries and for each call dlopen() and dlsym()
1533+
/// to get a pointer to this function and call through the acquired
1534+
/// function pointer to dump profile data.
15211535
///
15221536
extern "C" void __attribute((force_align_arg_pointer))
1523-
__bolt_instr_data_dump(int FD) {
1537+
__bolt_instr_data_dump(int FD, const char *LibPath = nullptr,
1538+
const uint8_t *LibContents = nullptr,
1539+
uint64_t LibSize = 0) {
1540+
if (LibPath)
1541+
strCopy(TargetPath, LibPath, NameMax);
1542+
15241543
// Already dumping
15251544
if (!GlobalWriteProfileMutex->acquire())
15261545
return;
@@ -1531,7 +1550,7 @@ __bolt_instr_data_dump(int FD) {
15311550
assert(ret == 0, "Failed to ftruncate!");
15321551
BumpPtrAllocator HashAlloc;
15331552
HashAlloc.setMaxSize(0x6400000);
1534-
ProfileWriterContext Ctx = readDescriptions();
1553+
ProfileWriterContext Ctx = readDescriptions(LibContents, LibSize);
15351554
Ctx.CallFlowTable = new (HashAlloc, 0) CallFlowHashTable(HashAlloc);
15361555

15371556
DEBUG(printStats(Ctx));
@@ -1551,8 +1570,10 @@ __bolt_instr_data_dump(int FD) {
15511570
Ctx.CallFlowTable->forEachElement(visitCallFlowEntry, FD, &Ctx);
15521571

15531572
__fsync(FD);
1554-
__munmap((void *)Ctx.MMapPtr, Ctx.MMapSize);
1555-
__close(Ctx.FileDesc);
1573+
if (Ctx.FileDesc != -1) {
1574+
__munmap((void *)Ctx.MMapPtr, Ctx.MMapSize);
1575+
__close(Ctx.FileDesc);
1576+
}
15561577
HashAlloc.destroy();
15571578
GlobalWriteProfileMutex->release();
15581579
DEBUG(report("Finished writing profile.\n"));

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static auto SerializeReferenceLambda = [](const auto &Ref, Object &Object) {
4545

4646
static json::Object
4747
serializeLocation(const Location &Loc,
48-
const std::optional<StringRef> &RepositoryUrl) {
48+
const std::optional<StringRef> RepositoryUrl) {
4949
Object LocationObj = Object();
5050
LocationObj["LineNumber"] = Loc.StartLineNumber;
5151
LocationObj["Filename"] = Loc.Filename;
@@ -169,7 +169,7 @@ static json::Value serializeComment(const CommentInfo &I) {
169169

170170
static void
171171
serializeCommonAttributes(const Info &I, json::Object &Obj,
172-
const std::optional<StringRef> &RepositoryUrl) {
172+
const std::optional<StringRef> RepositoryUrl) {
173173
Obj["Name"] = I.Name;
174174
Obj["USR"] = toHex(toStringRef(I.USR));
175175

@@ -211,9 +211,9 @@ static void serializeReference(const Reference &Ref, Object &ReferenceObj) {
211211
// differently. Only enums, records, and typedefs are handled here.
212212
static void
213213
serializeCommonChildren(const ScopeChildren &Children, json::Object &Obj,
214-
const std::optional<StringRef> &RepositoryUrl) {
215-
static auto SerializeInfo = [&RepositoryUrl](const auto &Info,
216-
Object &Object) {
214+
const std::optional<StringRef> RepositoryUrl) {
215+
static auto SerializeInfo = [RepositoryUrl](const auto &Info,
216+
Object &Object) {
217217
serializeInfo(Info, Object, RepositoryUrl);
218218
};
219219

@@ -304,7 +304,7 @@ static void serializeInfo(const FieldTypeInfo &I, Object &Obj) {
304304
}
305305

306306
static void serializeInfo(const FunctionInfo &F, json::Object &Obj,
307-
const std::optional<StringRef> &RepositoryURL) {
307+
const std::optional<StringRef> RepositoryURL) {
308308
serializeCommonAttributes(F, Obj, RepositoryURL);
309309
Obj["IsStatic"] = F.IsStatic;
310310

@@ -459,7 +459,7 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj,
459459
}
460460

461461
static void serializeInfo(const VarInfo &I, json::Object &Obj,
462-
const std::optional<StringRef> &RepositoryUrl) {
462+
const std::optional<StringRef> RepositoryUrl) {
463463
serializeCommonAttributes(I, Obj, RepositoryUrl);
464464
Obj["IsStatic"] = I.IsStatic;
465465
auto TypeObj = Object();
@@ -468,15 +468,15 @@ static void serializeInfo(const VarInfo &I, json::Object &Obj,
468468
}
469469

470470
static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
471-
const std::optional<StringRef> &RepositoryUrl) {
471+
const std::optional<StringRef> RepositoryUrl) {
472472
serializeCommonAttributes(I, Obj, RepositoryUrl);
473473

474474
if (!I.Children.Namespaces.empty())
475475
serializeArray(I.Children.Namespaces, Obj, "Namespaces",
476476
SerializeReferenceLambda);
477477

478-
static auto SerializeInfo = [&RepositoryUrl](const auto &Info,
479-
Object &Object) {
478+
static auto SerializeInfo = [RepositoryUrl](const auto &Info,
479+
Object &Object) {
480480
serializeInfo(Info, Object, RepositoryUrl);
481481
};
482482

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

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,45 @@ void ExceptionEscapeCheck::check(const MatchFinder::MatchResult &Result) {
7878
if (!MatchedDecl)
7979
return;
8080

81-
if (Tracer.analyze(MatchedDecl).getBehaviour() ==
82-
utils::ExceptionAnalyzer::State::Throwing)
83-
// FIXME: We should provide more information about the exact location where
84-
// the exception is thrown, maybe the full path the exception escapes
85-
diag(MatchedDecl->getLocation(), "an exception may be thrown in function "
86-
"%0 which should not throw exceptions")
87-
<< MatchedDecl;
81+
const utils::ExceptionAnalyzer::ExceptionInfo Info =
82+
Tracer.analyze(MatchedDecl);
83+
84+
if (Info.getBehaviour() != utils::ExceptionAnalyzer::State::Throwing)
85+
return;
86+
87+
diag(MatchedDecl->getLocation(), "an exception may be thrown in function "
88+
"%0 which should not throw exceptions")
89+
<< MatchedDecl;
90+
91+
const auto &[ThrowType, ThrowInfo] = *Info.getExceptions().begin();
92+
93+
if (ThrowInfo.Loc.isInvalid())
94+
return;
95+
96+
const utils::ExceptionAnalyzer::CallStack &Stack = ThrowInfo.Stack;
97+
diag(ThrowInfo.Loc,
98+
"frame #0: unhandled exception of type %0 may be thrown in function %1 "
99+
"here",
100+
DiagnosticIDs::Note)
101+
<< QualType(ThrowType, 0U) << Stack.back().first;
102+
103+
size_t FrameNo = 1;
104+
for (auto CurrIt = ++Stack.rbegin(), PrevIt = Stack.rbegin();
105+
CurrIt != Stack.rend(); ++CurrIt, ++PrevIt) {
106+
const FunctionDecl *CurrFunction = CurrIt->first;
107+
const FunctionDecl *PrevFunction = PrevIt->first;
108+
const SourceLocation PrevLocation = PrevIt->second;
109+
if (PrevLocation.isValid()) {
110+
diag(PrevLocation, "frame #%0: function %1 calls function %2 here",
111+
DiagnosticIDs::Note)
112+
<< FrameNo << CurrFunction << PrevFunction;
113+
} else {
114+
diag(CurrFunction->getLocation(),
115+
"frame #%0: function %1 calls function %2", DiagnosticIDs::Note)
116+
<< FrameNo << CurrFunction << PrevFunction;
117+
}
118+
++FrameNo;
119+
}
88120
}
89121

90122
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void InterfacesGlobalInitCheck::registerMatchers(MatchFinder *Finder) {
1919
hasDeclContext(anyOf(translationUnitDecl(), // Global scope.
2020
namespaceDecl(), // Namespace scope.
2121
recordDecl())), // Class scope.
22-
unless(isConstexpr()));
22+
unless(isConstexpr()), unless(isConstinit()));
2323

2424
const auto ReferencesUndefinedGlobalVar = declRefExpr(hasDeclaration(
2525
varDecl(GlobalVarDecl, unless(isDefinition())).bind("referencee")));

0 commit comments

Comments
 (0)