[PATCH] D105917: [llvm-objdump][CallGraphSection] Extract call graph information from binary

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 20 09:16:49 PDT 2021


morehouse added inline comments.


================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:1093
 
+static raw_ostream &disAsmOuts() { return QuietDisasm ? nulls() : outs(); }
+
----------------



================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:1471
+              // operand is an indirect call. Otherwise, it is a direct call
+              // with exactly one immediate operand.
+              bool HasRegOperand = false;
----------------
Is `MIA->isIndirectBranch() && MIA->isCall()` sufficient to detect an indirect call?


================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2156-2158
+    size_t Size = CGSecContents.size() / sizeof(uint64_t);
+    auto *It = (const uint64_t *const)CGSecContents.data();
+    const auto *End = (const uint64_t *const)CGSecContents.data() + Size;
----------------



================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2220-2226
+    auto ICallWithoutTypeIdCount =
+        IndirectCallSites.size() - ICallWithTypeIdCount;
+    if (ICallWithoutTypeIdCount)
+      reportWarning("callgraph section does not have type ids for " +
+                        std::to_string(ICallWithoutTypeIdCount) +
+                        " indirect calls",
+                    Obj->getFileName());
----------------



================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2228-2242
+    uint64_t NotListedCount = 0;
+    for (const auto &El : FuncInfo)
+      NotListedCount += El.second.Kind == NOT_LISTED;
+    if (NotListedCount)
+      reportWarning("callgraph section does not have information for " +
+                        std::to_string(NotListedCount) + " functions",
+                    Obj->getFileName());
----------------
Nit: the above two loops could be combined.


================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2250-2266
+    // Not listed functions: print as indirect target with unknown id.
+    if (NotListedCount) {
+      for (const auto &El : FuncInfo) {
+        auto FuncEntryPc = El.first;
+        if (El.second.Kind == NOT_LISTED)
+          outs() << " " << format("%lx", FuncEntryPc);
+      }
----------------
Nit: the above two loops could be combined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105917



More information about the llvm-commits mailing list