[Mlir-commits] [mlir] [mlir][CallGraph] Add edges for callable symbol references in CallGraph (PR #116177)
Haocong Lu
llvmlistbot at llvm.org
Sun Dec 1 22:35:41 PST 2024
Luhaocong wrote:
> > Yes, I echo the same comments as @zero9178. This doesn't look correct to me generally, a function being public isn't the only indication something can be referenced externally. Non-symbol callables could be called externally, so could symbols with their address taken. To be able to answer that question for symbol operations you'd need a deeper analysis of the program state (i.e. seeing what things reference the symbol and possibly how they reference it)
>
> Thanks for your professional guidance @zero9178 @River707 . I will refer to the analysis in `struct CGUseList` and LLVM's implements, then try building a more complete CallGraph.
Hi @zero9178 @River707 , this is first version to improve mlir CallGraph, I introduce a reference edge if any operation references a callable symbol, which refers to many design concepts of `LazyCallGraph` in LLVM : https://github.com/llvm/llvm-project/commit/bf71a34eb9e25c6080d5058a553dbcb75676ff95. But I retain the entry and exit nodes, and add references counter for each callgraph node, which is easy to find a dead node.
In inliner pass, `struct CGUseList` is removed, so the inlined region always should clone to keep result correct. And the clean work for dead nodes will be done at the end of inliner pass, which use a new CallGraph after inline.
Full dump files of two test cases is here:
[dump-test-callgraph.txt](https://github.com/user-attachments/files/17973545/dump-test-callgraph.txt)
[dump-inlining-dce.mlir.txt](https://github.com/user-attachments/files/17973544/dump-inlining-dce.mlir.txt)
https://github.com/llvm/llvm-project/pull/116177
More information about the Mlir-commits
mailing list