Skip to content

Commit 19e5168

Browse files
committed
[SYCL] Revert "[OpenCL] Enable address spaces for references in C++"
Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent 2260ff1 commit 19e5168

File tree

8 files changed

+31
-76
lines changed

8 files changed

+31
-76
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9774,10 +9774,6 @@ class Sema {
97749774
AssignmentAction Action,
97759775
CheckedConversionKind CCK);
97769776

9777-
ExprResult PerformQualificationConversion(
9778-
Expr *E, QualType Ty, ExprValueKind VK = VK_RValue,
9779-
CheckedConversionKind CCK = CCK_ImplicitConversion);
9780-
97819777
/// the following "Check" methods will return a valid/converted QualType
97829778
/// or a null QualType (indicating an error diagnostic was issued).
97839779

clang/lib/AST/Expr.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,18 +1660,13 @@ bool CastExpr::CastConsistency() const {
16601660
assert(getSubExpr()->getType()->isFunctionType());
16611661
goto CheckNoBasePath;
16621662

1663-
case CK_AddressSpaceConversion: {
1664-
auto Ty = getType();
1665-
auto SETy = getSubExpr()->getType();
1666-
assert(getValueKindForType(Ty) == Expr::getValueKindForType(SETy));
1667-
if (!isGLValue())
1668-
Ty = Ty->getPointeeType();
1669-
if (!isGLValue())
1670-
SETy = SETy->getPointeeType();
1671-
assert(!Ty.isNull() && !SETy.isNull() &&
1672-
Ty.getAddressSpace() != SETy.getAddressSpace());
1673-
goto CheckNoBasePath;
1674-
}
1663+
case CK_AddressSpaceConversion:
1664+
assert(getType()->isPointerType() || getType()->isBlockPointerType());
1665+
assert(getSubExpr()->getType()->isPointerType() ||
1666+
getSubExpr()->getType()->isBlockPointerType());
1667+
assert(getType()->getPointeeType().getAddressSpace() !=
1668+
getSubExpr()->getType()->getPointeeType().getAddressSpace());
1669+
LLVM_FALLTHROUGH;
16751670
// These should not have an inheritance path.
16761671
case CK_Dynamic:
16771672
case CK_ToUnion:

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,6 +4168,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
41684168
case CK_ARCReclaimReturnedObject:
41694169
case CK_ARCExtendBlockObject:
41704170
case CK_CopyAndAutoreleaseBlockObject:
4171+
case CK_AddressSpaceConversion:
41714172
case CK_IntToOCLSampler:
41724173
case CK_FixedPointCast:
41734174
case CK_FixedPointToBoolean:
@@ -4264,15 +4265,6 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
42644265
return MakeAddrLValue(V, E->getType(), LV.getBaseInfo(),
42654266
CGM.getTBAAInfoForSubobject(LV, E->getType()));
42664267
}
4267-
case CK_AddressSpaceConversion: {
4268-
LValue LV = EmitLValue(E->getSubExpr());
4269-
QualType DestTy = getContext().getPointerType(E->getType());
4270-
llvm::Value *V = getTargetHooks().performAddrSpaceCast(
4271-
*this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
4272-
E->getType().getAddressSpace(), ConvertType(DestTy));
4273-
return MakeAddrLValue(Address(V, LV.getAddress().getAlignment()),
4274-
E->getType(), LV.getBaseInfo(), LV.getTBAAInfo());
4275-
}
42764268
case CK_ObjCObjectLValueCast: {
42774269
LValue LV = EmitLValue(E->getSubExpr());
42784270
Address V = Builder.CreateElementBitCast(LV.getAddress(),

clang/lib/Sema/DeclSpec.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,14 @@ bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
566566
// these storage-class specifiers.
567567
// OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
568568
// specifiers are not supported."
569-
// OpenCL C++ v1.0 s2.9 restricts register.
570569
if (S.getLangOpts().OpenCL &&
571570
!S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
572571
switch (SC) {
573572
case SCS_extern:
574573
case SCS_private_extern:
575574
case SCS_static:
576-
if (S.getLangOpts().OpenCLVersion < 120 &&
577-
!S.getLangOpts().OpenCLCPlusPlus) {
578-
DiagID = diag::err_opencl_unknown_type_specifier;
575+
if (S.getLangOpts().OpenCLVersion < 120) {
576+
DiagID = diag::err_opencl_unknown_type_specifier;
579577
PrevSpec = getSpecifierName(SC);
580578
return true;
581579
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7359,23 +7359,19 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
73597359
return;
73607360
}
73617361
}
7362-
// OpenCL C v1.2 s6.5 - All program scope variables must be declared in the
7362+
// OpenCL v1.2 s6.5 - All program scope variables must be declared in the
73637363
// __constant address space.
7364-
// OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static
7364+
// OpenCL v2.0 s6.5.1 - Variables defined at program scope and static
73657365
// variables inside a function can also be declared in the global
73667366
// address space.
7367-
// OpenCL C++ v1.0 s2.5 inherits rule from OpenCL C v2.0 and allows local
7368-
// address space additionally.
7369-
// FIXME: Add local AS for OpenCL C++.
73707367
if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() ||
73717368
NewVD->hasExternalStorage()) {
73727369
if (!T->isSamplerT() &&
73737370
!(T.getAddressSpace() == LangAS::opencl_constant ||
73747371
(T.getAddressSpace() == LangAS::opencl_global &&
7375-
(getLangOpts().OpenCLVersion == 200 ||
7376-
getLangOpts().OpenCLCPlusPlus)))) {
7372+
getLangOpts().OpenCLVersion == 200))) {
73777373
int Scope = NewVD->isStaticLocal() | NewVD->hasExternalStorage() << 1;
7378-
if (getLangOpts().OpenCLVersion == 200 || getLangOpts().OpenCLCPlusPlus)
7374+
if (getLangOpts().OpenCLVersion == 200)
73797375
Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
73807376
<< Scope << "global or constant";
73817377
else

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4276,24 +4276,10 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
42764276
case ICK_Qualification: {
42774277
// The qualification keeps the category of the inner expression, unless the
42784278
// target type isn't a reference.
4279-
ExprValueKind VK =
4280-
ToType->isReferenceType() ? From->getValueKind() : VK_RValue;
4281-
4282-
CastKind CK = CK_NoOp;
4283-
4284-
if (ToType->isReferenceType() &&
4285-
ToType->getPointeeType().getAddressSpace() !=
4286-
From->getType().getAddressSpace())
4287-
CK = CK_AddressSpaceConversion;
4288-
4289-
if (ToType->isPointerType() &&
4290-
ToType->getPointeeType().getAddressSpace() !=
4291-
From->getType()->getPointeeType().getAddressSpace())
4292-
CK = CK_AddressSpaceConversion;
4293-
4294-
From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context), CK, VK,
4295-
/*BasePath=*/nullptr, CCK)
4296-
.get();
4279+
ExprValueKind VK = ToType->isReferenceType() ?
4280+
From->getValueKind() : VK_RValue;
4281+
From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context),
4282+
CK_NoOp, VK, /*BasePath=*/nullptr, CCK).get();
42974283

42984284
if (SCS.DeprecatedStringLiteralToCharPtr &&
42994285
!getLangOpts().WritableStrings) {

clang/lib/Sema/SemaInit.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7261,20 +7261,12 @@ ExprResult Sema::TemporaryMaterializationConversion(Expr *E) {
72617261
return CreateMaterializeTemporaryExpr(E->getType(), E, false);
72627262
}
72637263

7264-
ExprResult Sema::PerformQualificationConversion(Expr *E, QualType Ty,
7265-
ExprValueKind VK,
7266-
CheckedConversionKind CCK) {
7267-
CastKind CK = (Ty.getAddressSpace() != E->getType().getAddressSpace())
7268-
? CK_AddressSpaceConversion
7269-
: CK_NoOp;
7270-
return ImpCastExprToType(E, Ty, CK, VK, /*BasePath=*/nullptr, CCK);
7271-
}
7272-
7273-
ExprResult InitializationSequence::Perform(Sema &S,
7274-
const InitializedEntity &Entity,
7275-
const InitializationKind &Kind,
7276-
MultiExprArg Args,
7277-
QualType *ResultType) {
7264+
ExprResult
7265+
InitializationSequence::Perform(Sema &S,
7266+
const InitializedEntity &Entity,
7267+
const InitializationKind &Kind,
7268+
MultiExprArg Args,
7269+
QualType *ResultType) {
72787270
if (Failed()) {
72797271
Diagnose(S, Entity, Kind, Args);
72807272
return ExprError();
@@ -7662,11 +7654,12 @@ ExprResult InitializationSequence::Perform(Sema &S,
76627654
case SK_QualificationConversionRValue: {
76637655
// Perform a qualification conversion; these can never go wrong.
76647656
ExprValueKind VK =
7665-
Step->Kind == SK_QualificationConversionLValue
7666-
? VK_LValue
7667-
: (Step->Kind == SK_QualificationConversionXValue ? VK_XValue
7668-
: VK_RValue);
7669-
CurInit = S.PerformQualificationConversion(CurInit.get(), Step->Type, VK);
7657+
Step->Kind == SK_QualificationConversionLValue ?
7658+
VK_LValue :
7659+
(Step->Kind == SK_QualificationConversionXValue ?
7660+
VK_XValue :
7661+
VK_RValue);
7662+
CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, CK_NoOp, VK);
76707663
break;
76717664
}
76727665

clang/lib/Sema/SemaType.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7255,8 +7255,7 @@ static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State,
72557255
bool IsPointee =
72567256
ChunkIndex > 0 &&
72577257
(D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Pointer ||
7258-
D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer ||
7259-
D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Reference);
7258+
D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer);
72607259
bool IsFuncReturnType =
72617260
ChunkIndex > 0 &&
72627261
D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Function;

0 commit comments

Comments
 (0)