[llvm] [SHT_LLVM_FUNC_MAP][ObjectYaml]Introduce function address map section and emit dynamic instruction count(ObjectYaml part) (PR #124332)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 00:34:39 PST 2025


================
@@ -535,6 +535,27 @@ Example of BBAddrMap with PGO data:
    .uleb128  1000                         # BB_3 basic block frequency (only when enabled)
    .uleb128  0                            # BB_3 successors count (only enabled with branch probabilities)
 
+``SHT_LLVM_FUNC_MAP`` Section (function address map)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+This section stores the mapping from the binary address of function to its
+related metadata features. It is used to emit function-level analysis data and
+can be enabled through ``--func-map`` option. The fields are encoded in the
+following format:
+
+#. A version number byte used for backward compatibility.
----------------
jh7370 wrote:

> The only missing part is how to assign zero addresses to sections corresponding to discarded functions (without making changes in the linker).

That's easy: you don't need to do anything! By default, the linker leaves these references as 0. However, I should point out that it is legitimate to have functions at address 0 in an ELF, so, depending on the platform, you might need to be careful of that. LLD has an option for assigning a different value for such references to debug sections, but I don't know if it applies more generally or is specific to DWARF without looking it up. There might be other clever techniques you could use, but I'm not especially clear on what those might be.

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


More information about the llvm-commits mailing list