================
@@ -6344,12 +6344,37 @@ ExprResult
Sema::PerformImplicitObjectArgumentInitialization(
QualType FromRecordType, DestType;
QualType ImplicitParamRecordType = Method->getFunctionObjectParameterType();
+ LangAS FromAS = From->getType().getAddressSpace();
if (getLangOpts().HLSL &&
- From->getType().getAddressSpace() == LangAS::hlsl_constant) {
+ (FromAS == LangAS::hlsl_constant ||
+ (FromAS == LangAS::hlsl_groupshared && Method->isConst()))) {
QualType CastType = From->getType().getLocalUnqualifiedType().withConst();
From = ImplicitCastExpr::Create(Context, CastType, CK_LValueToRValue, From,
/*BasePath=*/nullptr, VK_PRValue,
FPOptionsOverride());
+ } else if (getLangOpts().HLSL && FromAS == LangAS::hlsl_groupshared) {
+ ASTContext &Ctx = SemaRef.getASTContext();
+ QualType Ty =
+ From->getType().getLocalUnqualifiedType().getNonLValueExprType(Ctx);
+ InitializedEntity Entity = InitializedEntity::InitializeTemporary(Ty);
+ auto *FromOpV = new (Ctx) OpaqueValueExpr(
+ From->getBeginLoc(), From->getType().getLocalUnqualifiedType(),
+ VK_LValue, OK_Ordinary, From);
+ ExprResult Res =
+ SemaRef.PerformCopyInitialization(Entity, From->getBeginLoc(), From);
+ if (Res.isInvalid())
+ return ExprError();
+ Expr *Base = Res.get();
+ auto *OpV = new (Ctx)
+ OpaqueValueExpr(From->getBeginLoc(), Ty, VK_LValue, OK_Ordinary, Base);
+
+ Res = SemaRef.ActOnBinOp(SemaRef.getCurScope(), From->getBeginLoc(),
+ tok::equal, FromOpV, OpV);
+ if (Res.isInvalid())
+ return ExprError();
+ Expr *Writeback = Res.get();
+ From = HLSLOutArgExpr::Create(Ctx, Ty, FromOpV, OpV, Writeback,
+ /*IsInOut=*/true);
----------------
hekota wrote:
This seems to be very similar to the code in `SemaHLSL::ActOnOutParamExpr`. It
would be good to extract it into a shared helper function:
```suggestion
From = HLSL().createOutArgExpr(From);
```
https://github.com/llvm/llvm-project/pull/229939
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits