Skip to content

Commit 2fe2b15

Browse files
Merge branch 'main' into libcxx-test-nasty-string-20
2 parents 653e7ff + d39d24c commit 2fe2b15

File tree

542 files changed

+30939
-23212
lines changed

Some content is hidden

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

542 files changed

+30939
-23212
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN cmake -B ./build -G Ninja ./llvm \
3232
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
3333
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
3434
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
35-
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build" \
35+
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build;llvm-symbolizer" \
3636
-DCLANG_DEFAULT_LINKER="lld"
3737

3838
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,18 +871,27 @@ DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
871871

872872
BinaryContext &BC = BF.getBinaryContext();
873873

874-
if (!BF.isSimple())
875-
return std::nullopt;
876-
877-
assert(BF.hasCFG() && "can only record traces in CFG state");
878-
879874
// Offsets of the trace within this function.
880875
const uint64_t From = FirstLBR.To - BF.getAddress();
881876
const uint64_t To = SecondLBR.From - BF.getAddress();
882877

883878
if (From > To)
884879
return std::nullopt;
885880

881+
// Accept fall-throughs inside pseudo functions (PLT/thunks).
882+
// This check has to be above BF.empty as pseudo functions would pass it:
883+
// pseudo => ignored => CFG not built => empty.
884+
// If we return nullopt, trace would be reported as mismatching disassembled
885+
// function contents which it is not. To avoid this, return an empty
886+
// fall-through list instead.
887+
if (BF.isPseudo())
888+
return Branches;
889+
890+
if (!BF.isSimple())
891+
return std::nullopt;
892+
893+
assert(BF.hasCFG() && "can only record traces in CFG state");
894+
886895
const BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(From);
887896
const BinaryBasicBlock *ToBB = BF.getBasicBlockContainingOffset(To);
888897

bolt/test/X86/callcont-fallthru.s

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# RUN: link_fdata %s %t %t.pa3 PREAGG3
1010
# RUN: link_fdata %s %t %t.pat PREAGGT1
1111
# RUN: link_fdata %s %t %t.pat2 PREAGGT2
12+
# RUN: link_fdata %s %t %t.patplt PREAGGPLT
1213

1314
## Check normal case: fallthrough is not LP or secondary entry.
1415
# RUN: llvm-strip --strip-unneeded %t -o %t.strip
@@ -42,6 +43,12 @@
4243
# RUN: llvm-bolt %t.strip --pa -p %t.pat2 -o %t.out \
4344
# RUN: --print-cfg --print-only=main | FileCheck %s --check-prefix=CHECK3
4445

46+
## Check pre-aggregated traces don't report zero-sized PLT fall-through as
47+
## invalid trace
48+
# RUN: llvm-bolt %t.strip --pa -p %t.patplt -o %t.out | FileCheck %s \
49+
# RUN: --check-prefix=CHECK-PLT
50+
# CHECK-PLT: traces mismatching disassembled function contents: 0
51+
4552
.globl foo
4653
.type foo, %function
4754
foo:
@@ -65,7 +72,10 @@ main:
6572
movl $0x0, -0x4(%rbp)
6673
movl %edi, -0x8(%rbp)
6774
movq %rsi, -0x10(%rbp)
75+
Ltmp0_br:
6876
callq puts@PLT
77+
## Check PLT traces are accepted
78+
# PREAGGPLT: T #Ltmp0_br# #puts@plt# #puts@plt# 3
6979
## Target is an external-origin call continuation
7080
# PREAGG1: B X:0 #Ltmp1# 2 0
7181
# PREAGGT1: T X:0 #Ltmp1# #Ltmp4_br# 2

bolt/test/link_fdata.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import argparse
11+
import os
1112
import subprocess
1213
import sys
1314
import re
@@ -84,8 +85,16 @@
8485
exit("ERROR: unexpected input:\n%s" % line)
8586

8687
# Read nm output: <symbol value> <symbol type> <symbol name>
88+
is_llvm_nm = os.path.basename(args.nmtool) == "llvm-nm"
8789
nm_output = subprocess.run(
88-
[args.nmtool, "--defined-only", args.objfile], text=True, capture_output=True
90+
[
91+
args.nmtool,
92+
"--defined-only",
93+
"--special-syms" if is_llvm_nm else "--synthetic",
94+
args.objfile,
95+
],
96+
text=True,
97+
capture_output=True,
8998
).stdout
9099
# Populate symbol map
91100
symbols = {}

clang-tools-extra/clangd/AST.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ QualType declaredType(const TypeDecl *D) {
439439
if (const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(D))
440440
if (const auto *Args = CTSD->getTemplateArgsAsWritten())
441441
return Context.getTemplateSpecializationType(
442-
TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(),
443-
/*CanonicalArgs=*/std::nullopt);
442+
TemplateName(CTSD->getSpecializedTemplate()), Args->arguments());
444443
return Context.getTypeDeclType(D);
445444
}
446445

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ C23 Feature Support
170170
scope.
171171
- Fixed a bug where you could not cast a null pointer constant to type
172172
``nullptr_t``. Fixes #GH133644.
173+
- Fixed a failed assertion with an invalid parameter to the ``#embed``
174+
directive. Fixes #GH126940.
173175

174176
C11 Feature Support
175177
^^^^^^^^^^^^^^^^^^^
@@ -301,8 +303,6 @@ Improvements to Clang's diagnostics
301303
- Clang now better preserves the sugared types of pointers to member.
302304
- Clang now better preserves the presence of the template keyword with dependent
303305
prefixes.
304-
- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of
305-
the template parameter.
306306
- Clang now respects the current language mode when printing expressions in
307307
diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also
308308
a bunch of HLSL types being printed as their C++ equivalents.
@@ -334,6 +334,7 @@ Improvements to Clang's diagnostics
334334
- Fixed an assertion when referencing an out-of-bounds parameter via a function
335335
attribute whose argument list refers to parameters by index and the function
336336
is variadic. e.g.,
337+
337338
.. code-block:: c
338339
339340
__attribute__ ((__format_arg__(2))) void test (int i, ...) { }

clang/include/clang/AST/ASTContext.h

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
367367
const ASTContext&>
368368
CanonTemplateTemplateParms;
369369

370+
TemplateTemplateParmDecl *
371+
getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
372+
370373
/// The typedef for the __int128_t type.
371374
mutable TypedefDecl *Int128Decl = nullptr;
372375

@@ -1808,26 +1811,22 @@ class ASTContext : public RefCountedBase<ASTContext> {
18081811
bool ParameterPack,
18091812
TemplateTypeParmDecl *ParmDecl = nullptr) const;
18101813

1811-
QualType getCanonicalTemplateSpecializationType(
1812-
TemplateName T, ArrayRef<TemplateArgument> CanonicalArgs) const;
1814+
QualType getTemplateSpecializationType(TemplateName T,
1815+
ArrayRef<TemplateArgument> Args,
1816+
QualType Canon = QualType()) const;
18131817

18141818
QualType
1815-
getTemplateSpecializationType(TemplateName T,
1816-
ArrayRef<TemplateArgument> SpecifiedArgs,
1817-
ArrayRef<TemplateArgument> CanonicalArgs,
1818-
QualType Underlying = QualType()) const;
1819+
getCanonicalTemplateSpecializationType(TemplateName T,
1820+
ArrayRef<TemplateArgument> Args) const;
18191821

1820-
QualType
1821-
getTemplateSpecializationType(TemplateName T,
1822-
ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
1823-
ArrayRef<TemplateArgument> CanonicalArgs,
1824-
QualType Canon = QualType()) const;
1822+
QualType getTemplateSpecializationType(TemplateName T,
1823+
ArrayRef<TemplateArgumentLoc> Args,
1824+
QualType Canon = QualType()) const;
18251825

1826-
TypeSourceInfo *getTemplateSpecializationTypeInfo(
1827-
TemplateName T, SourceLocation TLoc,
1828-
const TemplateArgumentListInfo &SpecifiedArgs,
1829-
ArrayRef<TemplateArgument> CanonicalArgs,
1830-
QualType Canon = QualType()) const;
1826+
TypeSourceInfo *
1827+
getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc,
1828+
const TemplateArgumentListInfo &Args,
1829+
QualType Canon = QualType()) const;
18311830

18321831
QualType getParenType(QualType NamedType) const;
18331832

@@ -2943,21 +2942,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
29432942
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg)
29442943
const;
29452944

2946-
/// Canonicalize the given template argument list.
2947-
///
2948-
/// Returns true if any arguments were non-canonical, false otherwise.
2949-
bool
2950-
canonicalizeTemplateArguments(MutableArrayRef<TemplateArgument> Args) const;
2951-
2952-
/// Canonicalize the given TemplateTemplateParmDecl.
2953-
TemplateTemplateParmDecl *
2954-
getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
2955-
2956-
TemplateTemplateParmDecl *findCanonicalTemplateTemplateParmDeclInternal(
2957-
TemplateTemplateParmDecl *TTP) const;
2958-
TemplateTemplateParmDecl *insertCanonicalTemplateTemplateParmDeclInternal(
2959-
TemplateTemplateParmDecl *CanonTTP) const;
2960-
29612945
/// Type Query functions. If the type is an instance of the specified class,
29622946
/// return the Type pointer for the underlying maximally pretty type. This
29632947
/// is a member of ASTContext because this may need to do some amount of

clang/include/clang/AST/PropertiesBase.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -877,14 +877,11 @@ let Class = PropertyTypeCase<TemplateArgument, "Expression"> in {
877877
def : Property<"expression", ExprRef> {
878878
let Read = [{ node.getAsExpr() }];
879879
}
880-
def : Property<"IsCanonical", Bool> {
881-
let Read = [{ node.isCanonicalExpr() }];
882-
}
883880
def : Property<"isDefaulted", Bool> {
884881
let Read = [{ node.getIsDefaulted() }];
885882
}
886883
def : Creator<[{
887-
return TemplateArgument(expression, IsCanonical, isDefaulted);
884+
return TemplateArgument(expression, isDefaulted);
888885
}]>;
889886
}
890887
let Class = PropertyTypeCase<TemplateArgument, "Pack"> in {

clang/include/clang/AST/TemplateBase.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ class TemplateArgument {
167167
unsigned Kind : 31;
168168
LLVM_PREFERRED_TYPE(bool)
169169
unsigned IsDefaulted : 1;
170-
LLVM_PREFERRED_TYPE(bool)
171-
unsigned IsCanonicalExpr : 1;
172170
uintptr_t V;
173171
};
174172
union {
@@ -189,8 +187,7 @@ class TemplateArgument {
189187

190188
public:
191189
/// Construct an empty, invalid template argument.
192-
constexpr TemplateArgument()
193-
: TypeOrValue{Null, /*IsDefaulted=*/0, /*IsCanonicalExpr=*/0, /*V=*/0} {}
190+
constexpr TemplateArgument() : TypeOrValue({Null, 0, /* IsDefaulted */ 0}) {}
194191

195192
/// Construct a template type argument.
196193
TemplateArgument(QualType T, bool isNullPtr = false,
@@ -265,10 +262,9 @@ class TemplateArgument {
265262
/// This form of template argument only occurs in template argument
266263
/// lists used for dependent types and for expression; it will not
267264
/// occur in a non-dependent, canonical template argument list.
268-
TemplateArgument(Expr *E, bool IsCanonical, bool IsDefaulted = false) {
265+
explicit TemplateArgument(Expr *E, bool IsDefaulted = false) {
269266
TypeOrValue.Kind = Expression;
270267
TypeOrValue.IsDefaulted = IsDefaulted;
271-
TypeOrValue.IsCanonicalExpr = IsCanonical;
272268
TypeOrValue.V = reinterpret_cast<uintptr_t>(E);
273269
}
274270

@@ -411,11 +407,6 @@ class TemplateArgument {
411407
return reinterpret_cast<Expr *>(TypeOrValue.V);
412408
}
413409

414-
bool isCanonicalExpr() const {
415-
assert(getKind() == Expression && "Unexpected kind");
416-
return TypeOrValue.IsCanonicalExpr;
417-
}
418-
419410
/// Iterator that traverses the elements of a template argument pack.
420411
using pack_iterator = const TemplateArgument *;
421412

clang/include/clang/AST/Type.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6676,9 +6676,10 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
66766676
/// replacement must, recursively, be one of these).
66776677
TemplateName Template;
66786678

6679-
TemplateSpecializationType(TemplateName T, bool IsAlias,
6679+
TemplateSpecializationType(TemplateName T,
66806680
ArrayRef<TemplateArgument> Args,
6681-
QualType Underlying);
6681+
QualType Canon,
6682+
QualType Aliased);
66826683

66836684
public:
66846685
/// Determine whether any of the given template arguments are dependent.
@@ -6746,7 +6747,7 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
67466747

67476748
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx);
67486749
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T,
6749-
ArrayRef<TemplateArgument> Args, QualType Underlying,
6750+
ArrayRef<TemplateArgument> Args,
67506751
const ASTContext &Context);
67516752

67526753
static bool classof(const Type *T) {

0 commit comments

Comments
 (0)