[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"));
----------------
bharadwajy wrote:
> When can this happen? Does it actually indicate a bug in the code or is there some input that someone could generate that would cause this diagnostic to get emitted?
Since this is the method used by other passes to query for shader flags mask for a function, a failed query is reported as a diagnostic. If the preference is to return a value indicating an error - allowing the caller to determine the consequences - I am open to that as well.
https://github.com/llvm/llvm-project/pull/112967
More information about the llvm-commits
mailing list