[PATCH] D105907: [CallGraphSection] Add call graph section options and documentation

Matt Morehouse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 14 13:06:09 PDT 2021


morehouse added a subscriber: MaskRay.
morehouse added a comment.

We should also tests for the new flags in clang/test/Driver/clang_f_opts.c.



================
Comment at: clang/docs/CallGraphSection.rst:58
+
+A type identifier may be repeated in different entries. The id value 0 is
+reserved for unknown and used for indirect targets with unknown type.
----------------
necipfazil wrote:
> morehouse wrote:
> > Why would a type ID be repeated?
> Current implementation [1] creates a call graph section per function comdat group, to which the assembly printer writes the call graph entries related to the function.  This is done to enable dead-stripping of call graph entries.  Consequently, the callsites from two functions may share the same type ID but appear as distinct entries as they will be written to distinct sections.  Although they are merged to a single section by the linker, the type ID repetition persists since the linker only concatenates.
> 
> Eliminating this to ensure that type IDs are not repeated should only decrease the binary size overhead.
> 
> [1] https://reviews.llvm.org/D105916 , see MCObjectFileInfo::getCallGraphSection()
Indeed, this is a tricky problem.  The current solution is probably OK, but maybe we can simplify the callgraph section format in light of this solution.  e.g.,
```
Format version, Type id, IsFuncEntry, PC
  0, NumericTypeId(foo), 1, FuncEntryPc(foo)
  0, NumericTypeId(foo), 0, CallSitePc(fp_foo())
  0, NumericTypeId(main), 1, FuncEntryPc(main)
```

cc @MaskRay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105907



More information about the cfe-commits mailing list