Skip to content

Commit 905621f

Browse files
committed
Merge tag 'llvmorg-20.1.5' into ldc-release/20.x
LLVM Release 20.1.5
2 parents a905655 + 7b09d7b commit 905621f

File tree

97 files changed

+2782
-500
lines changed

Some content is hidden

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

97 files changed

+2782
-500
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,8 @@ RISC-V Support
12671267
- The option ``-mcmodel=large`` for the large code model is supported.
12681268
- Bump RVV intrinsic to version 1.0, the spec: https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4
12691269

1270+
- `Zicsr` / `Zifencei` are allowed to be duplicated in the presence of `g` in `-march`.
1271+
12701272
CUDA/HIP Language Changes
12711273
^^^^^^^^^^^^^^^^^^^^^^^^^
12721274
- Fixed a bug about overriding a constexpr pure-virtual member function with a non-constexpr virtual member function which causes compilation failure when including standard C++ header `format`.

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,19 @@ ANALYZER_OPTION(
385385
"flex\" won't be analyzed.",
386386
true)
387387

388+
ANALYZER_OPTION(
389+
bool, InlineFunctionsWithAmbiguousLoops, "inline-functions-with-ambiguous-loops",
390+
"If disabled (the default), the analyzer puts functions on a \"do not "
391+
"inline this\" list if it finds an execution path within that function "
392+
"that may potentially perform 'analyzer-max-loop' (= 4 by default) "
393+
"iterations in a loop. (Note that functions that _definitely_ reach the "
394+
"loop limit on some execution path are currently marked as \"do not "
395+
"inline\" even if this option is enabled.) Enabling this option "
396+
"eliminates this (somewhat arbitrary) restriction from the analysis "
397+
"scope, which increases the analysis runtime (on average by ~10%, but "
398+
"a few translation units may see much larger slowdowns).",
399+
false)
400+
388401
//===----------------------------------------------------------------------===//
389402
// Unsigned analyzer options.
390403
//===----------------------------------------------------------------------===//

clang/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ class FunctionSummariesTy {
8181
I->second.MayInline = 0;
8282
}
8383

84-
void markReachedMaxBlockCount(const Decl *D) {
85-
markShouldNotInline(D);
86-
}
87-
8884
std::optional<bool> mayInline(const Decl *D) {
8985
MapTy::const_iterator I = Map.find(D);
9086
if (I != Map.end() && I->second.InlineChecked)

clang/lib/AST/ExprConstant.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12710,11 +12710,13 @@ static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc,
1271012710
bool DetermineForCompleteObject = refersToCompleteObject(LVal);
1271112711

1271212712
auto CheckedHandleSizeof = [&](QualType Ty, CharUnits &Result) {
12713-
if (Ty.isNull() || Ty->isIncompleteType() || Ty->isFunctionType())
12713+
if (Ty.isNull())
1271412714
return false;
1271512715

12716-
if (Ty->isReferenceType())
12717-
Ty = Ty.getNonReferenceType();
12716+
Ty = Ty.getNonReferenceType();
12717+
12718+
if (Ty->isIncompleteType() || Ty->isFunctionType())
12719+
return false;
1271812720

1271912721
return HandleSizeof(Info, ExprLoc, Ty, Result);
1272012722
};

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3552,7 +3552,21 @@ void MicrosoftCXXNameMangler::mangleType(const DependentSizedExtVectorType *T,
35523552

35533553
void MicrosoftCXXNameMangler::mangleType(const ConstantMatrixType *T,
35543554
Qualifiers quals, SourceRange Range) {
3555-
Error(Range.getBegin(), "matrix type") << Range;
3555+
QualType EltTy = T->getElementType();
3556+
3557+
llvm::SmallString<64> TemplateMangling;
3558+
llvm::raw_svector_ostream Stream(TemplateMangling);
3559+
MicrosoftCXXNameMangler Extra(Context, Stream);
3560+
3561+
Stream << "?$";
3562+
3563+
Extra.mangleSourceName("__matrix");
3564+
Extra.mangleType(EltTy, Range, QMM_Escape);
3565+
3566+
Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumRows()));
3567+
Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumColumns()));
3568+
3569+
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__clang"});
35563570
}
35573571

35583572
void MicrosoftCXXNameMangler::mangleType(const DependentSizedMatrixType *T,

clang/lib/AST/NestedNameSpecifier.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,16 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
283283
case TypeSpec: {
284284
const auto *Record =
285285
dyn_cast_or_null<ClassTemplateSpecializationDecl>(getAsRecordDecl());
286-
if (ResolveTemplateArguments && Record) {
286+
const TemplateParameterList *TPL = nullptr;
287+
if (Record) {
288+
TPL = Record->getSpecializedTemplate()->getTemplateParameters();
289+
if (ResolveTemplateArguments) {
287290
// Print the type trait with resolved template parameters.
288291
Record->printName(OS, Policy);
289-
printTemplateArgumentList(
290-
OS, Record->getTemplateArgs().asArray(), Policy,
291-
Record->getSpecializedTemplate()->getTemplateParameters());
292+
printTemplateArgumentList(OS, Record->getTemplateArgs().asArray(),
293+
Policy, TPL);
292294
break;
295+
}
293296
}
294297
const Type *T = getAsType();
295298

@@ -313,16 +316,16 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
313316
TemplateName::Qualified::None);
314317

315318
// Print the template argument list.
316-
printTemplateArgumentList(OS, SpecType->template_arguments(),
317-
InnerPolicy);
319+
printTemplateArgumentList(OS, SpecType->template_arguments(), InnerPolicy,
320+
TPL);
318321
} else if (const auto *DepSpecType =
319322
dyn_cast<DependentTemplateSpecializationType>(T)) {
320323
// Print the template name without its corresponding
321324
// nested-name-specifier.
322325
OS << DepSpecType->getIdentifier()->getName();
323326
// Print the template argument list.
324327
printTemplateArgumentList(OS, DepSpecType->template_arguments(),
325-
InnerPolicy);
328+
InnerPolicy, TPL);
326329
} else {
327330
// Print the type normally
328331
QualType(T, 0).print(OS, InnerPolicy);

clang/lib/Analysis/LiveVariables.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,19 @@ void LiveVariables::dumpExprLiveness(const SourceManager &M) {
662662
}
663663

664664
void LiveVariablesImpl::dumpExprLiveness(const SourceManager &M) {
665+
const ASTContext &Ctx = analysisContext.getASTContext();
666+
auto ByIDs = [&Ctx](const Expr *L, const Expr *R) {
667+
return L->getID(Ctx) < R->getID(Ctx);
668+
};
669+
665670
// Don't iterate over blockEndsToLiveness directly because it's not sorted.
666671
for (const CFGBlock *B : *analysisContext.getCFG()) {
667-
668672
llvm::errs() << "\n[ B" << B->getBlockID()
669673
<< " (live expressions at block exit) ]\n";
670-
for (const Expr *E : blocksEndToLiveness[B].liveExprs) {
674+
std::vector<const Expr *> LiveExprs;
675+
llvm::append_range(LiveExprs, blocksEndToLiveness[B].liveExprs);
676+
llvm::sort(LiveExprs, ByIDs);
677+
for (const Expr *E : LiveExprs) {
671678
llvm::errs() << "\n";
672679
E->dump();
673680
}

clang/lib/Basic/Targets/SystemZ.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static constexpr ISANameRevision ISARevisions[] = {
105105
{{"arch12"}, 12}, {{"z14"}, 12},
106106
{{"arch13"}, 13}, {{"z15"}, 13},
107107
{{"arch14"}, 14}, {{"z16"}, 14},
108-
{{"arch15"}, 15},
108+
{{"arch15"}, 15}, {{"z17"}, 15},
109109
};
110110

111111
int SystemZTargetInfo::getISARevision(StringRef Name) const {

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,8 +1837,8 @@ void UnwrappedLineParser::parseStructuralElement(
18371837
nextToken();
18381838
if (FormatTok->is(tok::l_paren)) {
18391839
parseParens();
1840-
assert(FormatTok->Previous);
1841-
if (FormatTok->Previous->endsSequence(tok::r_paren, tok::kw_auto,
1840+
if (FormatTok->Previous &&
1841+
FormatTok->Previous->endsSequence(tok::r_paren, tok::kw_auto,
18421842
tok::l_paren)) {
18431843
Line->SeenDecltypeAuto = true;
18441844
}

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,20 @@ bool ExprEngine::replayWithoutInlining(ExplodedNode *N,
25102510
return true;
25112511
}
25122512

2513+
/// Return the innermost location context which is inlined at `Node`, unless
2514+
/// it's the top-level (entry point) location context.
2515+
static const LocationContext *getInlinedLocationContext(ExplodedNode *Node,
2516+
ExplodedGraph &G) {
2517+
const LocationContext *CalleeLC = Node->getLocation().getLocationContext();
2518+
const LocationContext *RootLC =
2519+
(*G.roots_begin())->getLocation().getLocationContext();
2520+
2521+
if (CalleeLC->getStackFrame() == RootLC->getStackFrame())
2522+
return nullptr;
2523+
2524+
return CalleeLC;
2525+
}
2526+
25132527
/// Block entrance. (Update counters).
25142528
void ExprEngine::processCFGBlockEntrance(const BlockEdge &L,
25152529
NodeBuilderWithSinks &nodeBuilder,
@@ -2557,21 +2571,24 @@ void ExprEngine::processCFGBlockEntrance(const BlockEdge &L,
25572571
const ExplodedNode *Sink =
25582572
nodeBuilder.generateSink(Pred->getState(), Pred, &tag);
25592573

2560-
// Check if we stopped at the top level function or not.
2561-
// Root node should have the location context of the top most function.
2562-
const LocationContext *CalleeLC = Pred->getLocation().getLocationContext();
2563-
const LocationContext *CalleeSF = CalleeLC->getStackFrame();
2564-
const LocationContext *RootLC =
2565-
(*G.roots_begin())->getLocation().getLocationContext();
2566-
if (RootLC->getStackFrame() != CalleeSF) {
2567-
Engine.FunctionSummaries->markReachedMaxBlockCount(CalleeSF->getDecl());
2574+
if (const LocationContext *LC = getInlinedLocationContext(Pred, G)) {
2575+
// FIXME: This will unconditionally prevent inlining this function (even
2576+
// from other entry points), which is not a reasonable heuristic: even if
2577+
// we reached max block count on this particular execution path, there
2578+
// may be other execution paths (especially with other parametrizations)
2579+
// where the analyzer can reach the end of the function (so there is no
2580+
// natural reason to avoid inlining it). However, disabling this would
2581+
// significantly increase the analysis time (because more entry points
2582+
// would exhaust their allocated budget), so it must be compensated by a
2583+
// different (more reasonable) reduction of analysis scope.
2584+
Engine.FunctionSummaries->markShouldNotInline(
2585+
LC->getStackFrame()->getDecl());
25682586

25692587
// Re-run the call evaluation without inlining it, by storing the
25702588
// no-inlining policy in the state and enqueuing the new work item on
25712589
// the list. Replay should almost never fail. Use the stats to catch it
25722590
// if it does.
2573-
if ((!AMgr.options.NoRetryExhausted &&
2574-
replayWithoutInlining(Pred, CalleeLC)))
2591+
if ((!AMgr.options.NoRetryExhausted && replayWithoutInlining(Pred, LC)))
25752592
return;
25762593
NumMaxBlockCountReachedInInlined++;
25772594
} else
@@ -2835,8 +2852,29 @@ void ExprEngine::processBranch(
28352852
// conflicts with the widen-loop analysis option (which is off by
28362853
// default). If we intend to support and stabilize the loop widening,
28372854
// we must ensure that it 'plays nicely' with this logic.
2838-
if (!SkipTrueBranch || AMgr.options.ShouldWidenLoops)
2855+
if (!SkipTrueBranch || AMgr.options.ShouldWidenLoops) {
28392856
Builder.generateNode(StTrue, true, PredN);
2857+
} else if (!AMgr.options.InlineFunctionsWithAmbiguousLoops) {
2858+
// FIXME: There is an ancient and arbitrary heuristic in
2859+
// `ExprEngine::processCFGBlockEntrance` which prevents all further
2860+
// inlining of a function if it finds an execution path within that
2861+
// function which reaches the `MaxBlockVisitOnPath` limit (a/k/a
2862+
// `analyzer-max-loop`, by default four iterations in a loop). Adding
2863+
// this "don't assume third iteration" logic significantly increased
2864+
// the analysis runtime on some inputs because less functions were
2865+
// arbitrarily excluded from being inlined, so more entry points used
2866+
// up their full allocated budget. As a hacky compensation for this,
2867+
// here we apply the "should not inline" mark in cases when the loop
2868+
// could potentially reach the `MaxBlockVisitOnPath` limit without the
2869+
// "don't assume third iteration" logic. This slightly overcompensates
2870+
// (activates if the third iteration can be entered, and will not
2871+
// recognize cases where the fourth iteration would't be completed), but
2872+
// should be good enough for practical purposes.
2873+
if (const LocationContext *LC = getInlinedLocationContext(Pred, G)) {
2874+
Engine.FunctionSummaries->markShouldNotInline(
2875+
LC->getStackFrame()->getDecl());
2876+
}
2877+
}
28402878
}
28412879

28422880
if (StFalse)

0 commit comments

Comments
 (0)