[llvm] [DirectX] Propagate shader flags mask of callees to callers (PR #118306)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 10:15:17 PST 2024
================
@@ -61,6 +66,21 @@ void ModuleShaderFlags::initialize(const Module &M) {
CombinedSFMask.merge(CSF);
}
llvm::sort(FunctionFlags);
+ // Propagate shader flag mask of functions to their callers.
+ while (!WorkList.empty()) {
+ const Function *Func = WorkList.pop_back_val();
+ if (!Func->user_empty()) {
+ const ComputedShaderFlags &FuncSF = getFunctionFlags(Func);
+ // Update mask of callers with that of Func
+ for (const auto User : Func->users()) {
+ if (const CallInst *CI = dyn_cast<CallInst>(User)) {
+ const Function *Caller = CI->getParent()->getParent();
+ if (mergeFunctionShaderFlags(Caller, FuncSF))
+ WorkList.push_back(Caller);
----------------
bogner wrote:
Ah, since this is an analysis and it's used by module passes we won't be able to simply convert to an SCC pass. As is, we may need to construct the call graph manually to do this in the more efficient way. It's probably fine to just construct a [CallGraph](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Analysis/CallGraph.h#L66) and use [SCCIterator](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/SCCIterator.h#L40) to process the functions in post order.
https://github.com/llvm/llvm-project/pull/118306
More information about the llvm-commits
mailing list