Skip to content

Commit 80abf82

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:b4afade17564 into amd-gfx:259556a2c143
Local branch amd-gfx 259556a Merged main:7ac532efc8ae into amd-gfx:d8f80774ebd7 Remote branch main b4afade [InstCombine] Avoid use of ConstantExpr::getZExtOrBitcast() (NFC)
2 parents 259556a + b4afade commit 80abf82

File tree

39 files changed

+535
-140
lines changed

39 files changed

+535
-140
lines changed

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
.. contents::
1414
:local:
1515

16+
==============
1617
OpenMP Support
1718
==============
1819

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ def CUDAInvalidTarget : InheritableAttr {
12751275

12761276
def CUDALaunchBounds : InheritableAttr {
12771277
let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
1278-
let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
1278+
let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>,
1279+
ExprArgument<"MaxBlocks", 1>];
12791280
let LangOpts = [CUDA];
12801281
let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
12811282
// An AST node is created for this attribute, but is not used by other parts

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11850,6 +11850,10 @@ def err_sycl_special_type_num_init_method : Error<
1185011850
"types with 'sycl_special_class' attribute must have one and only one '__init' "
1185111851
"method defined">;
1185211852

11853+
def warn_cuda_maxclusterrank_sm_90 : Warning<
11854+
"maxclusterrank requires sm_90 or higher, CUDA arch provided: %0, ignoring "
11855+
"%1 attribute">, InGroup<IgnoredAttributes>;
11856+
1185311857
def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must "
1185411858
"have a bit size of at least %select{2|1}0">;
1185511859
def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit "

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11053,12 +11053,13 @@ class Sema final {
1105311053
/// Create an CUDALaunchBoundsAttr attribute.
1105411054
CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
1105511055
Expr *MaxThreads,
11056-
Expr *MinBlocks);
11056+
Expr *MinBlocks,
11057+
Expr *MaxBlocks);
1105711058

1105811059
/// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
1105911060
/// declaration.
1106011061
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
11061-
Expr *MaxThreads, Expr *MinBlocks);
11062+
Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
1106211063

1106311064
/// AddModeAttr - Adds a mode attribute to a particular declaration.
1106411065
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,

clang/lib/AST/Interp/Boolean.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class Boolean final {
8484
Boolean truncate(unsigned TruncBits) const { return *this; }
8585

8686
void print(llvm::raw_ostream &OS) const { OS << (V ? "true" : "false"); }
87+
std::string toDiagnosticString(const ASTContext &Ctx) const {
88+
std::string NameStr;
89+
llvm::raw_string_ostream OS(NameStr);
90+
print(OS);
91+
return NameStr;
92+
}
8793

8894
static Boolean min(unsigned NumBits) { return Boolean(false); }
8995
static Boolean max(unsigned NumBits) { return Boolean(true); }

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,29 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
253253
return this->delegate(RHS);
254254
}
255255

256+
// Special case for C++'s three-way/spaceship operator <=>, which
257+
// returns a std::{strong,weak,partial}_ordering (which is a class, so doesn't
258+
// have a PrimType).
259+
if (!T) {
260+
if (DiscardResult)
261+
return true;
262+
const ComparisonCategoryInfo *CmpInfo =
263+
Ctx.getASTContext().CompCategories.lookupInfoForType(BO->getType());
264+
assert(CmpInfo);
265+
266+
// We need a temporary variable holding our return value.
267+
if (!Initializing) {
268+
std::optional<unsigned> ResultIndex = this->allocateLocal(BO, false);
269+
if (!this->emitGetPtrLocal(*ResultIndex, BO))
270+
return false;
271+
}
272+
273+
if (!visit(LHS) || !visit(RHS))
274+
return false;
275+
276+
return this->emitCMP3(*LT, CmpInfo, BO);
277+
}
278+
256279
if (!LT || !RT || !T)
257280
return this->bail(BO);
258281

clang/lib/AST/Interp/Floating.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ class Floating final {
7676
F.toString(Buffer);
7777
OS << Buffer;
7878
}
79+
std::string toDiagnosticString(const ASTContext &Ctx) const {
80+
std::string NameStr;
81+
llvm::raw_string_ostream OS(NameStr);
82+
print(OS);
83+
return NameStr;
84+
}
7985

8086
unsigned bitWidth() const { return F.semanticsSizeInBits(F.getSemantics()); }
8187

clang/lib/AST/Interp/Integral.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ template <unsigned Bits, bool Signed> class Integral final {
128128
return Compare(V, RHS.V);
129129
}
130130

131+
std::string toDiagnosticString(const ASTContext &Ctx) const {
132+
std::string NameStr;
133+
llvm::raw_string_ostream OS(NameStr);
134+
OS << V;
135+
return NameStr;
136+
}
137+
131138
unsigned countLeadingZeros() const {
132139
if constexpr (!Signed)
133140
return llvm::countl_zero<ReprT>(V);

clang/lib/AST/Interp/Interp.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ bool CheckCtorCall(InterpState &S, CodePtr OpPC, const Pointer &This);
112112
bool CheckPotentialReinterpretCast(InterpState &S, CodePtr OpPC,
113113
const Pointer &Ptr);
114114

115+
/// Sets the given integral value to the pointer, which is of
116+
/// a std::{weak,partial,strong}_ordering type.
117+
bool SetThreeWayComparisonField(InterpState &S, CodePtr OpPC,
118+
const Pointer &Ptr, const APSInt &IntValue);
119+
115120
/// Checks if the shift operation is legal.
116121
template <typename LT, typename RT>
117122
bool CheckShift(InterpState &S, CodePtr OpPC, const LT &LHS, const RT &RHS,
@@ -781,6 +786,30 @@ bool EQ(InterpState &S, CodePtr OpPC) {
781786
});
782787
}
783788

789+
template <PrimType Name, class T = typename PrimConv<Name>::T>
790+
bool CMP3(InterpState &S, CodePtr OpPC, const ComparisonCategoryInfo *CmpInfo) {
791+
const T &RHS = S.Stk.pop<T>();
792+
const T &LHS = S.Stk.pop<T>();
793+
const Pointer &P = S.Stk.peek<Pointer>();
794+
795+
ComparisonCategoryResult CmpResult = LHS.compare(RHS);
796+
if (CmpResult == ComparisonCategoryResult::Unordered) {
797+
// This should only happen with pointers.
798+
const SourceInfo &Loc = S.Current->getSource(OpPC);
799+
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
800+
<< LHS.toDiagnosticString(S.getCtx())
801+
<< RHS.toDiagnosticString(S.getCtx());
802+
return false;
803+
}
804+
805+
assert(CmpInfo);
806+
const auto *CmpValueInfo = CmpInfo->getValueInfo(CmpResult);
807+
assert(CmpValueInfo);
808+
assert(CmpValueInfo->hasValidIntValue());
809+
APSInt IntValue = CmpValueInfo->getIntValue();
810+
return SetThreeWayComparisonField(S, OpPC, P, IntValue);
811+
}
812+
784813
template <PrimType Name, class T = typename PrimConv<Name>::T>
785814
bool NE(InterpState &S, CodePtr OpPC) {
786815
return CmpHelperEQ<T>(S, OpPC, [](ComparisonCategoryResult R) {

clang/lib/AST/Interp/InterpBuiltin.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,5 +594,22 @@ bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E,
594594
return true;
595595
}
596596

597+
bool SetThreeWayComparisonField(InterpState &S, CodePtr OpPC,
598+
const Pointer &Ptr, const APSInt &IntValue) {
599+
600+
const Record *R = Ptr.getRecord();
601+
assert(R);
602+
assert(R->getNumFields() == 1);
603+
604+
unsigned FieldOffset = R->getField(0u)->Offset;
605+
const Pointer &FieldPtr = Ptr.atField(FieldOffset);
606+
PrimType FieldT = *S.getContext().classify(FieldPtr.getType());
607+
608+
INT_TYPE_SWITCH(FieldT,
609+
FieldPtr.deref<T>() = T::from(IntValue.getSExtValue()));
610+
FieldPtr.initialize();
611+
return true;
612+
}
613+
597614
} // namespace interp
598615
} // namespace clang

0 commit comments

Comments
 (0)