Skip to content

Commit 5416cfe

Browse files
authored
Merge pull request llvm#447 from AMD-Lightning-Internal/amd/merge/upstream_merge_20250202142826
merge main into amd-staging
2 parents eaa7782 + 8a45d53 commit 5416cfe

File tree

60 files changed

+2100
-2277
lines changed

Some content is hidden

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

60 files changed

+2100
-2277
lines changed

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5040,7 +5040,7 @@ class CXXParenListInitExpr final
50405040
}
50415041

50425042
const FieldDecl *getInitializedFieldInUnion() const {
5043-
return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5043+
return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
50445044
}
50455045

50465046
child_range children() {

clang/include/clang/Lex/Preprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ class Preprocessor {
933933
}
934934

935935
ArrayRef<ModuleMacro*> getOverriddenMacros() const {
936-
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
936+
if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
937937
return Info->OverriddenMacros;
938938
return {};
939939
}

clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
135135
// Create a handle over the emitted code.
136136
Function *Func = P.getFunction(FuncDecl);
137137
if (!Func) {
138-
unsigned BuiltinID = FuncDecl->getBuiltinID();
139-
Func =
140-
P.createFunction(FuncDecl, ParamOffset, std::move(ParamTypes),
141-
std::move(ParamDescriptors), std::move(ParamOffsets),
142-
HasThisPointer, HasRVO, BuiltinID);
138+
Func = P.createFunction(FuncDecl, ParamOffset, std::move(ParamTypes),
139+
std::move(ParamDescriptors),
140+
std::move(ParamOffsets), HasThisPointer, HasRVO);
143141
}
144142

145143
assert(Func);
@@ -212,8 +210,7 @@ Function *ByteCodeEmitter::compileObjCBlock(const BlockExpr *BE) {
212210
Function *Func =
213211
P.createFunction(BE, ParamOffset, std::move(ParamTypes),
214212
std::move(ParamDescriptors), std::move(ParamOffsets),
215-
/*HasThisPointer=*/false, /*HasRVO=*/false,
216-
/*IsUnevaluatedBuiltin=*/false);
213+
/*HasThisPointer=*/false, /*HasRVO=*/false);
217214

218215
assert(Func);
219216
Func->setDefined(true);

clang/lib/AST/ByteCode/Function.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,28 @@ Function::Function(Program &P, FunctionDeclTy Source, unsigned ArgSize,
1919
llvm::SmallVectorImpl<PrimType> &&ParamTypes,
2020
llvm::DenseMap<unsigned, ParamDescriptor> &&Params,
2121
llvm::SmallVectorImpl<unsigned> &&ParamOffsets,
22-
bool HasThisPointer, bool HasRVO, unsigned BuiltinID)
23-
: P(P), Source(Source), ArgSize(ArgSize), ParamTypes(std::move(ParamTypes)),
24-
Params(std::move(Params)), ParamOffsets(std::move(ParamOffsets)),
25-
HasThisPointer(HasThisPointer), HasRVO(HasRVO), BuiltinID(BuiltinID) {
26-
if (const auto *F = Source.dyn_cast<const FunctionDecl *>())
22+
bool HasThisPointer, bool HasRVO)
23+
: P(P), Kind(FunctionKind::Normal), Source(Source), ArgSize(ArgSize),
24+
ParamTypes(std::move(ParamTypes)), Params(std::move(Params)),
25+
ParamOffsets(std::move(ParamOffsets)), HasThisPointer(HasThisPointer),
26+
HasRVO(HasRVO) {
27+
if (const auto *F = dyn_cast<const FunctionDecl *>(Source)) {
2728
Variadic = F->isVariadic();
29+
BuiltinID = F->getBuiltinID();
30+
if (const auto *CD = dyn_cast<CXXConstructorDecl>(F)) {
31+
Virtual = CD->isVirtual();
32+
Kind = FunctionKind::Ctor;
33+
} else if (const auto *CD = dyn_cast<CXXDestructorDecl>(F)) {
34+
Virtual = CD->isVirtual();
35+
Kind = FunctionKind::Dtor;
36+
} else if (const auto *MD = dyn_cast<CXXMethodDecl>(F)) {
37+
Virtual = MD->isVirtual();
38+
if (MD->isLambdaStaticInvoker())
39+
Kind = FunctionKind::LambdaStaticInvoker;
40+
else if (clang::isLambdaCallOperator(F))
41+
Kind = FunctionKind::LambdaCallOperator;
42+
}
43+
}
2844
}
2945

3046
Function::ParamDescriptor Function::getParamDescriptor(unsigned Offset) const {
@@ -45,13 +61,6 @@ SourceInfo Function::getSource(CodePtr PC) const {
4561
return It->second;
4662
}
4763

48-
bool Function::isVirtual() const {
49-
if (const auto *M = dyn_cast_if_present<CXXMethodDecl>(
50-
Source.dyn_cast<const FunctionDecl *>()))
51-
return M->isVirtual();
52-
return false;
53-
}
54-
5564
/// Unevaluated builtins don't get their arguments put on the stack
5665
/// automatically. They instead operate on the AST of their Call
5766
/// Expression.

clang/lib/AST/ByteCode/Function.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ using FunctionDeclTy =
8080
///
8181
class Function final {
8282
public:
83+
enum class FunctionKind {
84+
Normal,
85+
Ctor,
86+
Dtor,
87+
LambdaStaticInvoker,
88+
LambdaCallOperator,
89+
};
8390
using ParamDescriptor = std::pair<PrimType, Descriptor *>;
8491

8592
/// Returns the size of the function's local stack.
@@ -141,43 +148,31 @@ class Function final {
141148
bool isConstexpr() const { return IsValid || isLambdaStaticInvoker(); }
142149

143150
/// Checks if the function is virtual.
144-
bool isVirtual() const;
151+
bool isVirtual() const { return Virtual; };
145152

146153
/// Checks if the function is a constructor.
147-
bool isConstructor() const {
148-
return isa_and_nonnull<CXXConstructorDecl>(
149-
dyn_cast<const FunctionDecl *>(Source));
150-
}
154+
bool isConstructor() const { return Kind == FunctionKind::Ctor; }
151155
/// Checks if the function is a destructor.
152-
bool isDestructor() const {
153-
return isa_and_nonnull<CXXDestructorDecl>(
154-
dyn_cast<const FunctionDecl *>(Source));
155-
}
156-
157-
/// Returns the parent record decl, if any.
158-
const CXXRecordDecl *getParentDecl() const {
159-
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
160-
dyn_cast<const FunctionDecl *>(Source)))
161-
return MD->getParent();
162-
return nullptr;
163-
}
156+
bool isDestructor() const { return Kind == FunctionKind::Dtor; }
164157

165158
/// Returns whether this function is a lambda static invoker,
166159
/// which we generate custom byte code for.
167160
bool isLambdaStaticInvoker() const {
168-
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
169-
dyn_cast<const FunctionDecl *>(Source)))
170-
return MD->isLambdaStaticInvoker();
171-
return false;
161+
return Kind == FunctionKind::LambdaStaticInvoker;
172162
}
173163

174164
/// Returns whether this function is the call operator
175165
/// of a lambda record decl.
176166
bool isLambdaCallOperator() const {
167+
return Kind == FunctionKind::LambdaCallOperator;
168+
}
169+
170+
/// Returns the parent record decl, if any.
171+
const CXXRecordDecl *getParentDecl() const {
177172
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
178173
dyn_cast<const FunctionDecl *>(Source)))
179-
return clang::isLambdaCallOperator(MD);
180-
return false;
174+
return MD->getParent();
175+
return nullptr;
181176
}
182177

183178
/// Checks if the function is fully done compiling.
@@ -213,7 +208,7 @@ class Function final {
213208

214209
bool isThisPointerExplicit() const {
215210
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
216-
Source.dyn_cast<const FunctionDecl *>()))
211+
dyn_cast<const FunctionDecl *>(Source)))
217212
return MD->isExplicitObjectMemberFunction();
218213
return false;
219214
}
@@ -232,7 +227,7 @@ class Function final {
232227
llvm::SmallVectorImpl<PrimType> &&ParamTypes,
233228
llvm::DenseMap<unsigned, ParamDescriptor> &&Params,
234229
llvm::SmallVectorImpl<unsigned> &&ParamOffsets, bool HasThisPointer,
235-
bool HasRVO, unsigned BuiltinID);
230+
bool HasRVO);
236231

237232
/// Sets the code of a function.
238233
void setCode(unsigned NewFrameSize, std::vector<std::byte> &&NewCode,
@@ -255,6 +250,8 @@ class Function final {
255250

256251
/// Program reference.
257252
Program &P;
253+
/// Function Kind.
254+
FunctionKind Kind;
258255
/// Declaration this function was compiled from.
259256
FunctionDeclTy Source;
260257
/// Local area size: storage + metadata.
@@ -289,6 +286,7 @@ class Function final {
289286
bool HasBody = false;
290287
bool Defined = false;
291288
bool Variadic = false;
289+
bool Virtual = false;
292290
unsigned BuiltinID = 0;
293291

294292
public:

clang/lib/AST/ByteCode/Interp.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,14 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, unsigned Bits, const T &LHS,
379379
APSInt Value = OpAP<APSInt>()(LHS.toAPSInt(Bits), RHS.toAPSInt(Bits));
380380

381381
// Report undefined behaviour, stopping if required.
382-
const Expr *E = S.Current->getExpr(OpPC);
383-
QualType Type = E->getType();
384382
if (S.checkingForUndefinedBehavior()) {
383+
const Expr *E = S.Current->getExpr(OpPC);
384+
QualType Type = E->getType();
385385
SmallString<32> Trunc;
386386
Value.trunc(Result.bitWidth())
387387
.toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
388388
/*UpperCase=*/true, /*InsertSeparators=*/true);
389-
auto Loc = E->getExprLoc();
390-
S.report(Loc, diag::warn_integer_constant_overflow)
389+
S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
391390
<< Trunc << Type << E->getSourceRange();
392391
}
393392

@@ -737,16 +736,14 @@ bool Neg(InterpState &S, CodePtr OpPC) {
737736
S.Stk.push<T>(Result);
738737

739738
APSInt NegatedValue = -Value.toAPSInt(Value.bitWidth() + 1);
740-
const Expr *E = S.Current->getExpr(OpPC);
741-
QualType Type = E->getType();
742-
743739
if (S.checkingForUndefinedBehavior()) {
740+
const Expr *E = S.Current->getExpr(OpPC);
741+
QualType Type = E->getType();
744742
SmallString<32> Trunc;
745743
NegatedValue.trunc(Result.bitWidth())
746744
.toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
747745
/*UpperCase=*/true, /*InsertSeparators=*/true);
748-
auto Loc = E->getExprLoc();
749-
S.report(Loc, diag::warn_integer_constant_overflow)
746+
S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
750747
<< Trunc << Type << E->getSourceRange();
751748
return true;
752749
}
@@ -800,15 +797,14 @@ bool IncDecHelper(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
800797
APResult = --Value.toAPSInt(Bits);
801798

802799
// Report undefined behaviour, stopping if required.
803-
const Expr *E = S.Current->getExpr(OpPC);
804-
QualType Type = E->getType();
805800
if (S.checkingForUndefinedBehavior()) {
801+
const Expr *E = S.Current->getExpr(OpPC);
802+
QualType Type = E->getType();
806803
SmallString<32> Trunc;
807804
APResult.trunc(Result.bitWidth())
808805
.toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
809806
/*UpperCase=*/true, /*InsertSeparators=*/true);
810-
auto Loc = E->getExprLoc();
811-
S.report(Loc, diag::warn_integer_constant_overflow)
807+
S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
812808
<< Trunc << Type << E->getSourceRange();
813809
return true;
814810
}

clang/tools/libclang/CIndex.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7415,11 +7415,11 @@ unsigned clang_getNumOverloadedDecls(CXCursor C) {
74157415
return 0;
74167416

74177417
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
7418-
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
7418+
if (const OverloadExpr *E = dyn_cast<const OverloadExpr *>(Storage))
74197419
return E->getNumDecls();
74207420

74217421
if (OverloadedTemplateStorage *S =
7422-
Storage.dyn_cast<OverloadedTemplateStorage *>())
7422+
dyn_cast<OverloadedTemplateStorage *>(Storage))
74237423
return S->size();
74247424

74257425
const Decl *D = cast<const Decl *>(Storage);
@@ -7438,11 +7438,11 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
74387438

74397439
CXTranslationUnit TU = getCursorTU(cursor);
74407440
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(cursor).first;
7441-
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
7441+
if (const OverloadExpr *E = dyn_cast<const OverloadExpr *>(Storage))
74427442
return MakeCXCursor(E->decls_begin()[index], TU);
74437443

74447444
if (OverloadedTemplateStorage *S =
7445-
Storage.dyn_cast<OverloadedTemplateStorage *>())
7445+
dyn_cast<OverloadedTemplateStorage *>(Storage))
74467446
return MakeCXCursor(S->begin()[index], TU);
74477447

74487448
const Decl *D = cast<const Decl *>(Storage);

llvm/include/llvm-c/Core.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ typedef enum {
321321
LLVMRealPredicateTrue /**< Always true (always folded) */
322322
} LLVMRealPredicate;
323323

324-
typedef enum {
325-
LLVMLandingPadCatch, /**< A catch clause */
326-
LLVMLandingPadFilter /**< A filter clause */
327-
} LLVMLandingPadClauseTy;
328-
329324
typedef enum {
330325
LLVMNotThreadLocal = 0,
331326
LLVMGeneralDynamicTLSModel,

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,10 +1759,6 @@ class TargetTransformInfo {
17591759
/// scalable version of the vectorized loop.
17601760
bool preferFixedOverScalableIfEqualCost() const;
17611761

1762-
/// \returns True if target prefers SLP vectorizer with altermate opcode
1763-
/// vectorization, false - otherwise.
1764-
bool preferAlternateOpcodeVectorization() const;
1765-
17661762
/// \returns True if the target prefers reductions in loop.
17671763
bool preferInLoopReduction(unsigned Opcode, Type *Ty,
17681764
ReductionFlags Flags) const;
@@ -2310,7 +2306,6 @@ class TargetTransformInfo::Concept {
23102306
unsigned ChainSizeInBytes,
23112307
VectorType *VecTy) const = 0;
23122308
virtual bool preferFixedOverScalableIfEqualCost() const = 0;
2313-
virtual bool preferAlternateOpcodeVectorization() const = 0;
23142309
virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty,
23152310
ReductionFlags) const = 0;
23162311
virtual bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
@@ -3111,9 +3106,6 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
31113106
bool preferFixedOverScalableIfEqualCost() const override {
31123107
return Impl.preferFixedOverScalableIfEqualCost();
31133108
}
3114-
bool preferAlternateOpcodeVectorization() const override {
3115-
return Impl.preferAlternateOpcodeVectorization();
3116-
}
31173109
bool preferInLoopReduction(unsigned Opcode, Type *Ty,
31183110
ReductionFlags Flags) const override {
31193111
return Impl.preferInLoopReduction(Opcode, Ty, Flags);

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,6 @@ class TargetTransformInfoImplBase {
989989

990990
bool preferFixedOverScalableIfEqualCost() const { return false; }
991991

992-
bool preferAlternateOpcodeVectorization() const { return true; }
993-
994992
bool preferInLoopReduction(unsigned Opcode, Type *Ty,
995993
TTI::ReductionFlags Flags) const {
996994
return false;

0 commit comments

Comments
 (0)