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

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 19:10:23 PDT 2024


================
@@ -63,16 +115,53 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
   OS << ";\n";
 }
 
+void DXILModuleShaderFlagsInfo::print(raw_ostream &OS) const {
+  OS << "; Shader Flags mask for Module:\n";
+  ModuleFlags.print(OS);
+  for (auto SF : FuncShaderFlagsVec) {
+    OS << "; Shader Flags mask for Function: " << SF.first->getName() << "\n";
+    SF.second.print(OS);
+  }
+}
+
+const ComputedShaderFlags
+DXILModuleShaderFlagsInfo::getShaderFlagsMask(const Function *Func) const {
+  FuncShaderFlagsMask V{Func, {}};
+  auto Iter = llvm::lower_bound(FuncShaderFlagsVec, V, compareFuncSFPairs);
+  if (Iter == FuncShaderFlagsVec.end()) {
+    Func->getContext().diagnose(DiagnosticInfoShaderFlags(
+        *(Func->getParent()), "Shader Flags information of Function '" +
+                                  Twine(Func->getName()) + "' not found"));
+  }
+  if (Iter->first != Func) {
+    Func->getContext().diagnose(DiagnosticInfoShaderFlags(
+        *(Func->getParent()),
+        "Inconsistent Shader Flags information of Function '" +
+            Twine(Func->getName()) + "' retrieved"));
----------------
bharadwajy wrote:

> I don't understand why this diagnostic exists? lower_bound is defined to return an iterator to a non-end element in the normal case when it isn't found, so this should really be exactly the same case as the one above.

Yes, it was an overly conservative (and redundant) check. Deleted.

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


More information about the llvm-commits mailing list