[PATCH] D39339: [CallGraph] Refine call graph for indirect calls with !callees metadata
Mark Lacey via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 10:13:26 PDT 2019
rudkx added inline comments.
================
Comment at: llvm/lib/Analysis/CallGraph.cpp:182-189
+ CGN = llvm::make_unique<CallGraphNode>(nullptr);
+ for (const MDOperand &Op : Callees->operands())
+ if (auto *MDConstant = mdconst::extract_or_null<Constant>(Op)) {
+ auto *F = cast<Function>(MDConstant);
+
+ assert(!F->isIntrinsic());
+ CGN->addCalledFunction(nullptr, getOrInsertFunction(F));
----------------
bogner wrote:
> rudkx wrote:
> > bogner wrote:
> > > Maybe I'm misreading this, but isn't `CGN == nullptr` here, given the assignment just above?
> > `GCN` should be a non-null `CallGraphNode` holding a `Function *` that has a `nullptr` value.
> Ah right. In that case, doesn't the node get destroyed when the `unique_ptr` goes out of scope here? You may have meant to use `.release()`, but in that case who owns this object?
`GCN` is a reference to the `unique_ptr<T>` in the map, and `unique_ptr` has a move assignment operator, so it transfers ownership to the map node right after it is allocated.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D39339/new/
https://reviews.llvm.org/D39339
More information about the llvm-commits
mailing list