[llvm] [llvm][AsmPrinter] Call graph section format. (PR #159866)
Prabhu Rajasekaran via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 17:11:06 PDT 2025
================
@@ -0,0 +1,29 @@
+# .callgraph Section Layout
+
+The `.callgraph` section is used to store call graph information for each function, which can be used for post-link analyses and optimizations. The section contains a series of records, with each record corresponding to a single function.
+
+For efficiency, we make a distinction between direct and indirect call data. For direct calls, we record the unique callees, not the location of each individual call. For indirect calls, we record the location of each call site and the type ID of the callee. Post link analysis scripts which utilize this information to reconstuct the program call graph can potentially receive more information regarding indirect callsites from the user to improve the precision of the call graph.
+
+## Per Function Record Layout
+
+Each record in the `.callgraph` section has the following binary layout:
+
+| Field | Type | Size (bits) | Description |
+| ---------------------------- | ------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
+| Format Version | `uint32_t` | 32 | The version of the record format. The current version is 0. |
+| Function Entry PC | `uintptr_t` | 32/64 | The address of the function's entry point. |
+| Function Kind | `uint8_t` | 8 | An enum indicating the function's properties (e.g., if it's an indirect call target). |
+| Function Type ID | `uint64_t` | 64 | The type ID of the function. This field is **only** present if `Function Kind` is `INDIRECT_TARGET_KNOWN_TID`. |
----------------
Prabhuk wrote:
The layout is updated to remove optional fields. PTAL.
https://github.com/llvm/llvm-project/pull/159866
More information about the llvm-commits
mailing list