Browse Source

SROA alloca and global variable at same worklist. (#3019)

* SROA alloca and global variable at same worklist.
This will allow memcpy replacement works for case like cb->global->alloca->global.
Xiang Li 5 years ago
parent
commit
73a9d7fe8b

+ 0 - 8
include/llvm/Transforms/Scalar.h

@@ -111,14 +111,6 @@ FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
 FunctionPass* createHLExpandStoreIntrinsicsPass();
 FunctionPass* createHLExpandStoreIntrinsicsPass();
 void initializeHLExpandStoreIntrinsicsPass(PassRegistry&);
 void initializeHLExpandStoreIntrinsicsPass(PassRegistry&);
 
 
-//===----------------------------------------------------------------------===//
-//
-// ScalarReplAggregatesHLSL - Break up alloca's of aggregates into multiple allocas
-// for hlsl. Array will not change, all structures will be broken up.
-//
-FunctionPass *createScalarReplAggregatesHLSLPass();
-
-void initializeSROA_DT_HLSLPass(PassRegistry&);
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 //
 //
 // ScalarReplAggregatesHLSL - Break up argument's of aggregates into multiple arguments
 // ScalarReplAggregatesHLSL - Break up argument's of aggregates into multiple arguments

+ 0 - 2
lib/HLSL/DxcOptimizer.cpp

@@ -172,10 +172,8 @@ HRESULT SetupRegistryPassForHLSL() {
     initializeSCCPPass(Registry);
     initializeSCCPPass(Registry);
     initializeSROAPass(Registry);
     initializeSROAPass(Registry);
     initializeSROA_DTPass(Registry);
     initializeSROA_DTPass(Registry);
-    initializeSROA_DT_HLSLPass(Registry);
     initializeSROA_Parameter_HLSLPass(Registry);
     initializeSROA_Parameter_HLSLPass(Registry);
     initializeSROA_SSAUpPass(Registry);
     initializeSROA_SSAUpPass(Registry);
-    initializeSROA_SSAUp_HLSLPass(Registry);
     initializeSampleProfileLoaderPass(Registry);
     initializeSampleProfileLoaderPass(Registry);
     initializeScalarizerPass(Registry);
     initializeScalarizerPass(Registry);
     initializeScopedNoAliasAAPass(Registry);
     initializeScopedNoAliasAAPass(Registry);

+ 0 - 3
lib/Transforms/IPO/PassManagerBuilder.cpp

@@ -229,9 +229,6 @@ static void addHLSLPasses(bool HLSLHighLevel, unsigned OptLevel, hlsl::HLSLExten
   // Split struct and array of parameter.
   // Split struct and array of parameter.
   MPM.add(createSROA_Parameter_HLSL());
   MPM.add(createSROA_Parameter_HLSL());
 
 
-  // Split struct.
-  MPM.add(createScalarReplAggregatesHLSLPass());
-
   MPM.add(createHLMatrixLowerPass());
   MPM.add(createHLMatrixLowerPass());
   // DCE should after SROA to remove unused element.
   // DCE should after SROA to remove unused element.
   MPM.add(createDeadCodeEliminationPass());
   MPM.add(createDeadCodeEliminationPass());

File diff suppressed because it is too large
+ 1336 - 1259
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp


+ 34 - 0
tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/static/cb_static_temp_static.hlsl

@@ -0,0 +1,34 @@
+// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
+
+// CHECK:@main
+// Make sure no copy left.
+// CHECK-NOT:store float
+
+struct ST {
+  float4x4 mat[2];
+};
+
+cbuffer A {
+  float4x4 gmat[2];
+  uint index;
+};
+
+static const struct {
+  float4x4 mat[2];
+} GV = {gmat};
+
+ST Get() {
+  ST R;
+  R.mat = GV.mat;
+  return R;
+}
+
+static ST SGV;
+
+
+float4 main() : SV_POSITION {
+  SGV = Get();
+  return SGV.mat[index][0];
+}
+
+

+ 2 - 2
tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/static/staticGlobals3.hlsl

@@ -11,11 +11,11 @@
 // CHECK: [3 x i32] [i32 0, i32 28, i32 0]
 // CHECK: [3 x i32] [i32 0, i32 28, i32 0]
 // t3.a
 // t3.a
 
 
-// CHECK: [12 x float] [float 5.000000e+00, float 7.000000e+00, float 6.000000e+00, float 8.000000e+00, float 2.500000e+01, float 2.700000e+01, float 2.600000e+01, float 2.800000e+01, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00]
+// CHECK-DAG: [12 x float] [float 5.000000e+00, float 7.000000e+00, float 6.000000e+00, float 8.000000e+00, float 2.500000e+01, float 2.700000e+01, float 2.600000e+01, float 2.800000e+01, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00]
 
 
 // t3.t
 // t3.t
 
 
-// CHECK: [24 x float] [float 2.500000e+01, float 2.700000e+01, float 2.600000e+01, float 2.800000e+01, float 2.500000e+01, float 2.700000e+01, float 2.600000e+01, float 2.800000e+01, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 5.000000e+00, float 7.000000e+00, float 6.000000e+00, float 8.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 5.000000e+00, float 7.000000e+00, float 6.000000e+00, float 8.000000e+00]
+// CHECK-DAG: [24 x float] [float 2.500000e+01, float 2.700000e+01, float 2.600000e+01, float 2.800000e+01, float 2.500000e+01, float 2.700000e+01, float 2.600000e+01, float 2.800000e+01, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 5.000000e+00, float 7.000000e+00, float 6.000000e+00, float 8.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 5.000000e+00, float 7.000000e+00, float 6.000000e+00, float 8.000000e+00]
 
 
 
 
 
 

+ 0 - 2
utils/hct/hctdb.py

@@ -2050,8 +2050,6 @@ class db_dxil(object):
         add_pass("hl-expand-store-intrinsics", "HLExpandStoreIntrinsics", "Expand HLSL store intrinsics", [])
         add_pass("hl-expand-store-intrinsics", "HLExpandStoreIntrinsics", "Expand HLSL store intrinsics", [])
         add_pass("hl-legalize-parameter", "HLLegalizeParameter", "Legalize parameter", [])
         add_pass("hl-legalize-parameter", "HLLegalizeParameter", "Legalize parameter", [])
         add_pass('scalarrepl-param-hlsl', 'SROA_Parameter_HLSL', 'Scalar Replacement of Aggregates HLSL (parameters)', [])
         add_pass('scalarrepl-param-hlsl', 'SROA_Parameter_HLSL', 'Scalar Replacement of Aggregates HLSL (parameters)', [])
-        add_pass('scalarreplhlsl', 'SROA_DT_HLSL', 'Scalar Replacement of Aggregates HLSL (DT)', [])
-        add_pass('scalarreplhlsl-ssa', 'SROA_SSAUp_HLSL', 'Scalar Replacement of Aggregates HLSL (SSAUp)', [])
         add_pass('static-global-to-alloca', 'LowerStaticGlobalIntoAlloca', 'Lower static global into Alloca', [])
         add_pass('static-global-to-alloca', 'LowerStaticGlobalIntoAlloca', 'Lower static global into Alloca', [])
         add_pass('hlmatrixlower', 'HLMatrixLowerPass', 'HLSL High-Level Matrix Lower', [])
         add_pass('hlmatrixlower', 'HLMatrixLowerPass', 'HLSL High-Level Matrix Lower', [])
         add_pass('matrixbitcastlower', 'MatrixBitcastLowerPass', 'Matrix Bitcast lower', [])
         add_pass('matrixbitcastlower', 'MatrixBitcastLowerPass', 'Matrix Bitcast lower', [])

Some files were not shown because too many files changed in this diff