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

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 12:59:08 PST 2024


================
@@ -63,17 +105,57 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
   OS << ";\n";
 }
 
+const SmallVector<std::pair<Function const *, ComputedShaderFlags>> &
+DXILModuleShaderFlagsInfo::getFunctionFlags() const {
+  return FunctionFlags;
+}
+
+const ComputedShaderFlags &DXILModuleShaderFlagsInfo::getModuleFlags() const {
+  return ModuleFlags;
+}
+
+Expected<const ComputedShaderFlags &>
+DXILModuleShaderFlagsInfo::getShaderFlagsMask(const Function *Func) const {
+  std::pair<Function const *, ComputedShaderFlags> V{Func, {}};
+  const auto Iter = llvm::lower_bound(FunctionFlags, V);
+  if (Iter == FunctionFlags.end() || Iter->first != Func) {
+    return createStringError("Shader Flags information of Function '" +
+                             Func->getName() + "' not found");
+  }
+  return Iter->second;
+}
+
 AnalysisKey ShaderFlagsAnalysis::Key;
 
-ComputedShaderFlags ShaderFlagsAnalysis::run(Module &M,
-                                             ModuleAnalysisManager &AM) {
-  return ComputedShaderFlags::computeFlags(M);
+DXILModuleShaderFlagsInfo ShaderFlagsAnalysis::run(Module &M,
+                                                   ModuleAnalysisManager &AM) {
+  DXILModuleShaderFlagsInfo MSFI;
+  MSFI.initialize(M);
+  return MSFI;
+}
+
+bool ShaderFlagsAnalysisWrapper::runOnModule(Module &M) {
+  MSFI.initialize(M);
----------------
bharadwajy wrote:

Replaced `initialize()` with a constructor.

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


More information about the llvm-commits mailing list