[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 11:51:20 PST 2024


================
@@ -318,22 +314,38 @@ static void translateMetadata(Module &M, const DXILResourceMap &DRM,
   // See https://github.com/llvm/llvm-project/issues/57928
   MDTuple *Signatures = nullptr;
 
-  if (MMDI.ShaderProfile == Triple::EnvironmentType::Library)
+  if (MMDI.ShaderProfile == Triple::EnvironmentType::Library) {
+    // Create a consolidated shader flag mask of all functions in the library
+    // to be used as shader flags mask value associated with top-level library
+    // entry metadata.
+    uint64_t ConsolidatedMask = ShaderFlags.getModuleFlags();
+    for (const auto &FunFlags : ShaderFlags.getFunctionFlags()) {
+      ConsolidatedMask |= FunFlags.second;
+    }
----------------
bharadwajy wrote:

> It looks like the calculation of the ConsolidatedMask should be entirely encapsulated within DXILModuleShaderFlagsInfo. It's kind of strange to have this kind of high-level DXILModuleShaderFlagsInfo that we then pull individual members out of to do calculations on.

The computation of the consolidated mask in this code location is specific for top-level library entry metadata. Hence it seems appropriate to be explicitly part of metadata generation.  Shader Flags Analysis Information should not need to incorporate the knowledge of how module and function shader flags mask values are used to compute a consolidated mask for various contexts of metadata generation.

https://github.com/llvm/llvm-project/pull/112967


More information about the llvm-commits mailing list