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

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 22 00:35:01 PST 2024


================
@@ -63,20 +106,64 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
   OS << ";\n";
 }
 
+/// Get the combined shader flag mask of all module functions.
+const ComputedShaderFlags DXILModuleShaderFlagsInfo::getCombinedFlags() const {
+  return CombinedSFMask;
+}
+
+/// Return the shader flags mask of the specified function Func, if one exists.
+/// else an error
+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");
+  }
----------------
bogner wrote:

The only way to have this fail is if we've invalidated the analysis (and failed to tell the pass manager) or we're trying to use it wrong. This should just be an assert.

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


More information about the llvm-commits mailing list