[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 09:55:26 PDT 2019


rudkx added inline comments.


================
Comment at: llvm/include/llvm/Analysis/CallGraph.h:88
+  using DummyNodeMapTy =
+      MapVector<const void *, std::unique_ptr<CallGraphNode>>;
+
----------------
bogner wrote:
> Does this really need to be `void *`? AFAICT it's always `CallBase *` or null. If that's not correct, it'd probably still be better to use `PointerUnion` or something.
These are actually keyed by `MDNode *`. I suspect the intent here was to make it more generally useful for creating dummy nodes mapped from various keys. I will change it to `MDNode *` and it can be generalized in the future if needed.


================
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:
> 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.


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