[llvm] [FuncAttrs] Relax norecurse attribute inference (PR #139943)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 09:26:37 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) {
----------------
david-arm wrote:
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 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?
https://github.com/llvm/llvm-project/pull/139943
More information about the llvm-commits
mailing list