Skip to content

Commit de56c73

Browse files
authored
merge main into amd-staging (llvm#2446)
2 parents 310c337 + 22c40b3 commit de56c73

File tree

203 files changed

+7611
-3236
lines changed

Some content is hidden

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

203 files changed

+7611
-3236
lines changed

.ci/monolithic-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function at-exit {
4747
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":linux: Linux x64 Test Results" \
4848
"linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
4949
else
50-
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":linux: Linux x64 Test Results" \
50+
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":penguin: Linux x64 Test Results" \
5151
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
5252
fi
5353
}

.ci/monolithic-windows.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function at-exit {
4242
python "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":windows: Windows x64 Test Results" \
4343
"windows-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
4444
else
45-
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":windows: Windows x64 Test Results" \
45+
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":window: Windows x64 Test Results" \
4646
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
4747
fi
4848
}

bolt/test/link_fdata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
3434
# <is symbol?> <closest elf symbol or DSO name> <relative TO address>
3535
# <number of mispredictions> <number of branches>
36-
fdata_pat = re.compile(r"([01].*) (?P<exec>\d+) (?P<mispred>\d+)")
36+
fdata_pat = re.compile(r"([01].*) (?P<mispred>\d+) (?P<exec>\d+)")
3737

3838
# Pre-aggregated profile:
3939
# {T|B|F|f} [<start_id>:]<start_offset> [<end_id>:]<end_offset> [<ft_end>]
@@ -61,15 +61,15 @@
6161
preagg_match = preagg_pat.match(profile_line)
6262
nolbr_match = nolbr_pat.match(profile_line)
6363
if fdata_match:
64-
src_dst, execnt, mispred = fdata_match.groups()
64+
src_dst, mispred, execnt = fdata_match.groups()
6565
# Split by whitespaces not preceded by a backslash (negative lookbehind)
6666
chunks = re.split(r"(?<!\\) +", src_dst)
6767
# Check if the number of records separated by non-escaped whitespace
6868
# exactly matches the format.
6969
assert (
7070
len(chunks) == 6
7171
), f"ERROR: wrong format/whitespaces must be escaped:\n{line}"
72-
exprs.append(("FDATA", (*chunks, execnt, mispred)))
72+
exprs.append(("FDATA", (*chunks, mispred, execnt)))
7373
elif nolbr_match:
7474
loc, count = nolbr_match.groups()
7575
# Split by whitespaces not preceded by a backslash (negative lookbehind)

clang/include/clang/Frontend/ASTConsumers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ CreateASTDumper(std::unique_ptr<raw_ostream> OS, StringRef FilterString,
3535
bool DumpDecls, bool Deserialize, bool DumpLookups,
3636
bool DumpDeclTypes, ASTDumpOutputFormat Format);
3737

38+
std::unique_ptr<ASTConsumer>
39+
CreateASTDumper(raw_ostream &OS, StringRef FilterString, bool DumpDecls,
40+
bool Deserialize, bool DumpLookups, bool DumpDeclTypes,
41+
ASTDumpOutputFormat Format);
42+
3843
// AST Decl node lister: prints qualified names of all filterable AST Decl
3944
// nodes.
4045
std::unique_ptr<ASTConsumer> CreateASTDeclNodeLister();

clang/include/clang/Sema/Sema.h

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10505,13 +10505,34 @@ class Sema final : public SemaBase {
1050510505
OverloadCandidateParamOrder PO = {},
1050610506
bool AggregateCandidateDeduction = false);
1050710507

10508+
struct CheckNonDependentConversionsFlag {
10509+
/// Do not consider any user-defined conversions when constructing the
10510+
/// initializing sequence.
10511+
bool SuppressUserConversions;
10512+
10513+
/// Before constructing the initializing sequence, we check whether the
10514+
/// parameter type and argument type contain any user defined conversions.
10515+
/// If so, do not initialize them. This effectively bypasses some undesired
10516+
/// instantiation before checking constaints, which might otherwise result
10517+
/// in non-SFINAE errors e.g. recursive constraints.
10518+
bool OnlyInitializeNonUserDefinedConversions;
10519+
10520+
CheckNonDependentConversionsFlag(
10521+
bool SuppressUserConversions,
10522+
bool OnlyInitializeNonUserDefinedConversions)
10523+
: SuppressUserConversions(SuppressUserConversions),
10524+
OnlyInitializeNonUserDefinedConversions(
10525+
OnlyInitializeNonUserDefinedConversions) {}
10526+
};
10527+
1050810528
/// Check that implicit conversion sequences can be formed for each argument
1050910529
/// whose corresponding parameter has a non-dependent type, per DR1391's
1051010530
/// [temp.deduct.call]p10.
1051110531
bool CheckNonDependentConversions(
1051210532
FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
1051310533
ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10514-
ConversionSequenceList &Conversions, bool SuppressUserConversions,
10534+
ConversionSequenceList &Conversions,
10535+
CheckNonDependentConversionsFlag UserConversionFlag,
1051510536
CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
1051610537
Expr::Classification ObjectClassification = {},
1051710538
OverloadCandidateParamOrder PO = {});
@@ -12555,14 +12576,22 @@ class Sema final : public SemaBase {
1255512576
///
1255612577
/// \param OriginalCallArgs If non-NULL, the original call arguments against
1255712578
/// which the deduced argument types should be compared.
12579+
/// \param CheckNonDependent Callback before substituting into the declaration
12580+
/// with the deduced template arguments.
12581+
/// \param OnlyInitializeNonUserDefinedConversions is used as a workaround for
12582+
/// some breakages introduced by CWG2369, where non-user-defined conversions
12583+
/// are checked first before the constraints.
1255812584
TemplateDeductionResult FinishTemplateArgumentDeduction(
1255912585
FunctionTemplateDecl *FunctionTemplate,
1256012586
SmallVectorImpl<DeducedTemplateArgument> &Deduced,
1256112587
unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
1256212588
sema::TemplateDeductionInfo &Info,
1256312589
SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
1256412590
bool PartialOverloading, bool PartialOrdering,
12565-
llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
12591+
llvm::function_ref<bool(bool)> CheckNonDependent =
12592+
[](bool /*OnlyInitializeNonUserDefinedConversions*/) {
12593+
return false;
12594+
});
1256612595

1256712596
/// Perform template argument deduction from a function call
1256812597
/// (C++ [temp.deduct.call]).
@@ -12598,7 +12627,7 @@ class Sema final : public SemaBase {
1259812627
bool PartialOrdering, QualType ObjectType,
1259912628
Expr::Classification ObjectClassification,
1260012629
bool ForOverloadSetAddressResolution,
12601-
llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
12630+
llvm::function_ref<bool(ArrayRef<QualType>, bool)> CheckNonDependent);
1260212631

1260312632
/// Deduce template arguments when taking the address of a function
1260412633
/// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
@@ -13074,6 +13103,9 @@ class Sema final : public SemaBase {
1307413103
/// Was the enclosing context a non-instantiation SFINAE context?
1307513104
bool SavedInNonInstantiationSFINAEContext;
1307613105

13106+
/// Whether we're substituting into constraints.
13107+
bool InConstraintSubstitution;
13108+
1307713109
/// The point of instantiation or synthesis within the source code.
1307813110
SourceLocation PointOfInstantiation;
1307913111

@@ -13123,9 +13155,9 @@ class Sema final : public SemaBase {
1312313155

1312413156
CodeSynthesisContext()
1312513157
: Kind(TemplateInstantiation),
13126-
SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
13127-
Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
13128-
DeductionInfo(nullptr) {}
13158+
SavedInNonInstantiationSFINAEContext(false),
13159+
InConstraintSubstitution(false), Entity(nullptr), Template(nullptr),
13160+
TemplateArgs(nullptr), NumTemplateArgs(0), DeductionInfo(nullptr) {}
1312913161

1313013162
/// Determines whether this template is an actual instantiation
1313113163
/// that should be counted toward the maximum instantiation depth.
@@ -13369,9 +13401,22 @@ class Sema final : public SemaBase {
1336913401
///
1337013402
/// \param SkipForSpecialization when specified, any template specializations
1337113403
/// in a traversal would be ignored.
13404+
///
1337213405
/// \param ForDefaultArgumentSubstitution indicates we should continue looking
1337313406
/// when encountering a specialized member function template, rather than
1337413407
/// returning immediately.
13408+
void getTemplateInstantiationArgs(
13409+
MultiLevelTemplateArgumentList &Result, const NamedDecl *D,
13410+
const DeclContext *DC = nullptr, bool Final = false,
13411+
std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13412+
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13413+
bool ForConstraintInstantiation = false,
13414+
bool SkipForSpecialization = false,
13415+
bool ForDefaultArgumentSubstitution = false);
13416+
13417+
/// This creates a new \p MultiLevelTemplateArgumentList and invokes the other
13418+
/// overload with it as the first parameter. Prefer this overload in most
13419+
/// situations.
1337513420
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
1337613421
const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
1337713422
std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
@@ -13644,7 +13689,7 @@ class Sema final : public SemaBase {
1364413689
ExprResult
1364513690
SubstConstraintExpr(Expr *E,
1364613691
const MultiLevelTemplateArgumentList &TemplateArgs);
13647-
// Unlike the above, this does not evaluates constraints.
13692+
// Unlike the above, this does not evaluate constraints.
1364813693
ExprResult SubstConstraintExprWithoutSatisfaction(
1364913694
Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
1365013695

@@ -13794,6 +13839,12 @@ class Sema final : public SemaBase {
1379413839
return CodeSynthesisContexts.size() > NonInstantiationEntries;
1379513840
}
1379613841

13842+
/// Determine whether we are currently performing constraint substitution.
13843+
bool inConstraintSubstitution() const {
13844+
return !CodeSynthesisContexts.empty() &&
13845+
CodeSynthesisContexts.back().InConstraintSubstitution;
13846+
}
13847+
1379713848
using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
1379813849

1379913850
/// \brief create a Requirement::SubstitutionDiagnostic with only a
@@ -14786,10 +14837,10 @@ class Sema final : public SemaBase {
1478614837
const MultiLevelTemplateArgumentList &TemplateArgs,
1478714838
SourceRange TemplateIDRange);
1478814839

14789-
bool CheckInstantiatedFunctionTemplateConstraints(
14790-
SourceLocation PointOfInstantiation, FunctionDecl *Decl,
14791-
ArrayRef<TemplateArgument> TemplateArgs,
14792-
ConstraintSatisfaction &Satisfaction);
14840+
bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
14841+
FunctionDecl *Decl,
14842+
ArrayRef<TemplateArgument> TemplateArgs,
14843+
ConstraintSatisfaction &Satisfaction);
1479314844

1479414845
/// \brief Emit diagnostics explaining why a constraint expression was deemed
1479514846
/// unsatisfied.

clang/include/clang/Sema/Template.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char {
522522
llvm::PointerUnion<Decl *, DeclArgumentPack *> *
523523
findInstantiationOf(const Decl *D);
524524

525+
/// Similar to \p findInstantiationOf(), but it wouldn't assert if the
526+
/// instantiation was not found within the current instantiation scope. This
527+
/// is helpful for on-demand declaration instantiation.
528+
llvm::PointerUnion<Decl *, DeclArgumentPack *> *
529+
getInstantiationOfIfExists(const Decl *D);
530+
525531
void InstantiatedLocal(const Decl *D, Decl *Inst);
526532
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst);
527533
void MakeInstantiatedLocalArgPack(const Decl *D);

clang/lib/Basic/DiagnosticIDs.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -542,26 +542,32 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
542542
return Result;
543543

544544
const auto &SM = Diag.getSourceManager();
545-
546-
bool ShowInSystemHeader =
547-
IsCustomDiag
548-
? CustomDiagInfo->getDescription(DiagID).ShouldShowInSystemHeader()
549-
: !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader;
550-
551545
// If we are in a system header, we ignore it. We look at the diagnostic class
552546
// because we also want to ignore extensions and warnings in -Werror and
553547
// -pedantic-errors modes, which *map* warnings/extensions to errors.
554-
if (State->SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid() &&
555-
SM.isInSystemHeader(SM.getExpansionLoc(Loc)))
556-
return diag::Severity::Ignored;
557-
548+
if (State->SuppressSystemWarnings && Loc.isValid() &&
549+
SM.isInSystemHeader(SM.getExpansionLoc(Loc))) {
550+
bool ShowInSystemHeader = true;
551+
if (IsCustomDiag)
552+
ShowInSystemHeader =
553+
CustomDiagInfo->getDescription(DiagID).ShouldShowInSystemHeader();
554+
else if (const StaticDiagInfoRec *Rec = GetDiagInfo(DiagID))
555+
ShowInSystemHeader = Rec->WarnShowInSystemHeader;
556+
557+
if (!ShowInSystemHeader)
558+
return diag::Severity::Ignored;
559+
}
558560
// We also ignore warnings due to system macros
559-
bool ShowInSystemMacro =
560-
!GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemMacro;
561-
if (State->SuppressSystemWarnings && !ShowInSystemMacro && Loc.isValid() &&
562-
SM.isInSystemMacro(Loc))
563-
return diag::Severity::Ignored;
561+
if (State->SuppressSystemWarnings && Loc.isValid() &&
562+
SM.isInSystemMacro(Loc)) {
563+
564+
bool ShowInSystemMacro = true;
565+
if (const StaticDiagInfoRec *Rec = GetDiagInfo(DiagID))
566+
ShowInSystemMacro = Rec->WarnShowInSystemMacro;
564567

568+
if (!ShowInSystemMacro)
569+
return diag::Severity::Ignored;
570+
}
565571
// Clang-diagnostics pragmas always take precedence over suppression mapping.
566572
if (!Mapping.isPragma() && Diag.isSuppressedViaMapping(DiagID, Loc))
567573
return diag::Severity::Ignored;

clang/lib/CodeGen/CGBlocks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "CGOpenCLRuntime.h"
1818
#include "CodeGenFunction.h"
1919
#include "CodeGenModule.h"
20+
#include "CodeGenPGO.h"
2021
#include "ConstantEmitter.h"
2122
#include "TargetInfo.h"
2223
#include "clang/AST/Attr.h"
@@ -1522,7 +1523,7 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
15221523
if (IsLambdaConversionToBlock)
15231524
EmitLambdaBlockInvokeBody();
15241525
else {
1525-
PGO.assignRegionCounters(GlobalDecl(blockDecl), fn);
1526+
PGO->assignRegionCounters(GlobalDecl(blockDecl), fn);
15261527
incrementProfileCounter(blockDecl->getBody());
15271528
EmitStmt(blockDecl->getBody());
15281529
}

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "CGRecordLayout.h"
2222
#include "CodeGenFunction.h"
2323
#include "CodeGenModule.h"
24+
#include "CodeGenPGO.h"
2425
#include "TargetInfo.h"
2526
#include "clang/AST/Attr.h"
2627
#include "clang/AST/Decl.h"
@@ -5912,7 +5913,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
59125913
// For more details, see the comment before the definition of
59135914
// IPVK_IndirectCallTarget in InstrProfData.inc.
59145915
if (!CI->getCalledFunction())
5915-
PGO.valueProfile(Builder, llvm::IPVK_IndirectCallTarget, CI, CalleePtr);
5916+
PGO->valueProfile(Builder, llvm::IPVK_IndirectCallTarget, CI, CalleePtr);
59165917

59175918
// In ObjC ARC mode with no ObjC ARC exception safety, tell the ARC
59185919
// optimizer it can aggressively ignore unwind edges.

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "CGOpenMPRuntime.h"
1919
#include "CodeGenFunction.h"
2020
#include "CodeGenModule.h"
21+
#include "CodeGenPGO.h"
2122
#include "ConstantEmitter.h"
2223
#include "EHScopeStack.h"
2324
#include "PatternInit.h"
@@ -368,7 +369,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
368369
return GV;
369370
}
370371

371-
PGO.markStmtMaybeUsed(D.getInit()); // FIXME: Too lazy
372+
PGO->markStmtMaybeUsed(D.getInit()); // FIXME: Too lazy
372373

373374
#ifndef NDEBUG
374375
CharUnits VarSize = CGM.getContext().getTypeSizeInChars(D.getType()) +
@@ -1963,7 +1964,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
19631964
// unless it contains a label.
19641965
if (!HaveInsertPoint()) {
19651966
if (!Init || !ContainsLabel(Init)) {
1966-
PGO.markStmtMaybeUsed(Init);
1967+
PGO->markStmtMaybeUsed(Init);
19671968
return;
19681969
}
19691970
EnsureInsertPoint();
@@ -2076,7 +2077,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
20762077
return EmitExprAsInit(Init, &D, lv, capturedByInit);
20772078
}
20782079

2079-
PGO.markStmtMaybeUsed(Init);
2080+
PGO->markStmtMaybeUsed(Init);
20802081

20812082
if (!emission.IsConstantAggregate) {
20822083
// For simple scalar/complex initialization, store the value directly.

0 commit comments

Comments
 (0)