Ver Fonte

Make return value the first output element. (#1622)

Adam Yang há 6 anos atrás
pai
commit
0e5b2624be

+ 3 - 3
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

@@ -6045,7 +6045,7 @@ void SROA_Parameter_HLSL::createFlattenedFunction(Function *F) {
 
     const int kRetArgNo = -1;
     for (unsigned i = 0; i < FlatRetList.size(); i++) {
-      FlatParamOriArgNoList.emplace_back(kRetArgNo);
+      FlatParamOriArgNoList.insert(FlatParamOriArgNoList.begin(), kRetArgNo);
     }
   }
 
@@ -6058,9 +6058,9 @@ void SROA_Parameter_HLSL::createFlattenedFunction(Function *F) {
     // Change return value into out parameter.
     retType = Type::getVoidTy(retType->getContext());
     // Merge return data info param data.
-    FlatParamList.insert(FlatParamList.end(), FlatRetList.begin(), FlatRetList.end());
 
-    FlatParamAnnotationList.insert(FlatParamAnnotationList.end(),
+    FlatParamList.insert(FlatParamList.begin(), FlatRetList.begin(), FlatRetList.end());
+    FlatParamAnnotationList.insert(FlatParamAnnotationList.begin(),
                                     FlatRetAnnotationList.begin(),
                                     FlatRetAnnotationList.end());
   }

+ 5 - 5
tools/clang/test/CodeGenHLSL/matrixOut1.hlsl

@@ -2,14 +2,14 @@
 
 // fxc o1.xy = 5, 7 o2.xy = 6, 8
 
-// CHECK: dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float 5.000000e+00)
-// CHECK: dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float 7.000000e+00)
-// CHECK: dx.op.storeOutput.f32(i32 5, i32 0, i32 1, i8 0, float 6.000000e+00)
-// CHECK: dx.op.storeOutput.f32(i32 5, i32 0, i32 1, i8 1, float 8.000000e+00)
+// CHECK: dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 0, float 5.000000e+00)
+// CHECK: dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 1, float 7.000000e+00)
+// CHECK: dx.op.storeOutput.f32(i32 5, i32 1, i32 1, i8 0, float 6.000000e+00)
+// CHECK: dx.op.storeOutput.f32(i32 5, i32 1, i32 1, i8 1, float 8.000000e+00)
 
 float4 main(out float2x2 a : A, int4 b : B) : SV_Position
 {
   float2x2 m = { 5, 6, 7, 8};
   a = m;
   return b;
-}
+}

+ 8 - 8
tools/clang/test/HLSL/eliminate_dynamic_output.hlsl

@@ -1,14 +1,14 @@
 // RUN: %dxc -Emain -Tvs_6_0 %s | %opt -S -hlsl-dxil-eliminate-output-dynamic | %FileCheck %s
 
 // CHECK-NOT: storeOutput.f32(i32 5, i32 0, i32 %i
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 1
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 2
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 3
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 4
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 5
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 6
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 7
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 2
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 3
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 4
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 5
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 6
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 7
 
 int  count;
 float4 c[16];

+ 8 - 8
tools/clang/test/HLSL/eliminate_dynamic_output2.hlsl

@@ -1,14 +1,14 @@
 // RUN: %dxc -Emain -Tvs_6_0 %s | %opt -S -hlsl-dxil-eliminate-output-dynamic | %FileCheck %s
 
 // CHECK-NOT: storeOutput.f32(i32 5, i32 0, i32 %i
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 0, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 1, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 2, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 3, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 0, i8 1
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 1, i8 1
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 2, i8 1
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 3, i8 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 0, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 1, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 2, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 3, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 0, i8 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 1, i8 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 2, i8 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 3, i8 1
 int  count;
 float4 c[16];
 

+ 8 - 8
tools/clang/test/HLSL/eliminate_dynamic_output3.hlsl

@@ -1,14 +1,14 @@
 // RUN: %dxc -Emain -Tvs_6_0 %s | %opt -S -hlsl-dxil-eliminate-output-dynamic | %FileCheck %s
 
 // CHECK-NOT: storeOutput.f32(i32 5, i32 0, i32 %i
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 1
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 2
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 3
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 4
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 5
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 6
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 7
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 2
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 3
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 4
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 5
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 6
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 7
 
 int  count;
 float4 c[16];

+ 4 - 4
tools/clang/test/HLSL/eliminate_dynamic_output4.hlsl

@@ -3,12 +3,12 @@
 // CHECK-NOT: storeOutput.f32(i32 5, i32 0, i32 %i
 // CHECK-NOT: storeOutput.f32(i32 5, i32 1, i32 %i
 // CHECK-NOT: storeOutput.f32(i32 5, i32 2, i32 %i
-// CHECK: storeOutput.f32(i32 5, i32 1, i32 0, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 1, i32 1, i8 0
 // CHECK: storeOutput.f32(i32 5, i32 2, i32 0, i8 0
 // CHECK: storeOutput.f32(i32 5, i32 2, i32 1, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 0, i8 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 1, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 3, i32 0, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 3, i32 1, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 0, i8 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 1, i8 0
 
 int  count;
 float4 c[16];

+ 8 - 8
tools/clang/test/HLSL/eliminate_dynamic_output6.hlsl

@@ -3,14 +3,14 @@
 // CHECK-NOT: storeOutput.f32(i32 5, i32 0, i32 %i
 // CHECK-NOT: storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float 0x3FF99999A0000000
 // CHECK: 0x3FF99999A0000000
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 0
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 1
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 2
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 3
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 4
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 5
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 6
-// CHECK: storeOutput.f32(i32 5, i32 0, i32 7
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 0
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 1
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 2
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 3
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 4
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 5
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 6
+// CHECK: storeOutput.f32(i32 5, i32 1, i32 7
 
 int  count;
 float4 c[16];

+ 4 - 4
tools/clang/unittests/HLSL/ValidationTest.cpp

@@ -1346,8 +1346,8 @@ TEST_F(ValidationTest, PsOutputSemantic) {
 TEST_F(ValidationTest, ArrayOfSVTarget) {
     RewriteAssemblyCheckMsg(
       L"..\\CodeGenHLSL\\targetArray.hlsl", "ps_6_0",
-      "i32 2, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 4, i32 5, i8 0, null}",
-      "i32 2, !\"SV_Target\", i8 9, i8 16, !101, i8 0, i32 2, i8 4, i32 5, i8 0, null}\n!101 = !{i32 5, i32 6}",
+      "i32 2, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 4, i32 0, i8 0, null}",
+      "i32 2, !\"SV_Target\", i8 9, i8 16, !101, i8 0, i32 2, i8 4, i32 0, i8 0, null}\n!101 = !{i32 5, i32 6}",
       "Pixel shader output registers are not indexable.",
       /*bRegex*/true);
 }
@@ -2260,8 +2260,8 @@ float4 main(float4 f4 : Input, out float d0 : SV_Depth, out float d1 : SV_Target
 { d0 = f4.z; d1 = f4.w; return f4; } \
     ",
     "ps_6_0",
-    {"!{i32 1, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 1, i32 0, i8 0, null}"},
-    {"!{i32 1, !\"SV_DepthGreaterEqual\", i8 9, i8 19, !\\1, i8 0, i32 1, i8 1, i32 -1, i8 -1, null}"},
+    {"!{i32 2, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 1, i32 0, i8 0, null}"},
+    {"!{i32 2, !\"SV_DepthGreaterEqual\", i8 9, i8 19, !\\1, i8 0, i32 1, i8 1, i32 -1, i8 -1, null}"},
     "Pixel Shader only allows one type of depth semantic to be declared",
     /*bRegex*/true);
 }