[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

Shaw Young via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jul 15 12:58:31 PDT 2024


================
@@ -50,6 +54,59 @@ llvm::cl::opt<bool> ProfileUseDFS("profile-use-dfs",
 namespace llvm {
 namespace bolt {
 
+void CallGraphMatcher::addBFCGEdges(BinaryContext &BC,
+                                    yaml::bolt::BinaryProfile &YamlBP,
+                                    BinaryFunction *BF) {
+  for (const BinaryBasicBlock &BB : BF->blocks()) {
+    for (const MCInst &Instr : BB) {
+      if (!BC.MIB->isCall(Instr))
+        continue;
+      const MCSymbol *CallSymbol = BC.MIB->getTargetSymbol(Instr);
+      if (!CallSymbol)
+        continue;
+      BinaryData *BD = BC.getBinaryDataByName(CallSymbol->getName());
+      if (!BD)
+        continue;
+      BinaryFunction *CalleeBF = BC.getFunctionForSymbol(BD->getSymbol());
----------------
shawbyoung wrote:

I believe it's possible to calls to functions pointers in the profile as well as the binary

https://github.com/llvm/llvm-project/pull/98125


More information about the llvm-branch-commits mailing list