|
@@ -5847,18 +5847,35 @@ void CGMSHLSLRuntime::EmitHLSLOutParamConversionInit(
|
|
const std::function<void(const VarDecl *, llvm::Value *)> &TmpArgMap) {
|
|
const std::function<void(const VarDecl *, llvm::Value *)> &TmpArgMap) {
|
|
// Special case: skip first argument of CXXOperatorCall (it is "this").
|
|
// Special case: skip first argument of CXXOperatorCall (it is "this").
|
|
unsigned ArgsToSkip = isa<CXXOperatorCallExpr>(E) ? 1 : 0;
|
|
unsigned ArgsToSkip = isa<CXXOperatorCallExpr>(E) ? 1 : 0;
|
|
-
|
|
|
|
for (uint32_t i = 0; i < FD->getNumParams(); i++) {
|
|
for (uint32_t i = 0; i < FD->getNumParams(); i++) {
|
|
const ParmVarDecl *Param = FD->getParamDecl(i);
|
|
const ParmVarDecl *Param = FD->getParamDecl(i);
|
|
const Expr *Arg = E->getArg(i+ArgsToSkip);
|
|
const Expr *Arg = E->getArg(i+ArgsToSkip);
|
|
QualType ParamTy = Param->getType().getNonReferenceType();
|
|
QualType ParamTy = Param->getType().getNonReferenceType();
|
|
|
|
|
|
- if (!Param->isModifierOut())
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (!Param->isModifierOut()) {
|
|
|
|
+ if (!ParamTy->isAggregateType() || hlsl::IsHLSLMatType(ParamTy))
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
// get original arg
|
|
// get original arg
|
|
LValue argLV = CGF.EmitLValue(Arg);
|
|
LValue argLV = CGF.EmitLValue(Arg);
|
|
|
|
|
|
|
|
+ if (!Param->isModifierOut()) {
|
|
|
|
+ bool isDefaultAddrSpace = true;
|
|
|
|
+ if (argLV.isSimple()) {
|
|
|
|
+ isDefaultAddrSpace =
|
|
|
|
+ argLV.getAddress()->getType()->getPointerAddressSpace() ==
|
|
|
|
+ DXIL::kDefaultAddrSpace;
|
|
|
|
+ }
|
|
|
|
+ bool isHLSLIntrinsic = false;
|
|
|
|
+ if (const FunctionDecl *Callee = E->getDirectCallee()) {
|
|
|
|
+ isHLSLIntrinsic = Callee->hasAttr<HLSLIntrinsicAttr>();
|
|
|
|
+ }
|
|
|
|
+ // Copy in arg which is not default address space and not on hlsl intrinsic.
|
|
|
|
+ if (isDefaultAddrSpace || isHLSLIntrinsic)
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
// create temp Var
|
|
// create temp Var
|
|
VarDecl *tmpArg =
|
|
VarDecl *tmpArg =
|
|
VarDecl::Create(CGF.getContext(), const_cast<FunctionDecl *>(FD),
|
|
VarDecl::Create(CGF.getContext(), const_cast<FunctionDecl *>(FD),
|
|
@@ -5902,8 +5919,10 @@ void CGMSHLSLRuntime::EmitHLSLOutParamConversionInit(
|
|
CGF.getContext());
|
|
CGF.getContext());
|
|
|
|
|
|
// save for cast after call
|
|
// save for cast after call
|
|
- castArgList.emplace_back(tmpLV);
|
|
|
|
- castArgList.emplace_back(argLV);
|
|
|
|
|
|
+ if (Param->isModifierOut()) {
|
|
|
|
+ castArgList.emplace_back(tmpLV);
|
|
|
|
+ castArgList.emplace_back(argLV);
|
|
|
|
+ }
|
|
|
|
|
|
bool isObject = HLModule::IsHLSLObjectType(
|
|
bool isObject = HLModule::IsHLSLObjectType(
|
|
tmpArgAddr->getType()->getPointerElementType());
|
|
tmpArgAddr->getType()->getPointerElementType());
|