Skip to content

Commit ef954d4

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3376)
2 parents 78cf0fe + 5dcd769 commit ef954d4

File tree

209 files changed

+5498
-2417
lines changed

Some content is hidden

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

209 files changed

+5498
-2417
lines changed

bolt/test/binary-analysis/AArch64/cmdline-args.test

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
# Verify that an error message is provided if an input file is missing or incorrect
55

66
RUN: not llvm-bolt-binary-analysis 2>&1 | FileCheck -check-prefix=NOFILEARG %s
7-
NOFILEARG: llvm-bolt-binary-analysis: Not enough positional command line arguments specified!
8-
NOFILEARG-NEXT: Must specify at least 1 positional argument: See: {{.*}}llvm-bolt-binary-analysis --help
7+
NOFILEARG: llvm-bolt-binary-analysis{{(\.exe)?}}: Not enough positional command line arguments specified!
8+
NOFILEARG-NEXT: Must specify at least 1 positional argument: See: {{.*}}llvm-bolt-binary-analysis{{(\.exe)?}} --help
99

1010
RUN: not llvm-bolt-binary-analysis non-existing-file 2>&1 | FileCheck -check-prefix=NONEXISTINGFILEARG %s
11-
NONEXISTINGFILEARG: llvm-bolt-binary-analysis: 'non-existing-file': No such file or directory.
11+
# Don't check the OS-dependent message "No such file or directory".
12+
NONEXISTINGFILEARG: llvm-bolt-binary-analysis{{(\.exe)?}}: 'non-existing-file': {{.*}}
1213

1314
RUN: not llvm-bolt-binary-analysis %p/Inputs/dummy.txt 2>&1 | FileCheck -check-prefix=NOELFFILEARG %s
14-
NOELFFILEARG: llvm-bolt-binary-analysis: '{{.*}}/Inputs/dummy.txt': The file was not recognized as a valid object file.
15+
NOELFFILEARG: llvm-bolt-binary-analysis{{(\.exe)?}}: '{{.*}}/Inputs/dummy.txt': The file was not recognized as a valid object file.
1516

1617
RUN: %clang %cflags -Wl,--emit-relocs %p/../../Inputs/asm_foo.s %p/../../Inputs/asm_main.c -o %t.exe
1718
RUN: llvm-bolt-binary-analysis %t.exe 2>&1 | FileCheck -check-prefix=VALIDELFFILEARG --allow-empty %s
@@ -26,7 +27,7 @@ RUN: llvm-bolt-binary-analysis --help 2>&1 | FileCheck -check-prefix=HELP %s
2627

2728
HELP: OVERVIEW: BinaryAnalysis
2829
HELP-EMPTY:
29-
HELP-NEXT: USAGE: llvm-bolt-binary-analysis [options] <executable>
30+
HELP-NEXT: USAGE: llvm-bolt-binary-analysis{{(\.exe)?}} [options] <executable>
3031
HELP-EMPTY:
3132
HELP-NEXT: OPTIONS:
3233
HELP-EMPTY:

bolt/test/lsda-section-name.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This test check that LSDA section named by .gcc_except_table.main is
22
// disassembled by BOLT.
33

4-
// RUN: %clang++ %cxxflags -O3 -no-pie -c %s -o %t.o
5-
// RUN: %clang++ %cxxflags -O3 -no-pie -fuse-ld=lld %t.o -o %t
4+
// RUN: %clangxx %cxxflags -O3 -no-pie -c %s -o %t.o
5+
// RUN: %clangxx %cxxflags -O3 -no-pie -fuse-ld=lld %t.o -o %t
66
// RUN: llvm-objcopy --rename-section .gcc_except_table=.gcc_except_table.main %t
77
// RUN: llvm-readelf -SW %t | FileCheck %s
88
// RUN: llvm-bolt %t -o %t.bolt

clang/docs/InternalsManual.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Description:
312312
* number: A simple decimal number matches if the argument is the same as the
313313
number. Example: ``"%plural{1:mouse|:mice}0"``
314314
* range: A range in square brackets matches if the argument is within the
315-
range. Then range is inclusive on both ends. Example:
315+
range. The range is inclusive on both ends. Example:
316316
``"%plural{0:none|1:one|[2,5]:some|:many}0"``
317317
* modulo: A modulo operator is followed by a number, and equals sign and
318318
either a number or a range. The tests are the same as for plain numbers
@@ -341,7 +341,7 @@ Example:
341341
Class:
342342
Integers
343343
Description:
344-
This is a formatter which represents the argument number in a human readable
344+
This is a formatter which represents the argument number in a human-readable
345345
format: the value ``123`` stays ``123``, ``12345`` becomes ``12.34k``,
346346
``6666666` becomes ``6.67M``, and so on for 'G' and 'T'.
347347

@@ -561,7 +561,7 @@ documentation for the ``-verify`` mode can be found at
561561

562562
There are many other possible implementations of this interface, and this is
563563
why we prefer diagnostics to pass down rich structured information in
564-
arguments. For example, an HTML output might want declaration names be
564+
arguments. For example, an HTML output might want declaration names to be
565565
linkified to where they come from in the source. Another example is that a GUI
566566
might let you click on typedefs to expand them. This application would want to
567567
pass significantly more information about types through to the GUI than a
@@ -846,7 +846,7 @@ Option Marshalling Infrastructure
846846
The option marshalling infrastructure automates the parsing of the Clang
847847
``-cc1`` frontend command line arguments into ``CompilerInvocation`` and their
848848
generation from ``CompilerInvocation``. The system replaces lots of repetitive
849-
C++ code with simple, declarative tablegen annotations and it's being used for
849+
C++ code with simple, declarative tablegen annotations and is being used for
850850
the majority of the ``-cc1`` command line interface. This section provides an
851851
overview of the system.
852852

@@ -986,7 +986,7 @@ line.
986986
NegFlag<SetFalse, [], [], "Use the new pass manager in LLVM">,
987987
BothFlags<[], [ClangOption, CC1Option]>>;
988988
989-
With most such pair of flags, the ``-cc1`` frontend accepts only the flag that
989+
With most such pairs of flags, the ``-cc1`` frontend accepts only the flag that
990990
changes the default key path value. The Clang driver is responsible for
991991
accepting both and either forwarding the changing flag or discarding the flag
992992
that would just set the key path to its default.
@@ -1042,8 +1042,8 @@ and the result is assigned to the key path on success.
10421042
The key path defaults to the value specified in ``MarshallingInfoEnum`` prefixed
10431043
by the contents of ``NormalizedValuesScope`` and ``::``. This ensures correct
10441044
reference to an enum case is formed even if the enum resides in different
1045-
namespace or is an enum class. If the value present on command line does not
1046-
match any of the comma-separated values from ``Values``, an error diagnostics is
1045+
namespace or is an enum class. If the value present on the command line does not
1046+
match any of the comma-separated values from ``Values``, an error diagnostic is
10471047
issued. Otherwise, the corresponding element from ``NormalizedValues`` at the
10481048
same index is assigned to the key path (also correctly scoped). The number of
10491049
comma-separated string values and elements of the array within
@@ -1111,7 +1111,7 @@ The Token class
11111111
---------------
11121112

11131113
The ``Token`` class is used to represent a single lexed token. Tokens are
1114-
intended to be used by the lexer/preprocess and parser libraries, but are not
1114+
intended to be used by the lexer/preprocessor and parser libraries, but are not
11151115
intended to live beyond them (for example, they should not live in the ASTs).
11161116

11171117
Tokens most often live on the stack (or some other location that is efficient
@@ -1253,7 +1253,7 @@ In order to do this, whenever the parser expects a ``tok::identifier`` or
12531253
``tok::coloncolon``, it should call the ``TryAnnotateTypeOrScopeToken`` or
12541254
``TryAnnotateCXXScopeToken`` methods to form the annotation token. These
12551255
methods will maximally form the specified annotation tokens and replace the
1256-
current token with them, if applicable. If the current tokens is not valid for
1256+
current token with them, if applicable. If the current token is not valid for
12571257
an annotation token, it will remain an identifier or "``::``" token.
12581258

12591259
.. _Lexer:
@@ -1276,7 +1276,7 @@ The lexer has a couple of interesting modal features:
12761276
This mode is used for lexing within an "``#if 0``" block, for example.
12771277
* The lexer can capture and return comments as tokens. This is required to
12781278
support the ``-C`` preprocessor mode, which passes comments through, and is
1279-
used by the diagnostic checker to identifier expect-error annotations.
1279+
used by the diagnostic checker to identify expect-error annotations.
12801280
* The lexer can be in ``ParsingFilename`` mode, which happens when
12811281
preprocessing after reading a ``#include`` directive. This mode changes the
12821282
parsing of "``<``" to return an "angled string" instead of a bunch of tokens
@@ -1308,7 +1308,7 @@ The ``TokenLexer`` class
13081308
------------------------
13091309

13101310
The ``TokenLexer`` class is a token provider that returns tokens from a list of
1311-
tokens that came from somewhere else. It typically used for two things: 1)
1311+
tokens that came from somewhere else. It is typically used for two things: 1)
13121312
returning tokens from a macro definition as it is being expanded 2) returning
13131313
tokens from an arbitrary buffer of tokens. The later use is used by
13141314
``_Pragma`` and will most likely be used to handle unbounded look-ahead for the
@@ -1509,7 +1509,7 @@ type checker must verify that the operand has a pointer type. It would not be
15091509
correct to check that with "``isa<PointerType>(SubExpr->getType())``", because
15101510
this predicate would fail if the subexpression had a typedef type.
15111511

1512-
The solution to this problem are a set of helper methods on ``Type``, used to
1512+
The solution to this problem is a set of helper methods on ``Type``, used to
15131513
check their properties. In this case, it would be correct to use
15141514
"``SubExpr->getType()->isPointerType()``" to do the check. This predicate will
15151515
return true if the *canonical type is a pointer*, which is true any time the
@@ -1632,7 +1632,7 @@ the names are inside the ``DeclarationName`` class).
16321632

16331633
``CXXLiteralOperatorName``
16341634

1635-
The name is a C++11 user defined literal operator. User defined
1635+
The name is a C++11 user-defined literal operator. User-defined
16361636
Literal operators are named according to the suffix they define,
16371637
e.g., "``_foo``" for "``operator "" _foo``". Use
16381638
``N.getCXXLiteralIdentifier()`` to retrieve the corresponding
@@ -2215,7 +2215,7 @@ Consequently, we must either set the virtual flag for the definition (but then
22152215
we create a malformed AST which the parser would never create), or we import
22162216
the whole redeclaration chain of the function. The most recent version of the
22172217
``ASTImporter`` uses the latter mechanism. We do import all function
2218-
declarations - regardless if they are definitions or prototypes - in the order
2218+
declarations - regardless of whether they are definitions or prototypes - in the order
22192219
as they appear in the "from" context.
22202220

22212221
.. One definition
@@ -2338,7 +2338,7 @@ library receive an Error object, which they must check.
23382338
During import of a specific declaration, it may happen that some AST nodes had
23392339
already been created before we recognize an error. In this case, we signal back
23402340
the error to the caller, but the "to" context remains polluted with those nodes
2341-
which had been created. Ideally, those nodes should not had been created, but
2341+
which had been created. Ideally, those nodes should not have been created, but
23422342
that time we did not know about the error, the error happened later. Since the
23432343
AST is immutable (most of the cases we can't remove existing nodes) we choose
23442344
to mark these nodes as erroneous.
@@ -2579,7 +2579,7 @@ that there are global declarations which collide with declarations from other
25792579
translation units, but they are not referenced outside from their translation
25802580
unit. These declarations should be in an unnamed namespace ideally. If we treat
25812581
these collisions liberally then CTU analysis can find more results. Note, the
2582-
feature be able to choose between name conflict handling strategies is still an
2582+
feature to be able to choose between name conflict handling strategies is still an
25832583
ongoing work.
25842584

25852585
.. _CFG:

clang/docs/ShadowCallStack.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The instrumentation makes use of the platform register ``x18`` on AArch64,
6161
``x3`` (``gp``) on RISC-V with software shadow stack and ``ssp`` on RISC-V with
6262
hardware shadow stack, which needs `Zicfiss`_ and ``-fcf-protection=return``.
6363
Users can choose between the software and hardware based shadow stack
64-
implementation on RISC-V backend by passing ``-fsanitize=shadowcallstack``
64+
implementation on RISC-V backend by passing ``-fsanitize=shadow-call-stack``
6565
or ``Zicfiss`` with ``-fcf-protection=return``.
6666
For simplicity we will refer to this as the ``SCSReg``. On some platforms,
6767
``SCSReg`` is reserved, and on others, it is designated as a scratch register.

clang/include/clang/Basic/CustomizableOptional.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ template <typename T> class CustomizableOptional {
7070

7171
void reset() { Storage.reset(); }
7272

73-
LLVM_DEPRECATED("Use &*X instead.", "&*X")
74-
constexpr const T *getPointer() const { return &Storage.value(); }
75-
LLVM_DEPRECATED("Use &*X instead.", "&*X")
76-
T *getPointer() { return &Storage.value(); }
77-
LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X")
78-
constexpr const T &value() const & { return Storage.value(); }
79-
LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X")
80-
T &value() & { return Storage.value(); }
81-
8273
constexpr explicit operator bool() const { return has_value(); }
8374
constexpr bool has_value() const { return Storage.has_value(); }
8475
constexpr const T *operator->() const { return &Storage.value(); }
@@ -90,8 +81,6 @@ template <typename T> class CustomizableOptional {
9081
return has_value() ? operator*() : std::forward<U>(alt);
9182
}
9283

93-
LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X")
94-
T &&value() && { return std::move(Storage.value()); }
9584
T &&operator*() && { return std::move(Storage.value()); }
9685

9786
template <typename U> T value_or(U &&alt) && {

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ struct MissingFeatures {
217217
static bool intrinsics() { return false; }
218218
static bool isMemcpyEquivalentSpecialMember() { return false; }
219219
static bool isTrivialCtorOrDtor() { return false; }
220+
static bool lambdaCaptures() { return false; }
220221
static bool lambdaFieldToName() { return false; }
221222
static bool loopInfoStack() { return false; }
222223
static bool lowerAggregateLoadStore() { return false; }

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ class CompilerInstance : public ModuleLoader {
420420
/// @{
421421

422422
llvm::vfs::FileSystem &getVirtualFileSystem() const;
423+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
424+
getVirtualFileSystemPtr() const;
423425

424426
/// @}
425427
/// @name File Manager

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,14 @@ bool InitLink::emit(Compiler<Emitter> *Ctx, const Expr *E) const {
106106
return true;
107107
}
108108

109-
/// Scope managing label targets.
110-
template <class Emitter> class LabelScope {
111-
public:
112-
virtual ~LabelScope() {}
113-
114-
protected:
115-
LabelScope(Compiler<Emitter> *Ctx) : Ctx(Ctx) {}
116-
/// Compiler instance.
117-
Compiler<Emitter> *Ctx;
118-
};
119-
120109
/// Sets the context for break/continue statements.
121-
template <class Emitter> class LoopScope final : public LabelScope<Emitter> {
110+
template <class Emitter> class LoopScope final {
122111
public:
123112
using LabelTy = typename Compiler<Emitter>::LabelTy;
124113
using OptLabelTy = typename Compiler<Emitter>::OptLabelTy;
125114

126115
LoopScope(Compiler<Emitter> *Ctx, LabelTy BreakLabel, LabelTy ContinueLabel)
127-
: LabelScope<Emitter>(Ctx), OldBreakLabel(Ctx->BreakLabel),
116+
: Ctx(Ctx), OldBreakLabel(Ctx->BreakLabel),
128117
OldContinueLabel(Ctx->ContinueLabel),
129118
OldBreakVarScope(Ctx->BreakVarScope),
130119
OldContinueVarScope(Ctx->ContinueVarScope) {
@@ -142,22 +131,23 @@ template <class Emitter> class LoopScope final : public LabelScope<Emitter> {
142131
}
143132

144133
private:
134+
Compiler<Emitter> *Ctx;
145135
OptLabelTy OldBreakLabel;
146136
OptLabelTy OldContinueLabel;
147137
VariableScope<Emitter> *OldBreakVarScope;
148138
VariableScope<Emitter> *OldContinueVarScope;
149139
};
150140

151141
// Sets the context for a switch scope, mapping labels.
152-
template <class Emitter> class SwitchScope final : public LabelScope<Emitter> {
142+
template <class Emitter> class SwitchScope final {
153143
public:
154144
using LabelTy = typename Compiler<Emitter>::LabelTy;
155145
using OptLabelTy = typename Compiler<Emitter>::OptLabelTy;
156146
using CaseMap = typename Compiler<Emitter>::CaseMap;
157147

158148
SwitchScope(Compiler<Emitter> *Ctx, CaseMap &&CaseLabels, LabelTy BreakLabel,
159149
OptLabelTy DefaultLabel)
160-
: LabelScope<Emitter>(Ctx), OldBreakLabel(Ctx->BreakLabel),
150+
: Ctx(Ctx), OldBreakLabel(Ctx->BreakLabel),
161151
OldDefaultLabel(this->Ctx->DefaultLabel),
162152
OldCaseLabels(std::move(this->Ctx->CaseLabels)),
163153
OldLabelVarScope(Ctx->BreakVarScope) {
@@ -175,6 +165,7 @@ template <class Emitter> class SwitchScope final : public LabelScope<Emitter> {
175165
}
176166

177167
private:
168+
Compiler<Emitter> *Ctx;
178169
OptLabelTy OldBreakLabel;
179170
OptLabelTy OldDefaultLabel;
180171
CaseMap OldCaseLabels;
@@ -1767,6 +1758,9 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
17671758
if (Inits.size() == 1 && E->getType() == Inits[0]->getType())
17681759
return this->delegate(Inits[0]);
17691760

1761+
if (!R)
1762+
return false;
1763+
17701764
auto initPrimitiveField = [=](const Record::Field *FieldToInit,
17711765
const Expr *Init, PrimType T,
17721766
bool Activate = false) -> bool {

clang/lib/Basic/SourceManager.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,18 +2366,16 @@ size_t SourceManager::getDataStructureSizes() const {
23662366

23672367
SourceManagerForFile::SourceManagerForFile(StringRef FileName,
23682368
StringRef Content) {
2369-
// This is referenced by `FileMgr` and will be released by `FileMgr` when it
2370-
// is deleted.
2371-
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
2372-
new llvm::vfs::InMemoryFileSystem);
2369+
auto InMemoryFileSystem =
2370+
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
23732371
InMemoryFileSystem->addFile(
23742372
FileName, 0,
23752373
llvm::MemoryBuffer::getMemBuffer(Content, FileName,
23762374
/*RequiresNullTerminator=*/false));
23772375
// This is passed to `SM` as reference, so the pointer has to be referenced
23782376
// in `Environment` so that `FileMgr` can out-live this function scope.
2379-
FileMgr =
2380-
std::make_unique<FileManager>(FileSystemOptions(), InMemoryFileSystem);
2377+
FileMgr = std::make_unique<FileManager>(FileSystemOptions(),
2378+
std::move(InMemoryFileSystem));
23812379
DiagOpts = std::make_unique<DiagnosticOptions>();
23822380
// This is passed to `SM` as reference, so the pointer has to be referenced
23832381
// by `Environment` due to the same reason above.

clang/lib/CIR/CodeGen/CIRGenDecl.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void CIRGenFunction::emitExprAsInit(const Expr *init, const ValueDecl *d,
520520
llvm_unreachable("bad evaluation kind");
521521
}
522522

523-
void CIRGenFunction::emitDecl(const Decl &d) {
523+
void CIRGenFunction::emitDecl(const Decl &d, bool evaluateConditionDecl) {
524524
switch (d.getKind()) {
525525
case Decl::BuiltinTemplate:
526526
case Decl::TranslationUnit:
@@ -608,11 +608,14 @@ void CIRGenFunction::emitDecl(const Decl &d) {
608608
case Decl::UsingDirective: // using namespace X; [C++]
609609
assert(!cir::MissingFeatures::generateDebugInfo());
610610
return;
611-
case Decl::Var: {
611+
case Decl::Var:
612+
case Decl::Decomposition: {
612613
const VarDecl &vd = cast<VarDecl>(d);
613614
assert(vd.isLocalVarDecl() &&
614615
"Should not see file-scope variables inside a function!");
615616
emitVarDecl(vd);
617+
if (evaluateConditionDecl)
618+
maybeEmitDeferredVarDeclInit(&vd);
616619
return;
617620
}
618621
case Decl::OpenACCDeclare:
@@ -632,7 +635,6 @@ void CIRGenFunction::emitDecl(const Decl &d) {
632635
case Decl::ImplicitConceptSpecialization:
633636
case Decl::TopLevelStmt:
634637
case Decl::UsingPack:
635-
case Decl::Decomposition: // This could be moved to join Decl::Var
636638
case Decl::OMPDeclareReduction:
637639
case Decl::OMPDeclareMapper:
638640
cgm.errorNYI(d.getSourceRange(),
@@ -797,3 +799,11 @@ void CIRGenFunction::emitAutoVarTypeCleanup(
797799
assert(!cir::MissingFeatures::ehCleanupFlags());
798800
ehStack.pushCleanup<DestroyObject>(cleanupKind, addr, type, destroyer);
799801
}
802+
803+
void CIRGenFunction::maybeEmitDeferredVarDeclInit(const VarDecl *vd) {
804+
if (auto *dd = dyn_cast_if_present<DecompositionDecl>(vd)) {
805+
for (auto *b : dd->flat_bindings())
806+
if (auto *hd = b->getHoldingVar())
807+
emitVarDecl(*hd);
808+
}
809+
}

0 commit comments

Comments
 (0)