Skip to content

Commit ec3fdb3

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:a7d6039f3efb into amd-gfx:c49aa733ae3f
Local branch amd-gfx c49aa73 Merged main:2633d94f289b into amd-gfx:38011e802b7f Remote branch main a7d6039 [mlir][linalg] Replace CopyOp from memref to linalg in linalg PromoteOp (llvm#69154)
2 parents c49aa73 + a7d6039 commit ec3fdb3

File tree

59 files changed

+2569
-609
lines changed

Some content is hidden

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

59 files changed

+2569
-609
lines changed

clang/include/clang/AST/DeclBase.h

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,16 +1515,14 @@ class DeclContext {
15151515
uint64_t IsThisDeclarationADemotedDefinition : 1;
15161516
};
15171517

1518-
/// Number of non-inherited bits in TagDeclBitfields.
1519-
enum { NumTagDeclBits = 10 };
1518+
/// Number of inherited and non-inherited bits in TagDeclBitfields.
1519+
enum { NumTagDeclBits = NumDeclContextBits + 10 };
15201520

15211521
/// Stores the bits used by EnumDecl.
15221522
/// If modified NumEnumDeclBit and the accessor
15231523
/// methods in EnumDecl should be updated appropriately.
15241524
class EnumDeclBitfields {
15251525
friend class EnumDecl;
1526-
/// For the bits in DeclContextBitfields.
1527-
uint64_t : NumDeclContextBits;
15281526
/// For the bits in TagDeclBitfields.
15291527
uint64_t : NumTagDeclBits;
15301528

@@ -1554,16 +1552,14 @@ class DeclContext {
15541552
uint64_t HasODRHash : 1;
15551553
};
15561554

1557-
/// Number of non-inherited bits in EnumDeclBitfields.
1558-
enum { NumEnumDeclBits = 20 };
1555+
/// Number of inherited and non-inherited bits in EnumDeclBitfields.
1556+
enum { NumEnumDeclBits = NumTagDeclBits + 20 };
15591557

15601558
/// Stores the bits used by RecordDecl.
15611559
/// If modified NumRecordDeclBits and the accessor
15621560
/// methods in RecordDecl should be updated appropriately.
15631561
class RecordDeclBitfields {
15641562
friend class RecordDecl;
1565-
/// For the bits in DeclContextBitfields.
1566-
uint64_t : NumDeclContextBits;
15671563
/// For the bits in TagDeclBitfields.
15681564
uint64_t : NumTagDeclBits;
15691565

@@ -1615,8 +1611,8 @@ class DeclContext {
16151611
uint64_t ODRHash : 26;
16161612
};
16171613

1618-
/// Number of non-inherited bits in RecordDeclBitfields.
1619-
enum { NumRecordDeclBits = 41 };
1614+
/// Number of inherited and non-inherited bits in RecordDeclBitfields.
1615+
enum { NumRecordDeclBits = NumTagDeclBits + 41 };
16201616

16211617
/// Stores the bits used by OMPDeclareReductionDecl.
16221618
/// If modified NumOMPDeclareReductionDeclBits and the accessor
@@ -1631,8 +1627,9 @@ class DeclContext {
16311627
uint64_t InitializerKind : 2;
16321628
};
16331629

1634-
/// Number of non-inherited bits in OMPDeclareReductionDeclBitfields.
1635-
enum { NumOMPDeclareReductionDeclBits = 2 };
1630+
/// Number of inherited and non-inherited bits in
1631+
/// OMPDeclareReductionDeclBitfields.
1632+
enum { NumOMPDeclareReductionDeclBits = NumDeclContextBits + 2 };
16361633

16371634
/// Stores the bits used by FunctionDecl.
16381635
/// If modified NumFunctionDeclBits and the accessor
@@ -1711,16 +1708,14 @@ class DeclContext {
17111708
uint64_t FriendConstraintRefersToEnclosingTemplate : 1;
17121709
};
17131710

1714-
/// Number of non-inherited bits in FunctionDeclBitfields.
1715-
enum { NumFunctionDeclBits = 31 };
1711+
/// Number of inherited and non-inherited bits in FunctionDeclBitfields.
1712+
enum { NumFunctionDeclBits = NumDeclContextBits + 31 };
17161713

17171714
/// Stores the bits used by CXXConstructorDecl. If modified
17181715
/// NumCXXConstructorDeclBits and the accessor
17191716
/// methods in CXXConstructorDecl should be updated appropriately.
17201717
class CXXConstructorDeclBitfields {
17211718
friend class CXXConstructorDecl;
1722-
/// For the bits in DeclContextBitfields.
1723-
uint64_t : NumDeclContextBits;
17241719
/// For the bits in FunctionDeclBitfields.
17251720
uint64_t : NumFunctionDeclBits;
17261721

@@ -1739,10 +1734,8 @@ class DeclContext {
17391734
uint64_t IsSimpleExplicit : 1;
17401735
};
17411736

1742-
/// Number of non-inherited bits in CXXConstructorDeclBitfields.
1743-
enum {
1744-
NumCXXConstructorDeclBits = 64 - NumDeclContextBits - NumFunctionDeclBits
1745-
};
1737+
/// Number of inherited and non-inherited bits in CXXConstructorDeclBitfields.
1738+
enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 20 };
17461739

17471740
/// Stores the bits used by ObjCMethodDecl.
17481741
/// If modified NumObjCMethodDeclBits and the accessor
@@ -1803,8 +1796,8 @@ class DeclContext {
18031796
uint64_t HasSkippedBody : 1;
18041797
};
18051798

1806-
/// Number of non-inherited bits in ObjCMethodDeclBitfields.
1807-
enum { NumObjCMethodDeclBits = 24 };
1799+
/// Number of inherited and non-inherited bits in ObjCMethodDeclBitfields.
1800+
enum { NumObjCMethodDeclBits = NumDeclContextBits + 24 };
18081801

18091802
/// Stores the bits used by ObjCContainerDecl.
18101803
/// If modified NumObjCContainerDeclBits and the accessor
@@ -1819,10 +1812,10 @@ class DeclContext {
18191812
SourceLocation AtStart;
18201813
};
18211814

1822-
/// Number of non-inherited bits in ObjCContainerDeclBitfields.
1815+
/// Number of inherited and non-inherited bits in ObjCContainerDeclBitfields.
18231816
/// Note that here we rely on the fact that SourceLocation is 32 bits
18241817
/// wide. We check this with the static_assert in the ctor of DeclContext.
1825-
enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
1818+
enum { NumObjCContainerDeclBits = 64 };
18261819

18271820
/// Stores the bits used by LinkageSpecDecl.
18281821
/// If modified NumLinkageSpecDeclBits and the accessor
@@ -1843,8 +1836,8 @@ class DeclContext {
18431836
uint64_t HasBraces : 1;
18441837
};
18451838

1846-
/// Number of non-inherited bits in LinkageSpecDeclBitfields.
1847-
enum { NumLinkageSpecDeclBits = 4 };
1839+
/// Number of inherited and non-inherited bits in LinkageSpecDeclBitfields.
1840+
enum { NumLinkageSpecDeclBits = NumDeclContextBits + 4 };
18481841

18491842
/// Stores the bits used by BlockDecl.
18501843
/// If modified NumBlockDeclBits and the accessor
@@ -1869,8 +1862,8 @@ class DeclContext {
18691862
uint64_t CanAvoidCopyToHeap : 1;
18701863
};
18711864

1872-
/// Number of non-inherited bits in BlockDeclBitfields.
1873-
enum { NumBlockDeclBits = 5 };
1865+
/// Number of inherited and non-inherited bits in BlockDeclBitfields.
1866+
enum { NumBlockDeclBits = NumDeclContextBits + 5 };
18741867

18751868
/// Pointer to the data structure used to lookup declarations
18761869
/// within this context (or a DependentStoredDeclsMap if this is a

clang/include/clang/AST/Type.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,11 +1663,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
16631663
/// Actually an ArrayType::ArraySizeModifier.
16641664
unsigned SizeModifier : 3;
16651665
};
1666+
enum { NumArrayTypeBits = NumTypeBits + 6 };
16661667

16671668
class ConstantArrayTypeBitfields {
16681669
friend class ConstantArrayType;
16691670

1670-
unsigned : NumTypeBits + 3 + 3;
1671+
unsigned : NumArrayTypeBits;
16711672

16721673
/// Whether we have a stored size expression.
16731674
unsigned HasStoredSizeExpr : 1;
@@ -1780,7 +1781,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
17801781
unsigned Keyword : 8;
17811782
};
17821783

1783-
enum { NumTypeWithKeywordBits = 8 };
1784+
enum { NumTypeWithKeywordBits = NumTypeBits + 8 };
17841785

17851786
class ElaboratedTypeBitfields {
17861787
friend class ElaboratedType;
@@ -1913,7 +1914,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
19131914
class DependentTemplateSpecializationTypeBitfields {
19141915
friend class DependentTemplateSpecializationType;
19151916

1916-
unsigned : NumTypeBits;
19171917
unsigned : NumTypeWithKeywordBits;
19181918

19191919
/// The number of template arguments named in this class template

clang/include/clang/Lex/Preprocessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,9 +2879,9 @@ class Preprocessor {
28792879
/// Alter the state of whether this PP currently is in a
28802880
/// "-Wunsafe-buffer-usage" opt-out region.
28812881
///
2882-
/// \param isEnter: true if this PP is entering a region; otherwise, this PP
2882+
/// \param isEnter true if this PP is entering a region; otherwise, this PP
28832883
/// is exiting a region
2884-
/// \param Loc: the location of the entry or exit of a
2884+
/// \param Loc the location of the entry or exit of a
28852885
/// region
28862886
/// \return true iff it is INVALID to enter or exit a region, i.e.,
28872887
/// attempt to enter a region before exiting a previous region, or exiting a
@@ -2893,7 +2893,7 @@ class Preprocessor {
28932893
/// opt-out region
28942894
bool isPPInSafeBufferOptOutRegion();
28952895

2896-
/// \param StartLoc: output argument. It will be set to the start location of
2896+
/// \param StartLoc output argument. It will be set to the start location of
28972897
/// the current "-Wunsafe-buffer-usage" opt-out region iff this function
28982898
/// returns true.
28992899
/// \return true iff this PP is currently in a "-Wunsafe-buffer-usage"

clang/lib/AST/Interp/Interp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
216216
}
217217

218218
bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
219-
return !Ptr.isDummy();
219+
return !Ptr.isZero() && !Ptr.isDummy();
220220
}
221221

222222
bool CheckNull(InterpState &S, CodePtr OpPC, const Pointer &Ptr,

clang/lib/AST/Interp/Interp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ inline bool GetPtrGlobal(InterpState &S, CodePtr OpPC, uint32_t I) {
11551155
/// 2) Pushes Pointer.atField(Off) on the stack
11561156
inline bool GetPtrField(InterpState &S, CodePtr OpPC, uint32_t Off) {
11571157
const Pointer &Ptr = S.Stk.pop<Pointer>();
1158-
if (!CheckNull(S, OpPC, Ptr, CSK_Field))
1158+
if (S.inConstantContext() && !CheckNull(S, OpPC, Ptr, CSK_Field))
11591159
return false;
11601160
if (!CheckExtern(S, OpPC, Ptr))
11611161
return false;

clang/lib/AST/Interp/Pointer.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ class Pointer {
199199
bool isField() const { return Base != 0 && Base != RootPtrMark; }
200200

201201
/// Accessor for information about the declaration site.
202-
const Descriptor *getDeclDesc() const { return Pointee->Desc; }
202+
const Descriptor *getDeclDesc() const {
203+
assert(Pointee);
204+
return Pointee->Desc;
205+
}
203206
SourceLocation getDeclLoc() const { return getDeclDesc()->getLocation(); }
204207

205208
/// Returns a pointer to the object of which this pointer is a field.
@@ -296,11 +299,17 @@ class Pointer {
296299
bool isUnion() const;
297300

298301
/// Checks if the storage is extern.
299-
bool isExtern() const { return Pointee->isExtern(); }
302+
bool isExtern() const { return Pointee && Pointee->isExtern(); }
300303
/// Checks if the storage is static.
301-
bool isStatic() const { return Pointee->isStatic(); }
304+
bool isStatic() const {
305+
assert(Pointee);
306+
return Pointee->isStatic();
307+
}
302308
/// Checks if the storage is temporary.
303-
bool isTemporary() const { return Pointee->isTemporary(); }
309+
bool isTemporary() const {
310+
assert(Pointee);
311+
return Pointee->isTemporary();
312+
}
304313
/// Checks if the storage is a static temporary.
305314
bool isStaticTemporary() const { return isStatic() && isTemporary(); }
306315

@@ -323,7 +332,10 @@ class Pointer {
323332
}
324333

325334
/// Returns the declaration ID.
326-
std::optional<unsigned> getDeclID() const { return Pointee->getDeclID(); }
335+
std::optional<unsigned> getDeclID() const {
336+
assert(Pointee);
337+
return Pointee->getDeclID();
338+
}
327339

328340
/// Returns the byte offset from the start.
329341
unsigned getByteOffset() const {
@@ -351,6 +363,8 @@ class Pointer {
351363

352364
/// Checks if the index is one past end.
353365
bool isOnePastEnd() const {
366+
if (!Pointee)
367+
return false;
354368
return isElementPastEnd() || getSize() == getOffset();
355369
}
356370

@@ -360,6 +374,7 @@ class Pointer {
360374
/// Dereferences the pointer, if it's live.
361375
template <typename T> T &deref() const {
362376
assert(isLive() && "Invalid pointer");
377+
assert(Pointee);
363378
if (isArrayRoot())
364379
return *reinterpret_cast<T *>(Pointee->rawData() + Base +
365380
sizeof(InitMapPtr));
@@ -370,6 +385,7 @@ class Pointer {
370385
/// Dereferences a primitive element.
371386
template <typename T> T &elem(unsigned I) const {
372387
assert(I < getNumElems());
388+
assert(Pointee);
373389
return reinterpret_cast<T *>(Pointee->data() + sizeof(InitMapPtr))[I];
374390
}
375391

@@ -431,12 +447,14 @@ class Pointer {
431447
/// Returns a descriptor at a given offset.
432448
InlineDescriptor *getDescriptor(unsigned Offset) const {
433449
assert(Offset != 0 && "Not a nested pointer");
450+
assert(Pointee);
434451
return reinterpret_cast<InlineDescriptor *>(Pointee->rawData() + Offset) -
435452
1;
436453
}
437454

438455
/// Returns a reference to the InitMapPtr which stores the initialization map.
439456
InitMapPtr &getInitMap() const {
457+
assert(Pointee);
440458
return *reinterpret_cast<InitMapPtr *>(Pointee->rawData() + Base);
441459
}
442460

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void ASTDeclWriter::VisitTypeAliasDecl(TypeAliasDecl *D) {
431431
}
432432

433433
void ASTDeclWriter::VisitTagDecl(TagDecl *D) {
434-
static_assert(DeclContext::NumTagDeclBits == 10,
434+
static_assert(DeclContext::NumTagDeclBits == 23,
435435
"You need to update the serializer after you change the "
436436
"TagDeclBits");
437437

@@ -459,7 +459,7 @@ void ASTDeclWriter::VisitTagDecl(TagDecl *D) {
459459
}
460460

461461
void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
462-
static_assert(DeclContext::NumEnumDeclBits == 20,
462+
static_assert(DeclContext::NumEnumDeclBits == 43,
463463
"You need to update the serializer after you change the "
464464
"EnumDeclBits");
465465

@@ -506,7 +506,7 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
506506
}
507507

508508
void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
509-
static_assert(DeclContext::NumRecordDeclBits == 41,
509+
static_assert(DeclContext::NumRecordDeclBits == 64,
510510
"You need to update the serializer after you change the "
511511
"RecordDeclBits");
512512

@@ -578,7 +578,7 @@ void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
578578
}
579579

580580
void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
581-
static_assert(DeclContext::NumFunctionDeclBits == 31,
581+
static_assert(DeclContext::NumFunctionDeclBits == 44,
582582
"You need to update the serializer after you change the "
583583
"FunctionDeclBits");
584584

@@ -726,7 +726,7 @@ void ASTDeclWriter::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) {
726726
}
727727

728728
void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
729-
static_assert(DeclContext::NumObjCMethodDeclBits == 24,
729+
static_assert(DeclContext::NumObjCMethodDeclBits == 37,
730730
"You need to update the serializer after you change the "
731731
"ObjCMethodDeclBits");
732732

@@ -788,7 +788,7 @@ void ASTDeclWriter::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) {
788788
}
789789

790790
void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) {
791-
static_assert(DeclContext::NumObjCContainerDeclBits == 51,
791+
static_assert(DeclContext::NumObjCContainerDeclBits == 64,
792792
"You need to update the serializer after you change the "
793793
"ObjCContainerDeclBits");
794794

@@ -1268,7 +1268,7 @@ void ASTDeclWriter::VisitCapturedDecl(CapturedDecl *CD) {
12681268
}
12691269

12701270
void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
1271-
static_assert(DeclContext::NumLinkageSpecDeclBits == 4,
1271+
static_assert(DeclContext::NumLinkageSpecDeclBits == 17,
12721272
"You need to update the serializer after you change the"
12731273
"LinkageSpecDeclBits");
12741274

@@ -1479,7 +1479,7 @@ void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
14791479
}
14801480

14811481
void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
1482-
static_assert(DeclContext::NumCXXConstructorDeclBits == 20,
1482+
static_assert(DeclContext::NumCXXConstructorDeclBits == 64,
14831483
"You need to update the serializer after you change the "
14841484
"CXXConstructorDeclBits");
14851485

@@ -1960,7 +1960,7 @@ void ASTDeclWriter::VisitOMPRequiresDecl(OMPRequiresDecl *D) {
19601960
}
19611961

19621962
void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
1963-
static_assert(DeclContext::NumOMPDeclareReductionDeclBits == 2,
1963+
static_assert(DeclContext::NumOMPDeclareReductionDeclBits == 15,
19641964
"You need to update the serializer after you change the "
19651965
"NumOMPDeclareReductionDeclBits");
19661966

clang/test/AST/Interp/c.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// RUN: %clang_cc1 -verify=ref -std=c11 %s
44
// RUN: %clang_cc1 -pedantic -verify=pedantic-ref -std=c11 %s
55

6+
typedef __INTPTR_TYPE__ intptr_t;
7+
68
_Static_assert(1, "");
79
_Static_assert(0 != 1, "");
810
_Static_assert(1.0 == 1.0, ""); // pedantic-ref-warning {{not an integer constant expression}} \
@@ -67,3 +69,15 @@ _Static_assert(&Test50 != (void*)0, ""); // ref-warning {{always true}} \
6769
// expected-warning {{always true}} \
6870
// pedantic-expected-warning {{always true}} \
6971
// pedantic-expected-warning {{is a GNU extension}}
72+
73+
struct y {int x,y;};
74+
int a2[(intptr_t)&((struct y*)0)->y]; // expected-warning {{folded to constant array}} \
75+
// pedantic-expected-warning {{folded to constant array}} \
76+
// ref-warning {{folded to constant array}} \
77+
// pedantic-ref-warning {{folded to constant array}}
78+
79+
const struct y *yy = (struct y*)0;
80+
const intptr_t L = (intptr_t)(&(yy->y)); // expected-error {{not a compile-time constant}} \
81+
// pedantic-expected-error {{not a compile-time constant}} \
82+
// ref-error {{not a compile-time constant}} \
83+
// pedantic-ref-error {{not a compile-time constant}}

0 commit comments

Comments
 (0)