[llvm] [FuncAttrs] Relax norecurse attribute inference (PR #139943)
Usha Gupta via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 10:15:19 PDT 2025
================
@@ -2059,8 +2059,49 @@ static void inferAttrsFromFunctionBodies(const SCCNodeSet &SCCNodes,
AI.run(SCCNodes, Changed);
}
+/// Returns true if N or any function it (transitively) calls makes a call
+/// to an unknown external function: either an indirect call or a declaration
+/// without the NoCallback attribute.
+static bool callsUnknownExternal(LazyCallGraph::Node *N) {
+ std::deque<LazyCallGraph::Node *> Worklist;
+ DenseSet<LazyCallGraph::Node *> Visited;
+ Worklist.push_back(N);
+ Visited.insert(N);
+
+ while (!Worklist.empty()) {
+ auto *Cur = Worklist.front();
+ Worklist.pop_front();
+
+ Function &F = Cur->getFunction();
+ for (auto &BB : F) {
----------------
usha1830 wrote:
Thanks for looking into it.
> Is there perhaps already a utility routine that can return a list of all calls made by a Function? Or could we make the same check in the loop below that looks at all the edges?
I think if I populate the edges early, I can use the calls() function instead of iterating over every instruction in every BB. I will refactor these loops.
>I took a look at CalleeInfo in llvm/include/llvm/IR/ModuleSummaryIndex.h and it doesn't have any information about callbacks, but perhaps we could add one?
Yeah. I can look at that too.
https://github.com/llvm/llvm-project/pull/139943
More information about the llvm-commits
mailing list