Skip to content

Commit 078c35d

Browse files
Merge branch 'llvm:main' into flang-x86-check-cpu
2 parents 696e808 + d6c6bde commit 078c35d

File tree

248 files changed

+6489
-3161
lines changed

Some content is hidden

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

248 files changed

+6489
-3161
lines changed

clang/include/clang/Basic/Cuda.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ enum class OffloadArch {
106106
GFX90a,
107107
GFX90c,
108108
GFX9_4_GENERIC,
109-
GFX940,
110-
GFX941,
111109
GFX942,
112110
GFX950,
113111
GFX10_1_GENERIC,

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,8 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
33973397
CtorFunc = getFunction(CE->getConstructor());
33983398
if (!CtorFunc)
33993399
return false;
3400-
}
3400+
} else if (!DynamicInit)
3401+
DynamicInit = Init;
34013402

34023403
LabelTy EndLabel = this->getLabel();
34033404
LabelTy StartLabel = this->getLabel();

clang/lib/AST/ByteCode/Interp.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,13 +1132,14 @@ bool CMP3(InterpState &S, CodePtr OpPC, const ComparisonCategoryInfo *CmpInfo) {
11321132
const Pointer &P = S.Stk.peek<Pointer>();
11331133

11341134
ComparisonCategoryResult CmpResult = LHS.compare(RHS);
1135-
if (CmpResult == ComparisonCategoryResult::Unordered) {
1136-
// This should only happen with pointers.
1137-
const SourceInfo &Loc = S.Current->getSource(OpPC);
1138-
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
1139-
<< LHS.toDiagnosticString(S.getASTContext())
1140-
<< RHS.toDiagnosticString(S.getASTContext());
1141-
return false;
1135+
if constexpr (std::is_same_v<T, Pointer>) {
1136+
if (CmpResult == ComparisonCategoryResult::Unordered) {
1137+
const SourceInfo &Loc = S.Current->getSource(OpPC);
1138+
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
1139+
<< LHS.toDiagnosticString(S.getASTContext())
1140+
<< RHS.toDiagnosticString(S.getASTContext());
1141+
return false;
1142+
}
11421143
}
11431144

11441145
assert(CmpInfo);

clang/lib/Basic/Cuda.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ static const OffloadArchToStringMap arch_names[] = {
124124
GFX(90a), // gfx90a
125125
GFX(90c), // gfx90c
126126
{OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
127-
GFX(940), // gfx940
128-
GFX(941), // gfx941
129127
GFX(942), // gfx942
130128
GFX(950), // gfx950
131129
{OffloadArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},

clang/lib/Basic/Targets/NVPTX.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
211211
case OffloadArch::GFX90a:
212212
case OffloadArch::GFX90c:
213213
case OffloadArch::GFX9_4_GENERIC:
214-
case OffloadArch::GFX940:
215-
case OffloadArch::GFX941:
216214
case OffloadArch::GFX942:
217215
case OffloadArch::GFX950:
218216
case OffloadArch::GFX10_1_GENERIC:

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,24 @@ static void emitSincosBuiltin(CodeGenFunction &CGF, const CallExpr *E,
859859
StoreCos->setMetadata(LLVMContext::MD_noalias, AliasScopeList);
860860
}
861861

862+
static llvm::Value *emitModfBuiltin(CodeGenFunction &CGF, const CallExpr *E,
863+
llvm::Intrinsic::ID IntrinsicID) {
864+
llvm::Value *Val = CGF.EmitScalarExpr(E->getArg(0));
865+
llvm::Value *IntPartDest = CGF.EmitScalarExpr(E->getArg(1));
866+
867+
llvm::Value *Call =
868+
CGF.Builder.CreateIntrinsic(IntrinsicID, {Val->getType()}, Val);
869+
870+
llvm::Value *FractionalResult = CGF.Builder.CreateExtractValue(Call, 0);
871+
llvm::Value *IntegralResult = CGF.Builder.CreateExtractValue(Call, 1);
872+
873+
QualType DestPtrType = E->getArg(1)->getType()->getPointeeType();
874+
LValue IntegralLV = CGF.MakeNaturalAlignAddrLValue(IntPartDest, DestPtrType);
875+
CGF.EmitStoreOfScalar(IntegralResult, IntegralLV);
876+
877+
return FractionalResult;
878+
}
879+
862880
/// EmitFAbs - Emit a call to @llvm.fabs().
863881
static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) {
864882
Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -3377,11 +3395,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
33773395
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
33783396
*this, E, Intrinsic::sinh, Intrinsic::experimental_constrained_sinh));
33793397

3398+
case Builtin::BIsincos:
3399+
case Builtin::BIsincosf:
3400+
case Builtin::BIsincosl:
33803401
case Builtin::BI__builtin_sincos:
33813402
case Builtin::BI__builtin_sincosf:
33823403
case Builtin::BI__builtin_sincosf16:
33833404
case Builtin::BI__builtin_sincosl:
33843405
case Builtin::BI__builtin_sincosf128:
3406+
if (Builder.getIsFPConstrained())
3407+
break; // TODO: Emit constrained sincos intrinsic once one exists.
33853408
emitSincosBuiltin(*this, E, Intrinsic::sincos);
33863409
return RValue::get(nullptr);
33873410

@@ -4107,6 +4130,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
41074130
case Builtin::BI__builtin_frexpf128:
41084131
case Builtin::BI__builtin_frexpf16:
41094132
return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));
4133+
case Builtin::BImodf:
4134+
case Builtin::BImodff:
4135+
case Builtin::BImodfl:
4136+
case Builtin::BI__builtin_modf:
4137+
case Builtin::BI__builtin_modff:
4138+
case Builtin::BI__builtin_modfl:
4139+
if (Builder.getIsFPConstrained())
4140+
break; // TODO: Emit constrained modf intrinsic once one exists.
4141+
return RValue::get(emitModfBuiltin(*this, E, Intrinsic::modf));
41104142
case Builtin::BI__builtin_isgreater:
41114143
case Builtin::BI__builtin_isgreaterequal:
41124144
case Builtin::BI__builtin_isless:

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,8 +2302,6 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const OMPRequiresDecl *D) {
23022302
case OffloadArch::GFX90a:
23032303
case OffloadArch::GFX90c:
23042304
case OffloadArch::GFX9_4_GENERIC:
2305-
case OffloadArch::GFX940:
2306-
case OffloadArch::GFX941:
23072305
case OffloadArch::GFX942:
23082306
case OffloadArch::GFX950:
23092307
case OffloadArch::GFX10_1_GENERIC:

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
232232
}
233233
}
234234

235+
if (C.getDriver().isUsingLTO()) {
236+
if (Arg *A = tools::getLastProfileSampleUseArg(Args))
237+
CmdArgs.push_back(Args.MakeArgString(std::string("-lto-sample-profile:") +
238+
A->getValue()));
239+
}
235240
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
236241

237242
// Control Flow Guard checks

clang/lib/Sema/SemaCast.cpp

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ namespace {
104104
void CheckStaticCast();
105105
void CheckDynamicCast();
106106
void CheckCXXCStyleCast(bool FunctionalCast, bool ListInitialization);
107+
bool CheckHLSLCStyleCast(CheckedConversionKind CCK);
107108
void CheckCStyleCast();
108109
void CheckBuiltinBitCast();
109110
void CheckAddrspaceCast();
@@ -2776,39 +2777,9 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
27762777
CheckedConversionKind CCK = FunctionalStyle
27772778
? CheckedConversionKind::FunctionalCast
27782779
: CheckedConversionKind::CStyleCast;
2779-
2780-
QualType SrcTy = SrcExpr.get()->getType();
2781-
// This case should not trigger on regular vector cast, vector truncation
2782-
if (Self.getLangOpts().HLSL &&
2783-
Self.HLSL().CanPerformElementwiseCast(SrcExpr.get(), DestType)) {
2784-
if (SrcTy->isConstantArrayType())
2785-
SrcExpr = Self.ImpCastExprToType(
2786-
SrcExpr.get(), Self.Context.getArrayParameterType(SrcTy),
2787-
CK_HLSLArrayRValue, VK_PRValue, nullptr, CCK);
2788-
Kind = CK_HLSLElementwiseCast;
2789-
return;
2790-
}
2791-
2792-
// This case should not trigger on regular vector splat
2793-
// If the relative order of this and the HLSLElementWise cast checks
2794-
// are changed, it might change which cast handles what in a few cases
2795-
if (Self.getLangOpts().HLSL &&
2796-
Self.HLSL().CanPerformAggregateSplatCast(SrcExpr.get(), DestType)) {
2797-
const VectorType *VT = SrcTy->getAs<VectorType>();
2798-
// change splat from vec1 case to splat from scalar
2799-
if (VT && VT->getNumElements() == 1)
2800-
SrcExpr = Self.ImpCastExprToType(
2801-
SrcExpr.get(), VT->getElementType(), CK_HLSLVectorTruncation,
2802-
SrcExpr.get()->getValueKind(), nullptr, CCK);
2803-
// Inserting a scalar cast here allows for a simplified codegen in
2804-
// the case the destTy is a vector
2805-
if (const VectorType *DVT = DestType->getAs<VectorType>())
2806-
SrcExpr = Self.ImpCastExprToType(
2807-
SrcExpr.get(), DVT->getElementType(),
2808-
Self.PrepareScalarCast(SrcExpr, DVT->getElementType()),
2809-
SrcExpr.get()->getValueKind(), nullptr, CCK);
2810-
Kind = CK_HLSLAggregateSplatCast;
2811-
return;
2780+
if (Self.getLangOpts().HLSL) {
2781+
if (CheckHLSLCStyleCast(CCK))
2782+
return;
28122783
}
28132784

28142785
if (ValueKind == VK_PRValue && !DestType->isRecordType() &&
@@ -2927,6 +2898,56 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
29272898
}
29282899
}
29292900

2901+
// CheckHLSLCStyleCast - Returns `true` ihe cast is handled or errored as an
2902+
// HLSL-specific cast. Returns false if the cast should be checked as a CXX
2903+
// C-Style cast.
2904+
bool CastOperation::CheckHLSLCStyleCast(CheckedConversionKind CCK) {
2905+
assert(Self.getLangOpts().HLSL && "Must be HLSL!");
2906+
QualType SrcTy = SrcExpr.get()->getType();
2907+
// HLSL has several unique forms of C-style casts which support aggregate to
2908+
// aggregate casting.
2909+
// This case should not trigger on regular vector cast, vector truncation
2910+
if (Self.HLSL().CanPerformElementwiseCast(SrcExpr.get(), DestType)) {
2911+
if (SrcTy->isConstantArrayType())
2912+
SrcExpr = Self.ImpCastExprToType(
2913+
SrcExpr.get(), Self.Context.getArrayParameterType(SrcTy),
2914+
CK_HLSLArrayRValue, VK_PRValue, nullptr, CCK);
2915+
Kind = CK_HLSLElementwiseCast;
2916+
return true;
2917+
}
2918+
2919+
// This case should not trigger on regular vector splat
2920+
// If the relative order of this and the HLSLElementWise cast checks
2921+
// are changed, it might change which cast handles what in a few cases
2922+
if (Self.HLSL().CanPerformAggregateSplatCast(SrcExpr.get(), DestType)) {
2923+
const VectorType *VT = SrcTy->getAs<VectorType>();
2924+
// change splat from vec1 case to splat from scalar
2925+
if (VT && VT->getNumElements() == 1)
2926+
SrcExpr = Self.ImpCastExprToType(
2927+
SrcExpr.get(), VT->getElementType(), CK_HLSLVectorTruncation,
2928+
SrcExpr.get()->getValueKind(), nullptr, CCK);
2929+
// Inserting a scalar cast here allows for a simplified codegen in
2930+
// the case the destTy is a vector
2931+
if (const VectorType *DVT = DestType->getAs<VectorType>())
2932+
SrcExpr = Self.ImpCastExprToType(
2933+
SrcExpr.get(), DVT->getElementType(),
2934+
Self.PrepareScalarCast(SrcExpr, DVT->getElementType()),
2935+
SrcExpr.get()->getValueKind(), nullptr, CCK);
2936+
Kind = CK_HLSLAggregateSplatCast;
2937+
return true;
2938+
}
2939+
2940+
// If the destination is an array, we've exhausted the valid HLSL casts, so we
2941+
// should emit a dignostic and stop processing.
2942+
if (DestType->isArrayType()) {
2943+
Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
2944+
<< 4 << SrcTy << DestType;
2945+
SrcExpr = ExprError();
2946+
return true;
2947+
}
2948+
return false;
2949+
}
2950+
29302951
/// DiagnoseBadFunctionCast - Warn whenever a function call is cast to a
29312952
/// non-matching type. Such as enum function call to int, int call to
29322953
/// pointer; etc. Cast to 'void' is an exception.

clang/lib/Sema/SemaInit.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6585,6 +6585,18 @@ void InitializationSequence::InitializeFrom(Sema &S,
65856585
}
65866586
}
65876587

6588+
if (S.getLangOpts().HLSL && Initializer && isa<ConstantArrayType>(DestAT)) {
6589+
QualType SrcType = Entity.getType();
6590+
if (SrcType->isArrayParameterType())
6591+
SrcType =
6592+
cast<ArrayParameterType>(SrcType)->getConstantArrayType(Context);
6593+
if (S.Context.hasSameUnqualifiedType(DestType, SrcType)) {
6594+
TryArrayCopy(S, Kind, Entity, Initializer, DestType, *this,
6595+
TreatUnavailableAsInvalid);
6596+
return;
6597+
}
6598+
}
6599+
65886600
// Some kinds of initialization permit an array to be initialized from
65896601
// another array of the same type, and perform elementwise initialization.
65906602
if (Initializer && isa<ConstantArrayType>(DestAT) &&

0 commit comments

Comments
 (0)