[PATCH] D104059: [WIP][Attributor] Derive AACallEdges attribute

Kuter Dinel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 14:17:53 PDT 2021


kuter added a comment.

The way `CallGraph` handles callbacks doesn't make sense to me. 
In the `CallGraph::populateCallGraphNode` callbacks are handled by the  `forEachCallbackFunction` function.
like this:

  // Add reference to callback functions.
  forEachCallbackFunction(*Call, [=](Function *CB) {
      Node->addCalledFunction(nullptr, getOrInsertFunction(CB));
  });

Which uses the `AbstractCallSite::getCallbackUses` and checks if the `Use` is a function.
The source of the `AbstractCallSite::getCallbackUses` is given below.

  void AbstractCallSite::getCallbackUses(       
      const CallBase &CB, SmallVectorImpl<const Use *> &CallbackUses) { 
    const Function *Callee = CB.getCalledFunction(); 
    if (!Callee)                                                      
      return; 
  
     ....                                                              
  }    

`CB.getCalledFunction` returns null if the call is indirect.  And a callback is indirect, right ?
Also the `getCallbackUses` uses the callback <https://llvm.org/docs/LangRef.html#callback-metadata> metadata which is intended for the function definitions rather than calls.

Am I misunderstanding something ?  What `CallGraph` does doesn't seem correct to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104059/new/

https://reviews.llvm.org/D104059



More information about the llvm-commits mailing list