Skip to content

Commit e37b4bd

Browse files
authored
Merge branch 'main' into hlsl-firstbitlow
2 parents d729dce + 193ea83 commit e37b4bd

File tree

418 files changed

+11877
-4561
lines changed

Some content is hidden

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

418 files changed

+11877
-4561
lines changed

.ci/metrics/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"https://influx-prod-13-prod-us-east-0.grafana.net/api/v1/push/influx/write"
1313
)
1414
GITHUB_PROJECT = "llvm/llvm-project"
15-
WORKFLOWS_TO_TRACK = ["Check code formatting", "LLVM Premerge Checks"]
15+
WORKFLOWS_TO_TRACK = ["LLVM Premerge Checks"]
1616
SCRAPE_INTERVAL_SECONDS = 5 * 60
1717

1818

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static void ignoreTypeLocClasses(
342342
Loc = Loc.getNextTypeLoc();
343343
}
344344

345-
static bool isMutliLevelPointerToTypeLocClasses(
345+
static bool isMultiLevelPointerToTypeLocClasses(
346346
TypeLoc Loc,
347347
std::initializer_list<TypeLoc::TypeLocClass> const &LocClasses) {
348348
ignoreTypeLocClasses(Loc, {TypeLoc::Paren, TypeLoc::Qualified});
@@ -424,7 +424,7 @@ void UseAutoCheck::replaceExpr(
424424

425425
auto Diag = diag(Range.getBegin(), Message);
426426

427-
bool ShouldReplenishVariableName = isMutliLevelPointerToTypeLocClasses(
427+
bool ShouldReplenishVariableName = isMultiLevelPointerToTypeLocClasses(
428428
TSI->getTypeLoc(), {TypeLoc::FunctionProto, TypeLoc::ConstantArray});
429429

430430
// Space after 'auto' to handle cases where the '*' in the pointer type is

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ Changes in existing checks
351351
<clang-tidy/checks/performance/move-const-arg>` check to fix a crash when
352352
an argument type is declared but not defined.
353353

354-
- Improved :doc:`performance-unnecessary-copy-initialization`
355-
<clang-tidy/checks/performance/unnecessary-copy-initialization> check
354+
- Improved :doc:`performance-unnecessary-copy-initialization
355+
<clang-tidy/checks/performance/unnecessary-copy-initialization>` check
356356
to consider static member functions the same way as free functions.
357357

358358
- Improved :doc:`readability-container-contains

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,9 @@ X86 Support
10681068
Arm and AArch64 Support
10691069
^^^^^^^^^^^^^^^^^^^^^^^
10701070

1071+
- Implementation of SVE2.1 and SME2.1 in accordance with the Arm C Language
1072+
Extensions (ACLE) is now available.
1073+
10711074
- In the ARM Target, the frame pointer (FP) of a leaf function can be retained
10721075
by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP
10731076
in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding

clang/include/clang/Basic/Builtins.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,10 +3347,12 @@ def VFork : LibBuiltin<"unistd.h"> {
33473347
}
33483348

33493349
// POSIX pthread.h
3350-
// FIXME: This should be a GNULibBuiltin, but it's currently missing the prototype.
33513350

3352-
def PthreadCreate : CustomEntry {
3353-
let Entry = "LIBBUILTIN(pthread_create, \"\", \"fC<2,3>\", PTHREAD_H, ALL_GNU_LANGUAGES)";
3351+
def PthreadCreate : GNULibBuiltin<"pthread.h"> {
3352+
let Spellings = ["pthread_create"];
3353+
let Attributes = [FunctionWithoutBuiltinPrefix, Callback<[2, 3]>];
3354+
// Note that we don't have an expressable prototype so we leave it empty.
3355+
let Prototype = "";
33543356
}
33553357

33563358
def SigSetJmp : LibBuiltin<"setjmp.h"> {

clang/include/clang/Basic/BuiltinsBase.td

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class IndexedAttribute<string baseMangling, int I> : Attribute<baseMangling> {
1717
int Index = I;
1818
}
1919

20+
class MultiIndexAttribute<string baseMangling, list<int> Is>
21+
: Attribute<baseMangling> {
22+
list<int> Indices = Is;
23+
}
24+
2025
// Standard Attributes
2126
// -------------------
2227
def NoReturn : Attribute<"r">;
@@ -77,6 +82,10 @@ def Constexpr : Attribute<"E">;
7782
// Builtin is immediate and must be constant evaluated. Implies Constexpr, and will only be supported in C++20 mode.
7883
def Consteval : Attribute<"EG">;
7984

85+
// Callback behavior: the first index argument is called with the arguments
86+
// indicated by the remaining indices.
87+
class Callback<list<int> ArgIndices> : MultiIndexAttribute<"C", ArgIndices>;
88+
8089
// Builtin kinds
8190
// =============
8291

@@ -92,10 +101,6 @@ class Builtin {
92101
bit EnableOpenCLLong = 0;
93102
}
94103

95-
class CustomEntry {
96-
string Entry;
97-
}
98-
99104
class AtomicBuiltin : Builtin;
100105

101106
class LibBuiltin<string header, string languages = "ALL_LANGUAGES"> : Builtin {

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,7 +4108,7 @@ defm ms_tls_guards : BoolFOption<"ms-tls-guards",
41084108
"Do not emit code to perform on-demand initialization of thread-local variables">,
41094109
PosFlag<SetTrue>>;
41104110
def ftime_report : Flag<["-"], "ftime-report">, Group<f_Group>,
4111-
Visibility<[ClangOption, CC1Option]>,
4111+
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
41124112
MarshallingInfoFlag<CodeGenOpts<"TimePasses">>;
41134113
def ftime_report_EQ: Joined<["-"], "ftime-report=">, Group<f_Group>,
41144114
Visibility<[ClangOption, CC1Option]>, Values<"per-pass,per-pass-run">,
@@ -4364,7 +4364,7 @@ defm split_machine_functions: BoolFOption<"split-machine-functions",
43644364
CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
43654365
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
43664366
NegFlag<SetFalse, [], [ClangOption], "Disable">,
4367-
BothFlags<[], [ClangOption], " late function splitting using profile information (x86 ELF)">>;
4367+
BothFlags<[], [ClangOption], " late function splitting using profile information (x86 and aarch64 ELF)">>;
43684368

43694369
defm strict_return : BoolFOption<"strict-return",
43704370
CodeGenOpts<"StrictReturn">, DefaultTrue,

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ bool InitLink::emit(Compiler<Emitter> *Ctx, const Expr *E) const {
9090
if (!Ctx->emitConstUint32(Offset, E))
9191
return false;
9292
return Ctx->emitArrayElemPtrPopUint32(E);
93+
case K_InitList:
94+
return true;
9395
default:
9496
llvm_unreachable("Unhandled InitLink kind");
9597
}
@@ -1717,6 +1719,8 @@ bool Compiler<Emitter>::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
17171719
template <class Emitter>
17181720
bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
17191721
const Expr *ArrayFiller, const Expr *E) {
1722+
InitLinkScope<Emitter> ILS(this, InitLink::InitList());
1723+
17201724
QualType QT = E->getType();
17211725
if (const auto *AT = QT->getAs<AtomicType>())
17221726
QT = AT->getValueType();
@@ -1754,6 +1758,7 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
17541758
auto initPrimitiveField = [=](const Record::Field *FieldToInit,
17551759
const Expr *Init, PrimType T) -> bool {
17561760
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(Init));
1761+
InitLinkScope<Emitter> ILS(this, InitLink::Field(FieldToInit->Offset));
17571762
if (!this->visit(Init))
17581763
return false;
17591764

@@ -1766,6 +1771,7 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
17661771
const Expr *Init) -> bool {
17671772
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(Init));
17681773
InitLinkScope<Emitter> ILS(this, InitLink::Field(FieldToInit->Offset));
1774+
17691775
// Non-primitive case. Get a pointer to the field-to-initialize
17701776
// on the stack and recurse into visitInitializer().
17711777
if (!this->emitGetPtrField(FieldToInit->Offset, Init))
@@ -3812,6 +3818,7 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
38123818

38133819
if (!this->emitGetPtrLocal(*LocalIndex, E))
38143820
return false;
3821+
InitLinkScope<Emitter> ILS(this, InitLink::Temp(*LocalIndex));
38153822
return this->visitInitializer(E);
38163823
}
38173824

@@ -4848,18 +4855,49 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
48484855
// instance pointer of the current function frame, but e.g. to the declaration
48494856
// currently being initialized. Here we emit the necessary instruction(s) for
48504857
// this scenario.
4851-
if (!InitStackActive || !E->isImplicit())
4858+
if (!InitStackActive)
48524859
return this->emitThis(E);
48534860

4854-
if (InitStackActive && !InitStack.empty()) {
4861+
if (!InitStack.empty()) {
4862+
// If our init stack is, for example:
4863+
// 0 Stack: 3 (decl)
4864+
// 1 Stack: 6 (init list)
4865+
// 2 Stack: 1 (field)
4866+
// 3 Stack: 6 (init list)
4867+
// 4 Stack: 1 (field)
4868+
//
4869+
// We want to find the LAST element in it that's an init list,
4870+
// which is marked with the K_InitList marker. The index right
4871+
// before that points to an init list. We need to find the
4872+
// elements before the K_InitList element that point to a base
4873+
// (e.g. a decl or This), optionally followed by field, elem, etc.
4874+
// In the example above, we want to emit elements [0..2].
48554875
unsigned StartIndex = 0;
4876+
unsigned EndIndex = 0;
4877+
// Find the init list.
48564878
for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) {
4879+
if (InitStack[StartIndex].Kind == InitLink::K_InitList ||
4880+
InitStack[StartIndex].Kind == InitLink::K_This) {
4881+
EndIndex = StartIndex;
4882+
--StartIndex;
4883+
break;
4884+
}
4885+
}
4886+
4887+
// Walk backwards to find the base.
4888+
for (; StartIndex > 0; --StartIndex) {
4889+
if (InitStack[StartIndex].Kind == InitLink::K_InitList)
4890+
continue;
4891+
48574892
if (InitStack[StartIndex].Kind != InitLink::K_Field &&
48584893
InitStack[StartIndex].Kind != InitLink::K_Elem)
48594894
break;
48604895
}
48614896

4862-
for (unsigned I = StartIndex, N = InitStack.size(); I != N; ++I) {
4897+
// Emit the instructions.
4898+
for (unsigned I = StartIndex; I != EndIndex; ++I) {
4899+
if (InitStack[I].Kind == InitLink::K_InitList)
4900+
continue;
48634901
if (!InitStack[I].template emit<Emitter>(this, E))
48644902
return false;
48654903
}

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ struct InitLink {
5151
K_Temp = 2,
5252
K_Decl = 3,
5353
K_Elem = 5,
54+
K_InitList = 6
5455
};
5556

5657
static InitLink This() { return InitLink{K_This}; }
58+
static InitLink InitList() { return InitLink{K_InitList}; }
5759
static InitLink Field(unsigned Offset) {
5860
InitLink IL{K_Field};
5961
IL.Offset = Offset;

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD,
7171
if (!this->visitDeclAndReturn(VD, S.inConstantContext()))
7272
EvalResult.setInvalid();
7373

74+
// Mark global variables as invalid if any diagnostic was produced.
75+
if (S.hasPriorDiagnostic() && Context::shouldBeGloballyIndexed(VD)) {
76+
if (auto GlobalIndex = P.getGlobal(VD)) {
77+
Block *GlobalBlock = P.getGlobal(*GlobalIndex);
78+
GlobalInlineDescriptor &GD =
79+
*reinterpret_cast<GlobalInlineDescriptor *>(GlobalBlock->rawData());
80+
GD.InitState = GlobalInitState::InitializerFailed;
81+
if (GlobalBlock->isInitialized())
82+
GlobalBlock->invokeDtor();
83+
}
84+
}
85+
7486
S.EvaluatingDecl = nullptr;
7587
updateGlobalTemporaries();
7688
return std::move(this->EvalResult);

0 commit comments

Comments
 (0)