Browse Source

Change byval to byref for out/inout parameter. (#132)

Xiang Li 8 years ago
parent
commit
dfaf7b8890

+ 3 - 0
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -4878,6 +4878,9 @@ void CGMSHLSLRuntime::EmitHLSLAggregateCopy(
       return;
     }
     const clang::RecordType *RT = Type->getAsStructureType();
+    // For classType.
+    if (!RT)
+      RT = Type->getAs<RecordType>();
     RecordDecl *RD = RT->getDecl();
     auto fieldIter = RD->field_begin();
 

+ 3 - 2
tools/clang/lib/CodeGen/TargetInfo.cpp

@@ -6208,9 +6208,10 @@ ABIArgInfo MSDXILABIInfo::classifyArgumentType(QualType Ty) const {
   if (const EnumType *EnumTy = Ty->getAs<EnumType>())
     Ty = EnumTy->getDecl()->getIntegerType();
 
-  // Return aggregates type as indirect by value
+  // Return aggregates type as indirect by ref.
+  // By val not work for out param.
   if (isAggregateTypeForABI(Ty))
-    return ABIArgInfo::getIndirect(0, /* byval */ true);
+    return ABIArgInfo::getIndirect(0, /* byval */ false);
 
   return (Ty->isPromotableIntegerType() ? ABIArgInfo::getExtend()
                                         : ABIArgInfo::getDirect());

+ 1 - 1
tools/clang/test/CodeGenHLSL/parameter_types.hlsl

@@ -1,6 +1,6 @@
 // RUN: %dxc -E main -T cs_6_0 -fcgl %s  | FileCheck %s
 
-// CHECK: float %a, <4 x float> %b, %struct.T* byval %t, %class.matrix.float.2.3 %m, [3 x <2 x float>]* byval %n
+// CHECK: float %a, <4 x float> %b, %struct.T* %t, %class.matrix.float.2.3 %m, [3 x <2 x float>]* %n
 
 // CHECK: float* dereferenceable(4) %a, <4 x float>* dereferenceable(16) %b, %struct.T* %t, %class.matrix.float.2.3* dereferenceable(24) %m, [3 x <2 x float>]* %n