[llvm] [DirectX] Propagate shader flags mask of callees to callers (PR #118306)
S. Bharadwaj Yadavalli via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 6 12:52:35 PST 2024
================
@@ -46,21 +49,79 @@ static void updateFunctionFlags(ComputedShaderFlags &CSF,
}
}
-void ModuleShaderFlags::initialize(const Module &M) {
- // Collect shader flags for each of the functions
- for (const auto &F : M.getFunctionList()) {
- if (F.isDeclaration())
+void ModuleShaderFlags::initialize(Module &M) {
+ CallGraph CG(M);
+
+ // Compute Shader Flags Mask for all functions using post-order visit of SCC
+ // of the call graph.
+ for (scc_iterator<CallGraph *> SCCI = scc_begin(&CG); !SCCI.isAtEnd();
+ ++SCCI) {
+ const std::vector<CallGraphNode *> &CurSCC = *SCCI;
+
+ // Union of shader masks of all functions in CurSCC
+ ComputedShaderFlags SCCSF;
+ for (CallGraphNode *CGN : CurSCC) {
+ Function *F = CGN->getFunction();
+ if (!F)
+ continue;
+
+ if (F->isDeclaration())
+ continue;
+
+ ComputedShaderFlags CSF;
+ for (const auto &BB : *F)
+ for (const auto &I : BB)
+ updateFunctionFlags(CSF, I);
+ // Insert shader flag mask for function F
+ FunctionFlags.insert({F, CSF});
+ // Update combined shader flags mask for all functions of the module
+ CombinedSFMask.merge(CSF);
----------------
bharadwajy wrote:
> Since we have to calculate SCCSF anyways, we can hoist the merge of the combined mask out of this loop
Changed.
https://github.com/llvm/llvm-project/pull/118306
More information about the llvm-commits
mailing list