Browse Source

Make sure handle store not unpack.

Xiang Li 8 years ago
parent
commit
6e4e66e845

+ 3 - 1
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

@@ -900,7 +900,9 @@ static bool unpackStoreToAggregate(InstCombiner &IC, StoreInst &SI) {
 
   if (auto *ST = dyn_cast<StructType>(T)) {
     // If the struct only have one element, we unpack.
-    if (ST->getNumElements() == 1) {
+    if (ST->getNumElements() == 1
+        && !hlsl::OP::IsDxilOpType(ST) // HLSL Change - avoid unpack dxil types.
+        ) {
       V = IC.Builder->CreateExtractValue(V, 0);
       combineStoreToNewValue(IC, SI, V);
       return true;

+ 10 - 0
tools/clang/test/CodeGenHLSL/shader-compat-suite/lib_ret_res.hlsl

@@ -0,0 +1,10 @@
+// RUN: %dxc -T lib_6_1 %s | FileCheck %s
+
+// Make sure handle store not unpack.
+// CHECK: store %dx.types.Handle %g_samLinear_sampler, %dx.types.Handle*
+
+SamplerState    g_samLinear;
+
+SamplerState GetSampler () {
+  return g_samLinear;
+}