Skip to content

Commit 5eb48c6

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3517)
2 parents 38d5e73 + 2348a4c commit 5eb48c6

File tree

64 files changed

+970
-565
lines changed

Some content is hidden

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

64 files changed

+970
-565
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ RISC-V Support
479479
- Add support for `__attribute__((interrupt("rnmi")))` to be used with the `Smrnmi` extension.
480480
With this the `Smrnmi` extension is fully supported.
481481

482+
- Add `-march=unset` to clear any previous `-march=` value. This ISA string will
483+
be computed from `-mcpu` or the platform default.
484+
482485
CUDA/HIP Language Changes
483486
^^^^^^^^^^^^^^^^^^^^^^^^^
484487

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
666666
}
667667

668668
case CK_VectorSplat: {
669-
assert(!classify(CE->getType()));
670-
assert(classify(SubExpr->getType()));
669+
assert(!canClassify(CE->getType()));
670+
assert(canClassify(SubExpr->getType()));
671671
assert(CE->getType()->isVectorType());
672672

673673
if (!Initializing) {
@@ -2069,7 +2069,7 @@ bool Compiler<Emitter>::visitCallArgs(ArrayRef<const Expr *> Args,
20692069

20702070
unsigned ArgIndex = 0;
20712071
for (const Expr *Arg : Args) {
2072-
if (OptPrimType T = classify(Arg)) {
2072+
if (canClassify(Arg)) {
20732073
if (!this->visit(Arg))
20742074
return false;
20752075
} else {
@@ -3154,7 +3154,7 @@ bool Compiler<Emitter>::VisitCXXNoexceptExpr(const CXXNoexceptExpr *E) {
31543154
template <class Emitter>
31553155
bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) {
31563156
QualType T = E->getType();
3157-
assert(!classify(T));
3157+
assert(!canClassify(T));
31583158

31593159
if (T->isRecordType()) {
31603160
const CXXConstructorDecl *Ctor = E->getConstructor();
@@ -4149,7 +4149,7 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
41494149

41504150
// Create local variable to hold the return value.
41514151
if (!E->isGLValue() && !E->getType()->isAnyComplexType() &&
4152-
!classify(E->getType())) {
4152+
!canClassify(E->getType())) {
41534153
std::optional<unsigned> LocalIndex = allocateLocal(E);
41544154
if (!LocalIndex)
41554155
return false;
@@ -4169,7 +4169,7 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
41694169

41704170
template <class Emitter>
41714171
bool Compiler<Emitter>::visitInitializer(const Expr *E) {
4172-
assert(!classify(E->getType()));
4172+
assert(!canClassify(E->getType()));
41734173

41744174
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/false,
41754175
/*NewInitializing=*/true);
@@ -4376,7 +4376,7 @@ bool Compiler<Emitter>::visitZeroArrayInitializer(QualType T, const Expr *E) {
43764376
template <class Emitter>
43774377
bool Compiler<Emitter>::visitAssignment(const Expr *LHS, const Expr *RHS,
43784378
const Expr *E) {
4379-
if (!classify(E->getType()))
4379+
if (!canClassify(E->getType()))
43804380
return false;
43814381

43824382
if (!this->visit(RHS))
@@ -7139,10 +7139,6 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
71397139
assert(!Desc->isPrimitive());
71407140
assert(!Desc->isPrimitiveArray());
71417141

7142-
// Can happen if the decl is invalid.
7143-
if (Desc->isDummy())
7144-
return true;
7145-
71467142
// Arrays.
71477143
if (Desc->isArray()) {
71487144
const Descriptor *ElemDesc = Desc->ElemDesc;

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
256256

257257
OptPrimType classify(const Expr *E) const { return Ctx.classify(E); }
258258
OptPrimType classify(QualType Ty) const { return Ctx.classify(Ty); }
259+
bool canClassify(const Expr *E) const { return Ctx.canClassify(E); }
260+
bool canClassify(QualType T) const { return Ctx.canClassify(T); }
259261

260262
/// Classifies a known primitive type.
261263
PrimType classifyPrim(QualType Ty) const {

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ const Function *Context::getOrCreateFunction(const FunctionDecl *FuncDecl) {
501501
// elsewhere in the code.
502502
QualType Ty = FuncDecl->getReturnType();
503503
bool HasRVO = false;
504-
if (!Ty->isVoidType() && !classify(Ty)) {
504+
if (!Ty->isVoidType() && !canClassify(Ty)) {
505505
HasRVO = true;
506506
ParamTypes.push_back(PT_Ptr);
507507
ParamOffsets.push_back(ParamOffset);

clang/lib/AST/ByteCode/Context.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ class Context final {
9393
return classify(E->getType());
9494
}
9595

96+
bool canClassify(QualType T) {
97+
if (const auto *BT = dyn_cast<BuiltinType>(T)) {
98+
if (BT->isInteger() || BT->isFloatingPoint())
99+
return true;
100+
if (BT->getKind() == BuiltinType::Bool)
101+
return true;
102+
}
103+
104+
if (T->isArrayType() || T->isRecordType() || T->isAnyComplexType() ||
105+
T->isVectorType())
106+
return false;
107+
return classify(T) != std::nullopt;
108+
}
109+
bool canClassify(const Expr *E) {
110+
if (E->isGLValue())
111+
return true;
112+
return canClassify(E->getType());
113+
}
114+
96115
const CXXMethodDecl *
97116
getOverridingFunction(const CXXRecordDecl *DynamicDecl,
98117
const CXXRecordDecl *StaticDecl,

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Descriptor::Descriptor(const DeclTy &D, const Record *R, MetadataSize MD,
367367
Descriptor::Descriptor(const DeclTy &D, MetadataSize MD)
368368
: Source(D), ElemSize(1), Size(1), MDSize(MD.value_or(0)),
369369
AllocSize(MDSize), ElemRecord(nullptr), IsConst(true), IsMutable(false),
370-
IsTemporary(false), IsDummy(true) {
370+
IsTemporary(false) {
371371
assert(Source && "Missing source");
372372
}
373373

@@ -453,7 +453,7 @@ SourceInfo Descriptor::getLoc() const {
453453
}
454454

455455
bool Descriptor::hasTrivialDtor() const {
456-
if (isPrimitive() || isPrimitiveArray() || isDummy())
456+
if (isPrimitive() || isPrimitiveArray())
457457
return true;
458458

459459
if (isRecord()) {
@@ -462,8 +462,9 @@ bool Descriptor::hasTrivialDtor() const {
462462
return !Dtor || Dtor->isTrivial();
463463
}
464464

465+
if (!ElemDesc)
466+
return true;
465467
// Composite arrays.
466-
assert(ElemDesc);
467468
return ElemDesc->hasTrivialDtor();
468469
}
469470

clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ struct Descriptor final {
166166
const bool IsVolatile = false;
167167
/// Flag indicating if the block is an array.
168168
const bool IsArray = false;
169-
/// Flag indicating if this is a dummy descriptor.
170-
bool IsDummy = false;
171169
bool IsConstexprUnknown = false;
172170

173171
/// Storage management methods.
@@ -203,9 +201,6 @@ struct Descriptor final {
203201
/// Allocates a dummy descriptor.
204202
Descriptor(const DeclTy &D, MetadataSize MD = std::nullopt);
205203

206-
/// Make this descriptor a dummy descriptor.
207-
void makeDummy() { IsDummy = true; }
208-
209204
QualType getType() const;
210205
QualType getElemQualType() const;
211206
QualType getDataType(const ASTContext &Ctx) const;
@@ -273,8 +268,6 @@ struct Descriptor final {
273268
bool isRecord() const { return !IsArray && ElemRecord; }
274269
/// Checks if the descriptor is of a union.
275270
bool isUnion() const;
276-
/// Checks if this is a dummy descriptor.
277-
bool isDummy() const { return IsDummy; }
278271

279272
/// Whether variables of this descriptor need their destructor called or not.
280273
bool hasTrivialDtor() const;

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
338338
}
339339

340340
OS << "\n";
341-
if (GP.isInitialized() && Desc->isPrimitive() && !Desc->isDummy()) {
341+
if (GP.isInitialized() && Desc->isPrimitive() && !G->block()->isDummy()) {
342342
OS << " ";
343343
{
344344
ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_CYAN, false});
@@ -394,8 +394,6 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream &OS) const {
394394
else if (isUnknownSizeArray())
395395
OS << " unknown-size-array";
396396

397-
if (isDummy())
398-
OS << " dummy";
399397
if (IsConstexprUnknown)
400398
OS << " constexpr-unknown";
401399
}
@@ -541,11 +539,12 @@ LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {
541539
else
542540
OS << "-\n";
543541
OS << " Pointers: " << NPointers << "\n";
544-
OS << " Dead: " << IsDead << "\n";
542+
OS << " Dead: " << isDead() << "\n";
545543
OS << " Static: " << IsStatic << "\n";
546-
OS << " Extern: " << IsExtern << "\n";
544+
OS << " Extern: " << isExtern() << "\n";
547545
OS << " Initialized: " << IsInitialized << "\n";
548-
OS << " Weak: " << IsWeak << "\n";
546+
OS << " Weak: " << isWeak() << "\n";
547+
OS << " Dummy: " << isDummy() << '\n';
549548
OS << " Dynamic: " << IsDynamic << "\n";
550549
}
551550

clang/lib/AST/ByteCode/DynamicAllocator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void DynamicAllocator::cleanup() {
2424
auto &AllocSite = Iter.second;
2525
for (auto &Alloc : AllocSite.Allocations) {
2626
Block *B = Alloc.block();
27-
assert(!B->IsDead);
27+
assert(!B->isDead());
2828
assert(B->isInitialized());
2929
B->invokeDtor();
3030

@@ -121,15 +121,15 @@ bool DynamicAllocator::deallocate(const Expr *Source,
121121
assert(!Site.empty());
122122

123123
// Find the Block to delete.
124-
auto AllocIt = llvm::find_if(Site.Allocations, [&](const Allocation &A) {
124+
auto *AllocIt = llvm::find_if(Site.Allocations, [&](const Allocation &A) {
125125
return BlockToDelete == A.block();
126126
});
127127

128128
assert(AllocIt != Site.Allocations.end());
129129

130130
Block *B = AllocIt->block();
131131
assert(B->isInitialized());
132-
assert(!B->IsDead);
132+
assert(!B->isDead());
133133
B->invokeDtor();
134134

135135
// Almost all our dynamic allocations have a pointer pointing to them
@@ -139,7 +139,7 @@ bool DynamicAllocator::deallocate(const Expr *Source,
139139
// over to a DeadBlock and simply keep the block in a separate DeadAllocations
140140
// list.
141141
if (B->hasPointers()) {
142-
B->IsDead = true;
142+
B->AccessFlags |= Block::DeadFlag;
143143
DeadAllocations.push_back(std::move(*AllocIt));
144144
Site.Allocations.erase(AllocIt);
145145

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ bool EvalEmitter::interpretCall(const FunctionDecl *FD, const Expr *E) {
9898
this->Params.insert({PD, {0, false}});
9999
}
100100

101-
if (!this->visit(E))
102-
return false;
103-
PrimType T = Ctx.classify(E).value_or(PT_Ptr);
104-
return this->emitPop(T, E);
101+
return this->visitExpr(E, /*DestroyToplevelScope=*/false);
105102
}
106103

107104
void EvalEmitter::emitLabel(LabelTy Label) { CurrentLabel = Label; }

0 commit comments

Comments
 (0)