Skip to content

Commit 5e43aa8

Browse files
authored
merge main into amd-staging (llvm#2187)
2 parents 3cd08b5 + 21bdbec commit 5e43aa8

File tree

177 files changed

+6460
-1505
lines changed

Some content is hidden

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

177 files changed

+6460
-1505
lines changed

.github/new-prs-labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ mlgo:
702702
- llvm/unittests/CodeGen/ML*
703703
- llvm/test/CodeGen/MLRegAlloc/**
704704
- llvm/utils/mlgo-utils/**
705+
- llvm/docs/MLGO.rst
705706

706707
tools:llvm-exegesis:
707708
- llvm/tools/llvm-exegesis/**

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ Bug Fixes in This Version
627627
argument which contains a pragma. (#GH113722)
628628
- Fixed assertion failures when generating name lookup table in modules. (#GH61065, #GH134739)
629629
- Fixed an assertion failure in constant compound literal statements. (#GH139160)
630+
- Fix crash due to unknown references and pointer implementation and handling of
631+
base classes. (GH139452)
630632

631633
Bug Fixes to Compiler Builtins
632634
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclCXX.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,9 +2606,6 @@ class CXXConstructorDecl final
26062606
size_t numTrailingObjects(OverloadToken<InheritedConstructor>) const {
26072607
return CXXConstructorDeclBits.IsInheritingConstructor;
26082608
}
2609-
size_t numTrailingObjects(OverloadToken<ExplicitSpecifier>) const {
2610-
return CXXConstructorDeclBits.HasTrailingExplicitSpecifier;
2611-
}
26122609

26132610
ExplicitSpecifier getExplicitSpecifierInternal() const {
26142611
if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
@@ -2625,8 +2622,12 @@ class CXXConstructorDecl final
26252622
};
26262623

26272624
uint64_t getTrailingAllocKind() const {
2628-
return numTrailingObjects(OverloadToken<InheritedConstructor>()) |
2629-
(numTrailingObjects(OverloadToken<ExplicitSpecifier>()) << 1);
2625+
uint64_t Kind = 0;
2626+
if (CXXConstructorDeclBits.IsInheritingConstructor)
2627+
Kind |= TAKInheritsConstructor;
2628+
if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
2629+
Kind |= TAKHasTailExplicit;
2630+
return Kind;
26302631
}
26312632

26322633
public:
@@ -3864,7 +3865,7 @@ class UsingPackDecl final
38643865
InstantiatedFrom ? InstantiatedFrom->getDeclName()
38653866
: DeclarationName()),
38663867
InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
3867-
llvm::uninitialized_copy(UsingDecls, getTrailingObjects<NamedDecl *>());
3868+
llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
38683869
}
38693870

38703871
void anchor() override;
@@ -3882,7 +3883,7 @@ class UsingPackDecl final
38823883
/// Get the set of using declarations that this pack expanded into. Note that
38833884
/// some of these may still be unresolved.
38843885
ArrayRef<NamedDecl *> expansions() const {
3885-
return getTrailingObjects<NamedDecl *>(NumExpansions);
3886+
return getTrailingObjects(NumExpansions);
38863887
}
38873888

38883889
static UsingPackDecl *Create(ASTContext &C, DeclContext *DC,
@@ -4235,7 +4236,7 @@ class DecompositionDecl final
42354236
: VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
42364237
SC),
42374238
NumBindings(Bindings.size()) {
4238-
llvm::uninitialized_copy(Bindings, getTrailingObjects<BindingDecl *>());
4239+
llvm::uninitialized_copy(Bindings, getTrailingObjects());
42394240
for (auto *B : Bindings) {
42404241
B->setDecomposedDecl(this);
42414242
if (B->isParameterPack() && B->getBinding()) {
@@ -4262,8 +4263,8 @@ class DecompositionDecl final
42624263
unsigned NumBindings);
42634264

42644265
// Provide the range of bindings which may have a nested pack.
4265-
llvm::ArrayRef<BindingDecl *> bindings() const {
4266-
return {getTrailingObjects<BindingDecl *>(), NumBindings};
4266+
ArrayRef<BindingDecl *> bindings() const {
4267+
return getTrailingObjects(NumBindings);
42674268
}
42684269

42694270
// Provide a flattened range to visit each binding.

clang/include/clang/Basic/Attr.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4739,7 +4739,8 @@ def Error : InheritableAttr {
47394739
def RootSignature : Attr {
47404740
/// [RootSignature(Signature)]
47414741
let Spellings = [Microsoft<"RootSignature">];
4742-
let Args = [IdentifierArgument<"Signature">];
4742+
let Args = [IdentifierArgument<"SignatureIdent">,
4743+
DeclArgument<HLSLRootSignature, "SignatureDecl", 0, /*fake=*/1>];
47434744
let Subjects = SubjectList<[Function],
47444745
ErrorDiag, "'function'">;
47454746
let LangOpts = [HLSL];
@@ -4789,6 +4790,7 @@ def HLSLResourceBinding: InheritableAttr {
47894790
RegisterType RegType;
47904791
std::optional<unsigned> SlotNumber;
47914792
unsigned SpaceNumber;
4793+
std::optional<unsigned> ImplicitBindingOrderID;
47924794

47934795
public:
47944796
void setBinding(RegisterType RT, std::optional<unsigned> SlotNum, unsigned SpaceNum) {
@@ -4810,6 +4812,16 @@ def HLSLResourceBinding: InheritableAttr {
48104812
unsigned getSpaceNumber() const {
48114813
return SpaceNumber;
48124814
}
4815+
void setImplicitBindingOrderID(uint32_t Value) {
4816+
ImplicitBindingOrderID = Value;
4817+
}
4818+
bool hasImplicitBindingOrderID() const {
4819+
return ImplicitBindingOrderID.has_value();
4820+
}
4821+
uint32_t getImplicitBindingOrderID() const {
4822+
assert(hasImplicitBindingOrderID() && "attribute does not have implicit binding order id");
4823+
return ImplicitBindingOrderID.value();
4824+
}
48134825
}];
48144826
}
48154827

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains external dialect interfaces for CIR.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
14+
#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
15+
16+
#include "mlir/Dialect/OpenACC/OpenACC.h"
17+
18+
namespace cir::acc {
19+
20+
template <typename T>
21+
struct OpenACCPointerLikeModel
22+
: public mlir::acc::PointerLikeType::ExternalModel<
23+
OpenACCPointerLikeModel<T>, T> {
24+
mlir::Type getElementType(mlir::Type pointer) const {
25+
return mlir::cast<T>(pointer).getPointee();
26+
}
27+
mlir::acc::VariableTypeCategory
28+
getPointeeTypeCategory(mlir::Type pointer,
29+
mlir::TypedValue<mlir::acc::PointerLikeType> varPtr,
30+
mlir::Type varType) const;
31+
};
32+
33+
} // namespace cir::acc
34+
35+
#endif // CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
10+
#define CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
11+
12+
namespace mlir {
13+
class DialectRegistry;
14+
} // namespace mlir
15+
16+
namespace cir::acc {
17+
18+
void registerOpenACCExtensions(mlir::DialectRegistry &registry);
19+
20+
} // namespace cir::acc
21+
22+
#endif // CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H

clang/include/clang/Sema/Overload.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,14 @@ class Sema;
430430
if (!ReferenceBinding) {
431431
#ifndef NDEBUG
432432
auto Decay = [&](QualType T) {
433-
return (T->isArrayType() || T->isFunctionType()) ? C.getDecayedType(T)
434-
: T;
433+
if (T->isArrayType() || T->isFunctionType())
434+
T = C.getDecayedType(T);
435+
436+
// A function pointer type can be resolved to a member function type,
437+
// which is still an identity conversion.
438+
if (auto *N = T->getAs<MemberPointerType>())
439+
T = C.getDecayedType(N->getPointeeType());
440+
return T;
435441
};
436442
// The types might differ if there is an array-to-pointer conversion
437443
// an function-to-pointer conversion, or lvalue-to-rvalue conversion.

clang/lib/AST/DeclCXX.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,9 +3449,8 @@ UsingPackDecl *UsingPackDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID,
34493449
size_t Extra = additionalSizeToAlloc<NamedDecl *>(NumExpansions);
34503450
auto *Result = new (C, ID, Extra) UsingPackDecl(nullptr, nullptr, {});
34513451
Result->NumExpansions = NumExpansions;
3452-
auto *Trail = Result->getTrailingObjects<NamedDecl *>();
3453-
for (unsigned I = 0; I != NumExpansions; ++I)
3454-
new (Trail + I) NamedDecl*(nullptr);
3452+
auto *Trail = Result->getTrailingObjects();
3453+
std::uninitialized_fill_n(Trail, NumExpansions, nullptr);
34553454
return Result;
34563455
}
34573456

@@ -3610,9 +3609,8 @@ DecompositionDecl *DecompositionDecl::CreateDeserialized(ASTContext &C,
36103609
QualType(), nullptr, StorageClass(), {});
36113610
// Set up and clean out the bindings array.
36123611
Result->NumBindings = NumBindings;
3613-
auto *Trail = Result->getTrailingObjects<BindingDecl *>();
3614-
for (unsigned I = 0; I != NumBindings; ++I)
3615-
new (Trail + I) BindingDecl*(nullptr);
3612+
auto *Trail = Result->getTrailingObjects();
3613+
std::uninitialized_fill_n(Trail, NumBindings, nullptr);
36163614
return Result;
36173615
}
36183616

clang/lib/AST/ExprConstant.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,11 @@ static bool HandleLValueBase(EvalInfo &Info, const Expr *E, LValue &Obj,
33143314
return false;
33153315

33163316
// Extract most-derived object and corresponding type.
3317-
DerivedDecl = D.MostDerivedType->getAsCXXRecordDecl();
3317+
// FIXME: After implementing P2280R4 it became possible to get references
3318+
// here. We do MostDerivedType->getAsCXXRecordDecl() in several other
3319+
// locations and if we see crashes in those locations in the future
3320+
// it may make more sense to move this fix into Lvalue::set.
3321+
DerivedDecl = D.MostDerivedType.getNonReferenceType()->getAsCXXRecordDecl();
33183322
if (!CastToDerivedClass(Info, E, Obj, DerivedDecl, D.MostDerivedPathLength))
33193323
return false;
33203324

clang/lib/CIR/CodeGen/CIRGenerator.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/AST/DeclGroup.h"
1919
#include "clang/CIR/CIRGenerator.h"
2020
#include "clang/CIR/Dialect/IR/CIRDialect.h"
21+
#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
2122

2223
using namespace cir;
2324
using namespace clang;
@@ -38,6 +39,12 @@ void CIRGenerator::Initialize(ASTContext &astContext) {
3839
mlirContext = std::make_unique<mlir::MLIRContext>();
3940
mlirContext->loadDialect<cir::CIRDialect>();
4041
mlirContext->getOrLoadDialect<mlir::acc::OpenACCDialect>();
42+
43+
// Register extensions to integrate CIR types with OpenACC.
44+
mlir::DialectRegistry registry;
45+
cir::acc::registerOpenACCExtensions(registry);
46+
mlirContext->appendDialectRegistry(registry);
47+
4148
cgm = std::make_unique<clang::CIRGen::CIRGenModule>(
4249
*mlirContext.get(), astContext, codeGenOpts, diags);
4350
}

0 commit comments

Comments
 (0)