Skip to content

Commit f2320d5

Browse files
committed
Merge commit '30298f91367f0c320e136cbe158f1d9dbf0c3a57' into llvmspirv_pulldown
2 parents dfa4baa + 30298f9 commit f2320d5

File tree

353 files changed

+9598
-8283
lines changed

Some content is hidden

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

353 files changed

+9598
-8283
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "bolt/Core/MCPlusBuilder.h"
2323
#include "llvm/BinaryFormat/ELF.h"
2424
#include "llvm/MC/MCContext.h"
25-
#include "llvm/MC/MCFixupKindInfo.h"
2625
#include "llvm/MC/MCInstBuilder.h"
2726
#include "llvm/MC/MCInstrInfo.h"
2827
#include "llvm/MC/MCRegister.h"
@@ -2557,7 +2556,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
25572556
else if (Fixup.getKind() ==
25582557
MCFixupKind(AArch64::fixup_aarch64_pcrel_branch26))
25592558
RelType = ELF::R_AARCH64_JUMP26;
2560-
else if (FKI.Flags & MCFixupKindInfo::FKF_IsPCRel) {
2559+
else if (Fixup.isPCRel()) {
25612560
switch (FKI.TargetSize) {
25622561
default:
25632562
return std::nullopt;

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "bolt/Core/MCPlusBuilder.h"
1919
#include "llvm/BinaryFormat/ELF.h"
2020
#include "llvm/MC/MCContext.h"
21-
#include "llvm/MC/MCFixupKindInfo.h"
2221
#include "llvm/MC/MCInst.h"
2322
#include "llvm/MC/MCInstBuilder.h"
2423
#include "llvm/MC/MCInstrInfo.h"
@@ -2444,7 +2443,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24442443
const uint64_t RelOffset = Fixup.getOffset();
24452444

24462445
uint32_t RelType;
2447-
if (FKI.Flags & MCFixupKindInfo::FKF_IsPCRel) {
2446+
if (Fixup.isPCRel()) {
24482447
switch (FKI.TargetSize) {
24492448
default:
24502449
return std::nullopt;

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "llvm/ADT/StringExtras.h"
3434
#include "llvm/ADT/StringRef.h"
3535
#include "llvm/ADT/Twine.h"
36-
#include "llvm/ADT/identity.h"
3736
#include "llvm/Support/Casting.h"
3837
#include "llvm/Support/ErrorHandling.h"
3938
#include "llvm/Support/FormatVariadic.h"
@@ -339,53 +338,6 @@ QualType maybeDesugar(ASTContext &AST, QualType QT) {
339338
return QT;
340339
}
341340

342-
// Given a callee expression `Fn`, if the call is through a function pointer,
343-
// try to find the declaration of the corresponding function pointer type,
344-
// so that we can recover argument names from it.
345-
// FIXME: This function is mostly duplicated in SemaCodeComplete.cpp; unify.
346-
static FunctionProtoTypeLoc getPrototypeLoc(Expr *Fn) {
347-
TypeLoc Target;
348-
Expr *NakedFn = Fn->IgnoreParenCasts();
349-
if (const auto *T = NakedFn->getType().getTypePtr()->getAs<TypedefType>()) {
350-
Target = T->getDecl()->getTypeSourceInfo()->getTypeLoc();
351-
} else if (const auto *DR = dyn_cast<DeclRefExpr>(NakedFn)) {
352-
const auto *D = DR->getDecl();
353-
if (const auto *const VD = dyn_cast<VarDecl>(D)) {
354-
Target = VD->getTypeSourceInfo()->getTypeLoc();
355-
}
356-
}
357-
358-
if (!Target)
359-
return {};
360-
361-
// Unwrap types that may be wrapping the function type
362-
while (true) {
363-
if (auto P = Target.getAs<PointerTypeLoc>()) {
364-
Target = P.getPointeeLoc();
365-
continue;
366-
}
367-
if (auto A = Target.getAs<AttributedTypeLoc>()) {
368-
Target = A.getModifiedLoc();
369-
continue;
370-
}
371-
if (auto P = Target.getAs<ParenTypeLoc>()) {
372-
Target = P.getInnerLoc();
373-
continue;
374-
}
375-
break;
376-
}
377-
378-
if (auto F = Target.getAs<FunctionProtoTypeLoc>()) {
379-
// In some edge cases the AST can contain a "trivial" FunctionProtoTypeLoc
380-
// which has null parameters. Avoid these as they don't contain useful
381-
// information.
382-
if (llvm::all_of(F.getParams(), llvm::identity<ParmVarDecl *>()))
383-
return F;
384-
}
385-
386-
return {};
387-
}
388-
389341
ArrayRef<const ParmVarDecl *>
390342
maybeDropCxxExplicitObjectParameters(ArrayRef<const ParmVarDecl *> Params) {
391343
if (!Params.empty() && Params.front()->isExplicitObjectParameter())
@@ -514,7 +466,8 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
514466
Callee.Decl = FD;
515467
else if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(CalleeDecls[0]))
516468
Callee.Decl = FTD->getTemplatedDecl();
517-
else if (FunctionProtoTypeLoc Loc = getPrototypeLoc(E->getCallee()))
469+
else if (FunctionProtoTypeLoc Loc =
470+
Resolver->getFunctionProtoTypeLoc(E->getCallee()))
518471
Callee.Loc = Loc;
519472
else
520473
return true;

clang/docs/DebuggingCoroutines.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ suspension point.
221221
Line 45 of "llvm-example.cpp" starts at address 0x201b <_ZL9coro_taski.destroy+555> and ends at 0x2046 <_ZL9coro_taski.destroy+598>.
222222
Line 45 of "llvm-example.cpp" starts at address 0x253b <_ZL9coro_taski.cleanup+555> and ends at 0x2566 <_ZL9coro_taski.cleanup+598>.
223223

224-
LLDB does not support looking up labels. Furthmore, those labels are only emitted
224+
LLDB does not support looking up labels. Furthermore, those labels are only emitted
225225
starting with clang 21.0.
226226

227227
For simple cases, you might still be able to guess the suspension point correctly.

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ Bug Fixes to C++ Support
900900
- Fixed an access checking bug when substituting into concepts (#GH115838)
901901
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
902902
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
903+
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
903904

904905
Bug Fixes to AST Handling
905906
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Sema/HeuristicResolver.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CXXBasePath;
2020
class CXXDependentScopeMemberExpr;
2121
class DeclarationName;
2222
class DependentScopeDeclRefExpr;
23+
class FunctionProtoTypeLoc;
2324
class NamedDecl;
2425
class Type;
2526
class UnresolvedUsingValueDecl;
@@ -93,6 +94,12 @@ class HeuristicResolver {
9394
// during simplification, and the operation fails if no pointer type is found.
9495
QualType simplifyType(QualType Type, const Expr *E, bool UnwrapPointer);
9596

97+
// Given an expression `Fn` representing the callee in a function call,
98+
// if the call is through a function pointer, try to find the declaration of
99+
// the corresponding function pointer type, so that we can recover argument
100+
// names from it.
101+
FunctionProtoTypeLoc getFunctionProtoTypeLoc(const Expr *Fn) const;
102+
96103
private:
97104
ASTContext &Ctx;
98105
};

clang/lib/AST/ByteCode/Interp.h

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,30 +1139,12 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
11391139
}
11401140

11411141
if (Pointer::hasSameBase(LHS, RHS)) {
1142-
if (LHS.inUnion() && RHS.inUnion()) {
1143-
// If the pointers point into a union, things are a little more
1144-
// complicated since the offset we save in interp::Pointer can't be used
1145-
// to compare the pointers directly.
1146-
size_t A = LHS.computeOffsetForComparison();
1147-
size_t B = RHS.computeOffsetForComparison();
1148-
S.Stk.push<BoolT>(BoolT::from(Fn(Compare(A, B))));
1149-
return true;
1150-
}
1151-
1152-
unsigned VL = LHS.getByteOffset();
1153-
unsigned VR = RHS.getByteOffset();
1154-
// In our Pointer class, a pointer to an array and a pointer to the first
1155-
// element in the same array are NOT equal. They have the same Base value,
1156-
// but a different Offset. This is a pretty rare case, so we fix this here
1157-
// by comparing pointers to the first elements.
1158-
if (!LHS.isZero() && LHS.isArrayRoot())
1159-
VL = LHS.atIndex(0).getByteOffset();
1160-
if (!RHS.isZero() && RHS.isArrayRoot())
1161-
VR = RHS.atIndex(0).getByteOffset();
1162-
1163-
S.Stk.push<BoolT>(BoolT::from(Fn(Compare(VL, VR))));
1142+
size_t A = LHS.computeOffsetForComparison();
1143+
size_t B = RHS.computeOffsetForComparison();
1144+
S.Stk.push<BoolT>(BoolT::from(Fn(Compare(A, B))));
11641145
return true;
11651146
}
1147+
11661148
// Otherwise we need to do a bunch of extra checks before returning Unordered.
11671149
if (LHS.isOnePastEnd() && !RHS.isOnePastEnd() && !RHS.isZero() &&
11681150
RHS.getOffset() == 0) {

clang/lib/AST/ByteCode/Pointer.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,28 @@ void Pointer::print(llvm::raw_ostream &OS) const {
338338
}
339339
}
340340

341-
/// Compute an integer that can be used to compare this pointer to
342-
/// another one.
343341
size_t Pointer::computeOffsetForComparison() const {
342+
if (isIntegralPointer())
343+
return asIntPointer().Value + Offset;
344+
if (isTypeidPointer())
345+
return reinterpret_cast<uintptr_t>(asTypeidPointer().TypePtr) + Offset;
346+
344347
if (!isBlockPointer())
345348
return Offset;
346349

347350
size_t Result = 0;
348351
Pointer P = *this;
349-
while (!P.isRoot()) {
350-
if (P.isArrayRoot()) {
352+
while (true) {
353+
354+
if (P.isVirtualBaseClass()) {
355+
Result += getInlineDesc()->Offset;
356+
P = P.getBase();
357+
continue;
358+
}
359+
360+
if (P.isBaseClass()) {
361+
if (P.getRecord()->getNumVirtualBases() > 0)
362+
Result += P.getInlineDesc()->Offset;
351363
P = P.getBase();
352364
continue;
353365
}
@@ -358,14 +370,26 @@ size_t Pointer::computeOffsetForComparison() const {
358370
continue;
359371
}
360372

373+
if (P.isRoot()) {
374+
if (P.isOnePastEnd())
375+
++Result;
376+
break;
377+
}
378+
361379
if (const Record *R = P.getBase().getRecord(); R && R->isUnion()) {
362380
// Direct child of a union - all have offset 0.
363381
P = P.getBase();
364382
continue;
365383
}
366384

385+
// Fields, etc.
367386
Result += P.getInlineDesc()->Offset;
387+
if (P.isOnePastEnd())
388+
++Result;
389+
368390
P = P.getBase();
391+
if (P.isRoot())
392+
break;
369393
}
370394

371395
return Result;

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ class Pointer {
761761
/// Prints the pointer.
762762
void print(llvm::raw_ostream &OS) const;
763763

764+
/// Compute an integer that can be used to compare this pointer to
765+
/// another one. This is usually NOT the same as the pointer offset
766+
/// regarding the AST record layout.
764767
size_t computeOffsetForComparison() const;
765768

766769
private:

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -156,39 +156,18 @@ static bool
156156
getAArch64MicroArchFeaturesFromMtune(const Driver &D, StringRef Mtune,
157157
const ArgList &Args,
158158
std::vector<StringRef> &Features) {
159-
std::string MtuneLowerCase = Mtune.lower();
160159
// Check CPU name is valid, but ignore any extensions on it.
160+
std::string MtuneLowerCase = Mtune.lower();
161161
llvm::AArch64::ExtensionSet Extensions;
162162
StringRef Tune;
163-
if (!DecodeAArch64Mcpu(D, MtuneLowerCase, Tune, Extensions))
164-
return false;
165-
166-
// Handle CPU name is 'native'.
167-
if (MtuneLowerCase == "native")
168-
MtuneLowerCase = std::string(llvm::sys::getHostCPUName());
169-
170-
// 'cyclone' and later have zero-cycle register moves and zeroing.
171-
if (MtuneLowerCase == "cyclone" ||
172-
StringRef(MtuneLowerCase).starts_with("apple")) {
173-
Features.push_back("+zcm-gpr64");
174-
Features.push_back("+zcz");
175-
}
176-
177-
return true;
163+
return DecodeAArch64Mcpu(D, MtuneLowerCase, Tune, Extensions);
178164
}
179165

180166
static bool
181167
getAArch64MicroArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu,
182168
const ArgList &Args,
183169
std::vector<StringRef> &Features) {
184-
StringRef CPU;
185-
// Check CPU name is valid, but ignore any extensions on it.
186-
llvm::AArch64::ExtensionSet DecodedFeature;
187-
std::string McpuLowerCase = Mcpu.lower();
188-
if (!DecodeAArch64Mcpu(D, McpuLowerCase, CPU, DecodedFeature))
189-
return false;
190-
191-
return getAArch64MicroArchFeaturesFromMtune(D, CPU, Args, Features);
170+
return getAArch64MicroArchFeaturesFromMtune(D, Mcpu, Args, Features);
192171
}
193172

194173
void aarch64::getAArch64TargetFeatures(const Driver &D,

0 commit comments

Comments
 (0)