瀏覽代碼

Not replace struct parameter to function call arg. (#466)

Xiang Li 8 年之前
父節點
當前提交
4723496f3e

+ 4 - 11
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

@@ -3658,17 +3658,10 @@ void PointerStatus::analyzePointer(const Value *V, PointerStatus &PS,
       for (unsigned i = 0; i < argSize; i++) {
         Value *arg = CI->getArgOperand(i);
         if (V == arg) {
-          DxilParamInputQual inputQual =
-              annotation->GetParameterAnnotation(i).GetParamInputQual();
-          if (inputQual != DxilParamInputQual::In) {
-            PS.MarkAsStored();
-            if (inputQual == DxilParamInputQual::Inout)
-              PS.MarkAsLoaded();
-            break;
-          } else {
-            PS.MarkAsLoaded();
-            break;
-          }
+          // Do not replace struct arg.
+          // Mark stored and loaded to disable replace.
+          PS.MarkAsStored();
+          PS.MarkAsLoaded();
         }
       }
     }

+ 19 - 0
tools/clang/test/CodeGenHLSL/shader-compat-suite/lib_arg_flatten/lib_arg_flatten3.hlsl

@@ -0,0 +1,19 @@
+// RUN: %dxc -T lib_6_1 %s | FileCheck %s
+
+// Make sure struct parameter not replaced as function call arg.
+
+// CHECK: call void @"\01?test_extern@@YAMUT@@@Z"(float %{{.*}}, float %{{.*}}, float* nonnull %{{.*}})
+
+struct T {
+  float a;
+  float b;
+};
+
+float test_extern(T t);
+
+float test(T t)
+{
+  T tmp = t;
+  float x = test_extern(tmp);
+  return x + tmp.b;
+}