Skip to content

Commit f9182bf

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I5a27c62a1c06b2dd867b52e19aca27c249173aa0
2 parents a163e83 + 5b342e6 commit f9182bf

File tree

127 files changed

+2906
-282
lines changed

Some content is hidden

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

127 files changed

+2906
-282
lines changed

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ void LinuxKernelRewriter::updateLKMarkers() {
484484
LKPatcher->addLE64Patch(LKMarkerInfo.SectionOffset, NewAddress);
485485
}
486486
}
487-
outs() << "BOLT-INFO: patching linux kernel sections. Total patches per "
488-
"section are as follows:\n";
487+
BC.outs() << "BOLT-INFO: patching linux kernel sections. Total patches per "
488+
"section are as follows:\n";
489489
for (const std::pair<const std::string, uint64_t> &KV : PatchCounts)
490-
outs() << " Section: " << KV.first << ", patch-counts: " << KV.second
491-
<< '\n';
490+
BC.outs() << " Section: " << KV.first << ", patch-counts: " << KV.second
491+
<< '\n';
492492
}
493493

494494
Error LinuxKernelRewriter::readORCTables() {
@@ -530,8 +530,8 @@ Error LinuxKernelRewriter::readORCTables() {
530530
"out of bounds while reading ORC IP table");
531531

532532
if (IP < PrevIP && opts::Verbosity)
533-
errs() << "BOLT-WARNING: out of order IP 0x" << Twine::utohexstr(IP)
534-
<< " detected while reading ORC\n";
533+
BC.errs() << "BOLT-WARNING: out of order IP 0x" << Twine::utohexstr(IP)
534+
<< " detected while reading ORC\n";
535535

536536
PrevIP = IP;
537537

@@ -564,8 +564,8 @@ Error LinuxKernelRewriter::readORCTables() {
564564

565565
if (!BF) {
566566
if (opts::Verbosity)
567-
errs() << "BOLT-WARNING: no binary function found matching ORC 0x"
568-
<< Twine::utohexstr(IP) << ": " << Entry.ORC << '\n';
567+
BC.errs() << "BOLT-WARNING: no binary function found matching ORC 0x"
568+
<< Twine::utohexstr(IP) << ": " << Entry.ORC << '\n';
569569
continue;
570570
}
571571

@@ -591,15 +591,15 @@ Error LinuxKernelRewriter::readORCTables() {
591591
BC.MIB->addAnnotation(*Inst, "ORC", Entry.ORC);
592592
}
593593

594-
outs() << "BOLT-INFO: parsed " << NumORCEntries << " ORC entries\n";
594+
BC.outs() << "BOLT-INFO: parsed " << NumORCEntries << " ORC entries\n";
595595

596596
if (opts::DumpORC) {
597-
outs() << "BOLT-INFO: ORC unwind information:\n";
597+
BC.outs() << "BOLT-INFO: ORC unwind information:\n";
598598
for (const ORCListEntry &E : ORCEntries) {
599-
outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
599+
BC.outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
600600
if (E.BF)
601-
outs() << ": " << *E.BF;
602-
outs() << '\n';
601+
BC.outs() << ": " << *E.BF;
602+
BC.outs() << '\n';
603603
}
604604
}
605605

@@ -632,12 +632,12 @@ Error LinuxKernelRewriter::readORCTables() {
632632
llvm::sort(ORCEntries);
633633

634634
if (opts::DumpORC) {
635-
outs() << "BOLT-INFO: amended ORC unwind information:\n";
635+
BC.outs() << "BOLT-INFO: amended ORC unwind information:\n";
636636
for (const ORCListEntry &E : ORCEntries) {
637-
outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
637+
BC.outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
638638
if (E.BF)
639-
outs() << ": " << *E.BF;
640-
outs() << '\n';
639+
BC.outs() << ": " << *E.BF;
640+
BC.outs() << '\n';
641641
}
642642
}
643643

@@ -684,8 +684,8 @@ Error LinuxKernelRewriter::processORCPostCFG() {
684684
"ORC info at function entry expected.");
685685

686686
if (It->ORC == NullORC && BF.hasORC()) {
687-
errs() << "BOLT-WARNING: ORC unwind info excludes prologue for "
688-
<< BF << '\n';
687+
BC.errs() << "BOLT-WARNING: ORC unwind info excludes prologue for "
688+
<< BF << '\n';
689689
}
690690

691691
It->BF = &BF;
@@ -878,9 +878,10 @@ Error LinuxKernelRewriter::readStaticCalls() {
878878
++EntryID;
879879

880880
if (opts::DumpStaticCalls) {
881-
outs() << "Static Call Site: " << EntryID << '\n';
882-
outs() << "\tCallAddress: 0x" << Twine::utohexstr(CallAddress) << '\n'
883-
<< "\tKeyAddress: 0x" << Twine::utohexstr(KeyAddress) << '\n';
881+
BC.outs() << "Static Call Site: " << EntryID << '\n';
882+
BC.outs() << "\tCallAddress: 0x" << Twine::utohexstr(CallAddress)
883+
<< "\n\tKeyAddress: 0x" << Twine::utohexstr(KeyAddress)
884+
<< '\n';
884885
}
885886

886887
BinaryFunction *BF = BC.getBinaryFunctionContainingAddress(CallAddress);
@@ -916,8 +917,8 @@ Error LinuxKernelRewriter::readStaticCalls() {
916917
StaticCallEntries.push_back({EntryID, BF, Label});
917918
}
918919

919-
outs() << "BOLT-INFO: parsed " << StaticCallEntries.size()
920-
<< " static call entries\n";
920+
BC.outs() << "BOLT-INFO: parsed " << StaticCallEntries.size()
921+
<< " static call entries\n";
921922

922923
return Error::success();
923924
}

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,13 +1408,16 @@ const IdentifierNamingCheck::FileStyle &
14081408
IdentifierNamingCheck::getStyleForFile(StringRef FileName) const {
14091409
if (!GetConfigPerFile)
14101410
return *MainFileStyle;
1411-
StringRef Parent = llvm::sys::path::parent_path(FileName);
1411+
1412+
SmallString<128> RealFileName;
1413+
llvm::sys::fs::real_path(FileName, RealFileName);
1414+
StringRef Parent = llvm::sys::path::parent_path(RealFileName);
14121415
auto Iter = NamingStylesCache.find(Parent);
14131416
if (Iter != NamingStylesCache.end())
14141417
return Iter->getValue();
14151418

14161419
llvm::StringRef CheckName = getID();
1417-
ClangTidyOptions Options = Context->getOptionsForFile(FileName);
1420+
ClangTidyOptions Options = Context->getOptionsForFile(RealFileName);
14181421
if (Options.Checks && GlobList(*Options.Checks).contains(CheckName)) {
14191422
auto It = NamingStylesCache.try_emplace(
14201423
Parent,

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ Changes in existing checks
188188
<clang-tidy/checks/readability/redundant-inline-specifier>` check to properly
189189
emit warnings for static data member with an in-class initializer.
190190

191+
- Improved :doc:`readability-identifier-naming
192+
<clang-tidy/checks/readability/identifier-naming>` check in `GetConfigPerFile`
193+
mode by resolving symbolic links to header files.
194+
191195
Removed checks
192196
^^^^^^^^^^^^^^
193197

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Checks: readability-identifier-naming
2+
CheckOptions:
3+
readability-identifier-naming.GlobalConstantCase: CamelCase
4+
readability-identifier-naming.GlobalConstantPrefix: k
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const int global_const = 5;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Specify `-std=c++20` to run test only once becuase test expects changes
2+
// in the header file so it fails if runs multiple times with different
3+
// `-std` flags as check_clang_tidy doesn by default.
4+
//
5+
// RUN: rm -rf %T/symlink
6+
// RUN: cp -r %S/Inputs/identifier-naming/symlink %T/symlink
7+
// RUN: mkdir -p %T/symlink/build
8+
// RUN: ln -s %T/symlink/include/test.h %T/symlink/build/test.h
9+
// RUN: %check_clang_tidy -std=c++20 %s readability-identifier-naming %t -- --header-filter="test.h" --config-file=%S/Inputs/identifier-naming/symlink/include/.clang-tidy -- -I %T/symlink/build
10+
// UNSUPPORTED: system-windows
11+
12+
#include "test.h"
13+
14+
int foo() {
15+
return global_const;
16+
// CHECK-MESSAGES: warning: invalid case style for global constant 'global_const' [readability-identifier-naming]
17+
// CHECK-FIXES: return kGlobalConst;
18+
}

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ Bug Fixes to C++ Support
270270
- No longer reject valid use of the ``_Alignas`` specifier when declaring a
271271
local variable, which is supported as a C11 extension in C++. Previously, it
272272
was only accepted at namespace scope but not at local function scope.
273+
- Clang no longer tries to call consteval constructors at runtime when they appear in a member initializer.
274+
(`#782154 <https://github.com/llvm/llvm-project/issues/82154>`_`)
273275

274276
Bug Fixes to AST Handling
275277
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 81 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,13 @@ bool ByteCodeExprGen<Emitter>::VisitMemberExpr(const MemberExpr *E) {
11571157
if (DiscardResult)
11581158
return this->discard(Base);
11591159

1160-
if (!this->delegate(Base))
1161-
return false;
1160+
if (Initializing) {
1161+
if (!this->delegate(Base))
1162+
return false;
1163+
} else {
1164+
if (!this->visit(Base))
1165+
return false;
1166+
}
11621167

11631168
// Base above gives us a pointer on the stack.
11641169
// TODO: Implement non-FieldDecl members.
@@ -1716,6 +1721,9 @@ bool ByteCodeExprGen<Emitter>::VisitTypeTraitExpr(const TypeTraitExpr *E) {
17161721

17171722
template <class Emitter>
17181723
bool ByteCodeExprGen<Emitter>::VisitLambdaExpr(const LambdaExpr *E) {
1724+
if (DiscardResult)
1725+
return true;
1726+
17191727
assert(Initializing);
17201728
const Record *R = P.getOrCreateRecord(E->getLambdaClass());
17211729

@@ -1848,6 +1856,8 @@ bool ByteCodeExprGen<Emitter>::VisitCXXConstructExpr(
18481856

18491857
// Immediately call the destructor if we have to.
18501858
if (DiscardResult) {
1859+
if (!this->emitRecordDestruction(getRecord(E->getType())))
1860+
return false;
18511861
if (!this->emitPopPtr(E))
18521862
return false;
18531863
}
@@ -2463,17 +2473,6 @@ bool ByteCodeExprGen<Emitter>::dereferenceVar(
24632473
}
24642474
}
24652475

2466-
// If the declaration is a constant value, emit it here even
2467-
// though the declaration was not evaluated in the current scope.
2468-
// The access mode can only be read in this case.
2469-
if (!DiscardResult && AK == DerefKind::Read) {
2470-
if (VD->hasLocalStorage() && VD->hasInit() && !VD->isConstexpr()) {
2471-
QualType VT = VD->getType();
2472-
if (VT.isConstQualified() && VT->isFundamentalType())
2473-
return this->visit(VD->getInit());
2474-
}
2475-
}
2476-
24772476
// Value cannot be produced - try to emit pointer.
24782477
return visit(LV) && Indirect(T);
24792478
}
@@ -2744,10 +2743,9 @@ bool ByteCodeExprGen<Emitter>::visitVarDecl(const VarDecl *VD) {
27442743
return this->emitSetLocal(*VarT, Offset, VD);
27452744
}
27462745
} else {
2747-
if (std::optional<unsigned> Offset = this->allocateLocal(VD)) {
2748-
if (Init)
2749-
return this->visitLocalInitializer(Init, *Offset);
2750-
}
2746+
if (std::optional<unsigned> Offset = this->allocateLocal(VD))
2747+
return !Init || this->visitLocalInitializer(Init, *Offset);
2748+
return false;
27512749
}
27522750
return true;
27532751
}
@@ -2822,14 +2820,28 @@ bool ByteCodeExprGen<Emitter>::VisitCallExpr(const CallExpr *E) {
28222820
}
28232821
}
28242822

2823+
auto Args = E->arguments();
2824+
// Calling a static operator will still
2825+
// pass the instance, but we don't need it.
2826+
// Discard it here.
2827+
if (isa<CXXOperatorCallExpr>(E)) {
2828+
if (const auto *MD =
2829+
dyn_cast_if_present<CXXMethodDecl>(E->getDirectCallee());
2830+
MD && MD->isStatic()) {
2831+
if (!this->discard(E->getArg(0)))
2832+
return false;
2833+
Args = drop_begin(Args, 1);
2834+
}
2835+
}
2836+
28252837
// Add the (optional, implicit) This pointer.
28262838
if (const auto *MC = dyn_cast<CXXMemberCallExpr>(E)) {
28272839
if (!this->visit(MC->getImplicitObjectArgument()))
28282840
return false;
28292841
}
28302842

28312843
// Put arguments on the stack.
2832-
for (const auto *Arg : E->arguments()) {
2844+
for (const auto *Arg : Args) {
28332845
if (!this->visit(Arg))
28342846
return false;
28352847
}
@@ -3365,45 +3377,8 @@ bool ByteCodeExprGen<Emitter>::emitComplexReal(const Expr *SubExpr) {
33653377
return true;
33663378
}
33673379

3368-
/// When calling this, we have a pointer of the local-to-destroy
3369-
/// on the stack.
3370-
/// Emit destruction of record types (or arrays of record types).
33713380
template <class Emitter>
3372-
bool ByteCodeExprGen<Emitter>::emitRecordDestruction(const Descriptor *Desc) {
3373-
assert(Desc);
3374-
assert(!Desc->isPrimitive());
3375-
assert(!Desc->isPrimitiveArray());
3376-
3377-
// Arrays.
3378-
if (Desc->isArray()) {
3379-
const Descriptor *ElemDesc = Desc->ElemDesc;
3380-
assert(ElemDesc);
3381-
3382-
// Don't need to do anything for these.
3383-
if (ElemDesc->isPrimitiveArray())
3384-
return this->emitPopPtr(SourceInfo{});
3385-
3386-
// If this is an array of record types, check if we need
3387-
// to call the element destructors at all. If not, try
3388-
// to save the work.
3389-
if (const Record *ElemRecord = ElemDesc->ElemRecord) {
3390-
if (const CXXDestructorDecl *Dtor = ElemRecord->getDestructor();
3391-
!Dtor || Dtor->isTrivial())
3392-
return this->emitPopPtr(SourceInfo{});
3393-
}
3394-
3395-
for (ssize_t I = Desc->getNumElems() - 1; I >= 0; --I) {
3396-
if (!this->emitConstUint64(I, SourceInfo{}))
3397-
return false;
3398-
if (!this->emitArrayElemPtrUint64(SourceInfo{}))
3399-
return false;
3400-
if (!this->emitRecordDestruction(ElemDesc))
3401-
return false;
3402-
}
3403-
return this->emitPopPtr(SourceInfo{});
3404-
}
3405-
3406-
const Record *R = Desc->ElemRecord;
3381+
bool ByteCodeExprGen<Emitter>::emitRecordDestruction(const Record *R) {
34073382
assert(R);
34083383
// First, destroy all fields.
34093384
for (const Record::Field &Field : llvm::reverse(R->fields())) {
@@ -3413,7 +3388,9 @@ bool ByteCodeExprGen<Emitter>::emitRecordDestruction(const Descriptor *Desc) {
34133388
return false;
34143389
if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
34153390
return false;
3416-
if (!this->emitRecordDestruction(D))
3391+
if (!this->emitDestruction(D))
3392+
return false;
3393+
if (!this->emitPopPtr(SourceInfo{}))
34173394
return false;
34183395
}
34193396
}
@@ -3437,13 +3414,57 @@ bool ByteCodeExprGen<Emitter>::emitRecordDestruction(const Descriptor *Desc) {
34373414
for (const Record::Base &Base : llvm::reverse(R->bases())) {
34383415
if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
34393416
return false;
3440-
if (!this->emitRecordDestruction(Base.Desc))
3417+
if (!this->emitRecordDestruction(Base.R))
3418+
return false;
3419+
if (!this->emitPopPtr(SourceInfo{}))
34413420
return false;
34423421
}
3422+
34433423
// FIXME: Virtual bases.
3424+
return true;
3425+
}
3426+
/// When calling this, we have a pointer of the local-to-destroy
3427+
/// on the stack.
3428+
/// Emit destruction of record types (or arrays of record types).
3429+
template <class Emitter>
3430+
bool ByteCodeExprGen<Emitter>::emitDestruction(const Descriptor *Desc) {
3431+
assert(Desc);
3432+
assert(!Desc->isPrimitive());
3433+
assert(!Desc->isPrimitiveArray());
3434+
3435+
// Arrays.
3436+
if (Desc->isArray()) {
3437+
const Descriptor *ElemDesc = Desc->ElemDesc;
3438+
assert(ElemDesc);
3439+
3440+
// Don't need to do anything for these.
3441+
if (ElemDesc->isPrimitiveArray())
3442+
return true;
3443+
3444+
// If this is an array of record types, check if we need
3445+
// to call the element destructors at all. If not, try
3446+
// to save the work.
3447+
if (const Record *ElemRecord = ElemDesc->ElemRecord) {
3448+
if (const CXXDestructorDecl *Dtor = ElemRecord->getDestructor();
3449+
!Dtor || Dtor->isTrivial())
3450+
return true;
3451+
}
3452+
3453+
for (ssize_t I = Desc->getNumElems() - 1; I >= 0; --I) {
3454+
if (!this->emitConstUint64(I, SourceInfo{}))
3455+
return false;
3456+
if (!this->emitArrayElemPtrUint64(SourceInfo{}))
3457+
return false;
3458+
if (!this->emitDestruction(ElemDesc))
3459+
return false;
3460+
if (!this->emitPopPtr(SourceInfo{}))
3461+
return false;
3462+
}
3463+
return true;
3464+
}
34443465

3445-
// Remove the instance pointer.
3446-
return this->emitPopPtr(SourceInfo{});
3466+
assert(Desc->ElemRecord);
3467+
return this->emitRecordDestruction(Desc->ElemRecord);
34473468
}
34483469

34493470
namespace clang {

0 commit comments

Comments
 (0)