Skip to content

Commit 2546913

Browse files
committed
merge main into amd-staging
Change-Id: I7c5596bedab658f3083b2c95195bbb6841f24f5a
2 parents f9182bf + 8c5c4d9 commit 2546913

File tree

197 files changed

+7539
-2243
lines changed

Some content is hidden

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

197 files changed

+7539
-2243
lines changed

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
317317
ThreadPoolStrategy S = optimal_concurrency(
318318
std::max(Filenames.size() / 4, static_cast<size_t>(1)));
319319
ThreadPool Pool(S);
320-
DenseMap<llvm::thread::id, ProfileTy> ParsedProfiles(Pool.getThreadCount());
320+
DenseMap<llvm::thread::id, ProfileTy> ParsedProfiles(
321+
Pool.getMaxConcurrency());
321322
for (const auto &Filename : Filenames)
322323
Pool.async(ParseProfile, std::cref(Filename), std::ref(ParsedProfiles));
323324
Pool.wait();

clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
468468
// Extracting Exprs like a = 1 gives placeholder = a = 1 which isn't useful.
469469
// FIXME: we could still hoist the assignment, and leave the variable there?
470470
ParsedBinaryOperator BinOp;
471-
if (BinOp.parse(*N) && BinaryOperator::isAssignmentOp(BinOp.Kind))
471+
bool IsBinOp = BinOp.parse(*N);
472+
if (IsBinOp && BinaryOperator::isAssignmentOp(BinOp.Kind))
472473
return false;
473474

474475
const SelectionTree::Node &OuterImplicit = N->outerImplicit();
@@ -483,13 +484,48 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
483484
OuterImplicit.ASTNode.get<Expr>()))
484485
return false;
485486

487+
std::function<bool(const SelectionTree::Node *)> IsFullySelected =
488+
[&](const SelectionTree::Node *N) {
489+
if (N->ASTNode.getSourceRange().isValid() &&
490+
N->Selected != SelectionTree::Complete)
491+
return false;
492+
for (const auto *Child : N->Children) {
493+
if (!IsFullySelected(Child))
494+
return false;
495+
}
496+
return true;
497+
};
498+
auto ExprIsFullySelectedTargetNode = [&](const Expr *E) {
499+
if (E != OuterImplicit.ASTNode.get<Expr>())
500+
return false;
501+
502+
// The above condition is the only relevant one except for binary operators.
503+
// Without the following code, we would fail to offer extraction for e.g.:
504+
// int x = 1 + 2 + [[3 + 4 + 5]];
505+
// See the documentation of ParsedBinaryOperator for further details.
506+
if (!IsBinOp)
507+
return true;
508+
return IsFullySelected(N);
509+
};
510+
486511
// Disable extraction of full RHS on assignment operations, e.g:
487-
// auto x = [[RHS_EXPR]];
512+
// x = [[RHS_EXPR]];
488513
// This would just result in duplicating the code.
489514
if (const auto *BO = Parent->ASTNode.get<BinaryOperator>()) {
490-
if (BO->isAssignmentOp() &&
491-
BO->getRHS() == OuterImplicit.ASTNode.get<Expr>())
515+
if (BO->isAssignmentOp() && ExprIsFullySelectedTargetNode(BO->getRHS()))
516+
return false;
517+
}
518+
519+
// The same logic as for assignments applies to initializations.
520+
// However, we do allow extracting the RHS of an init capture, as it is
521+
// a valid use case to move non-trivial expressions out of the capture clause.
522+
// FIXME: In that case, the extracted variable should be captured directly,
523+
// rather than an explicit copy.
524+
if (const auto *Decl = Parent->ASTNode.get<VarDecl>()) {
525+
if (!Decl->isInitCapture() &&
526+
ExprIsFullySelectedTargetNode(Decl->getInit())) {
492527
return false;
528+
}
493529
}
494530

495531
return true;

clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ TEST_F(ExtractVariableTest, Test) {
2727
return [[[[t.b[[a]]r]]([[t.z]])]];
2828
}
2929
void f() {
30-
int a = [[5 +]] [[4 * [[[[xyz]]()]]]];
30+
int a = 5 + [[4 * [[[[xyz]]()]]]];
3131
// multivariable initialization
3232
if(1)
33-
int x = [[1]], y = [[a + 1]], a = [[1]], z = a + 1;
33+
int x = [[1]] + 1, y = a + [[1]], a = [[1]] + 2, z = a + 1;
3434
// if without else
3535
if([[1]])
3636
a = [[1]] + 1;
@@ -61,7 +61,7 @@ TEST_F(ExtractVariableTest, Test) {
6161
ExtraArgs = {"-xc"};
6262
const char *AvailableC = R"cpp(
6363
void foo() {
64-
int x = [[1]];
64+
int x = [[1]] + 1;
6565
})cpp";
6666
EXPECT_AVAILABLE(AvailableC);
6767

@@ -79,7 +79,7 @@ TEST_F(ExtractVariableTest, Test) {
7979
@end
8080
@implementation Foo
8181
- (void)method {
82-
int x = [[1 + 2]];
82+
int x = [[1]] + 2;
8383
}
8484
@end)cpp";
8585
EXPECT_AVAILABLE(AvailableObjC);
@@ -103,6 +103,9 @@ TEST_F(ExtractVariableTest, Test) {
103103
}
104104
int z = [[1]];
105105
} t;
106+
int x = [[1 + 2]];
107+
int y;
108+
y = [[1 + 2]];
106109
return [[t]].bar([[t]].z);
107110
}
108111
void v() { return; }
@@ -430,8 +433,8 @@ TEST_F(ExtractVariableTest, Test) {
430433
int member = 42;
431434
};
432435
)cpp"},
433-
{R"cpp(void f() { auto x = [[ [](){ return 42; }]]; })cpp",
434-
R"cpp(void f() { auto placeholder = [](){ return 42; }; auto x = placeholder; })cpp"},
436+
{R"cpp(void f() { auto x = +[[ [](){ return 42; }]]; })cpp",
437+
R"cpp(void f() { auto placeholder = [](){ return 42; }; auto x = + placeholder; })cpp"},
435438
{R"cpp(
436439
template <typename T>
437440
auto sink(T f) { return f(); }
@@ -515,13 +518,13 @@ TEST_F(ExtractVariableTest, Test) {
515518
{R"cpp(
516519
template <typename ...Ts>
517520
void foo(Ts ...args) {
518-
auto x = [[ [&args...]() {} ]];
521+
auto x = +[[ [&args...]() {} ]];
519522
}
520523
)cpp",
521524
R"cpp(
522525
template <typename ...Ts>
523526
void foo(Ts ...args) {
524-
auto placeholder = [&args...]() {}; auto x = placeholder ;
527+
auto placeholder = [&args...]() {}; auto x = + placeholder ;
525528
}
526529
)cpp"},
527530
{R"cpp(
@@ -533,7 +536,7 @@ TEST_F(ExtractVariableTest, Test) {
533536
int main() {
534537
Coordinates c = {};
535538
const auto [x, y] = c;
536-
auto f = [[ [&]() { return x + y; } ]];
539+
auto f = [[ [&]() { return x + y; } ]]();
537540
}
538541
)cpp",
539542
R"cpp(
@@ -545,7 +548,7 @@ TEST_F(ExtractVariableTest, Test) {
545548
int main() {
546549
Coordinates c = {};
547550
const auto [x, y] = c;
548-
auto placeholder = [&]() { return x + y; }; auto f = placeholder ;
551+
auto placeholder = [&]() { return x + y; }; auto f = placeholder ();
549552
}
550553
)cpp"},
551554
{R"cpp(
@@ -557,7 +560,7 @@ TEST_F(ExtractVariableTest, Test) {
557560
int main() {
558561
Coordinates c = {};
559562
if (const auto [x, y] = c; x > y) {
560-
auto f = [[ [&]() { return x + y; } ]];
563+
auto f = [[ [&]() { return x + y; } ]]();
561564
}
562565
}
563566
)cpp",
@@ -570,7 +573,7 @@ TEST_F(ExtractVariableTest, Test) {
570573
int main() {
571574
Coordinates c = {};
572575
if (const auto [x, y] = c; x > y) {
573-
auto placeholder = [&]() { return x + y; }; auto f = placeholder ;
576+
auto placeholder = [&]() { return x + y; }; auto f = placeholder ();
574577
}
575578
}
576579
)cpp"},

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ X86 Support
297297
Arm and AArch64 Support
298298
^^^^^^^^^^^^^^^^^^^^^^^
299299

300-
- Fixed the incorrect definition of the __ARM_ARCH macro for architectures greater than or equal to v8.1.
301-
302300
Android Support
303301
^^^^^^^^^^^^^^^
304302

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,12 @@ bool ByteCodeExprGen<Emitter>::VisitConceptSpecializationExpr(
21562156
return this->emitConstBool(E->isSatisfied(), E);
21572157
}
21582158

2159+
template <class Emitter>
2160+
bool ByteCodeExprGen<Emitter>::VisitCXXRewrittenBinaryOperator(
2161+
const CXXRewrittenBinaryOperator *E) {
2162+
return this->delegate(E->getSemanticForm());
2163+
}
2164+
21592165
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
21602166
if (E->containsErrors())
21612167
return false;

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
116116
bool VisitCXXUuidofExpr(const CXXUuidofExpr *E);
117117
bool VisitRequiresExpr(const RequiresExpr *E);
118118
bool VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
119+
bool VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *E);
119120

120121
protected:
121122
bool visitExpr(const Expr *E) override;

clang/lib/AST/Interp/Interp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,11 @@ inline bool SubPtr(InterpState &S, CodePtr OpPC) {
15791579
return false;
15801580
}
15811581

1582+
if (LHS.isZero() && RHS.isZero()) {
1583+
S.Stk.push<T>();
1584+
return true;
1585+
}
1586+
15821587
T A = T::from(LHS.getIndex());
15831588
T B = T::from(RHS.getIndex());
15841589
return AddSubMulHelper<T, T::sub, std::minus>(S, OpPC, A.bitWidth(), A, B);

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,8 +2200,7 @@ FixVarInitializerWithSpan(const Expr *Init, ASTContext &Ctx,
22002200
// Although the initializer is not allocating a buffer, the pointer
22012201
// variable could still be used in buffer access operations.
22022202
ExtentText = One;
2203-
} else if (const auto *CArrTy = Ctx.getAsConstantArrayType(
2204-
Init->IgnoreImpCasts()->getType())) {
2203+
} else if (Ctx.getAsConstantArrayType(Init->IgnoreImpCasts()->getType())) {
22052204
// std::span has a single parameter constructor for initialization with
22062205
// constant size array. The size is auto-deduced as the constructor is a
22072206
// function template. The correct fixit is empty - no changes should happen.

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -366,20 +366,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
366366

367367
// ACLE predefines. Many can only have one possible value on v8 AArch64.
368368
Builder.defineMacro("__ARM_ACLE", "200");
369-
370-
// __ARM_ARCH is defined as an integer value indicating the current ARM ISA.
371-
// For ISAs up to and including v8, __ARM_ARCH is equal to the major version
372-
// number. For ISAs from v8.1 onwards, __ARM_ARCH is scaled up to include the
373-
// minor version number, e.g. for ARM architecture ARMvX.Y:
374-
// __ARM_ARCH = X * 100 + Y.
375-
if (ArchInfo->Version.getMajor() == 8 && ArchInfo->Version.getMinor() == 0)
376-
Builder.defineMacro("__ARM_ARCH",
377-
std::to_string(ArchInfo->Version.getMajor()));
378-
else
379-
Builder.defineMacro("__ARM_ARCH",
380-
std::to_string(ArchInfo->Version.getMajor() * 100 +
381-
ArchInfo->Version.getMinor().value()));
382-
369+
Builder.defineMacro("__ARM_ARCH",
370+
std::to_string(ArchInfo->Version.getMajor()));
383371
Builder.defineMacro("__ARM_ARCH_PROFILE",
384372
std::string("'") + (char)ArchInfo->Profile + "'");
385373

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ void ARMTargetInfo::setArchInfo(llvm::ARM::ArchKind Kind) {
130130
SubArch = llvm::ARM::getSubArch(ArchKind);
131131
ArchProfile = llvm::ARM::parseArchProfile(SubArch);
132132
ArchVersion = llvm::ARM::parseArchVersion(SubArch);
133-
ArchMinorVersion = llvm::ARM::parseArchMinorVersion(SubArch);
134133

135134
// cache CPU related strings
136135
CPUAttr = getCPUAttr();
@@ -735,16 +734,9 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
735734
if (!CPUAttr.empty())
736735
Builder.defineMacro("__ARM_ARCH_" + CPUAttr + "__");
737736

738-
// __ARM_ARCH is defined as an integer value indicating the current ARM ISA.
739-
// For ISAs up to and including v8, __ARM_ARCH is equal to the major version
740-
// number. For ISAs from v8.1 onwards, __ARM_ARCH is scaled up to include the
741-
// minor version number, e.g. for ARM architecture ARMvX.Y:
742-
// __ARM_ARCH = X * 100 + Y.
743-
if (ArchVersion >= 9 || ArchMinorVersion != 0)
744-
Builder.defineMacro("__ARM_ARCH",
745-
Twine(ArchVersion * 100 + ArchMinorVersion));
746-
else
747-
Builder.defineMacro("__ARM_ARCH", Twine(ArchVersion));
737+
// ACLE 6.4.1 ARM/Thumb instruction set architecture
738+
// __ARM_ARCH is defined as an integer value indicating the current ARM ISA
739+
Builder.defineMacro("__ARM_ARCH", Twine(ArchVersion));
748740

749741
if (ArchVersion >= 8) {
750742
// ACLE 6.5.7 Crypto Extension

0 commit comments

Comments
 (0)