[all-commits] [llvm/llvm-project] a224c5: [LLD][LLVM] CG Graph profile using relocations
Alexander Yermolovich via All-commits
all-commits at lists.llvm.org
Thu Jun 24 09:09:58 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a224c5199b327ed0efcdcd87b6dbf950cf4d9ee1
https://github.com/llvm/llvm-project/commit/a224c5199b327ed0efcdcd87b6dbf950cf4d9ee1
Author: Alexander Yermolovich <ayermolo at fb.com>
Date: 2021-06-24 (Thu, 24 Jun 2021)
Changed paths:
M lld/ELF/Driver.cpp
M lld/ELF/InputFiles.cpp
M lld/ELF/InputFiles.h
M llvm/include/llvm/BinaryFormat/ELF.h
M llvm/include/llvm/MC/MCELFStreamer.h
M llvm/include/llvm/Object/ELFTypes.h
M llvm/include/llvm/ObjectYAML/ELFYAML.h
M llvm/lib/MC/ELFObjectWriter.cpp
M llvm/lib/MC/MCELFStreamer.cpp
M llvm/lib/ObjectYAML/ELFEmitter.cpp
M llvm/lib/ObjectYAML/ELFYAML.cpp
M llvm/test/MC/ELF/cgprofile.s
M llvm/test/Object/multiple-sections.yaml
M llvm/test/tools/llvm-readobj/ELF/call-graph-profile.test
M llvm/test/tools/llvm-readobj/ELF/demangle.test
M llvm/test/tools/obj2yaml/ELF/call-graph-profile-section.yaml
M llvm/test/tools/yaml2obj/ELF/call-graph-profile-section.yaml
M llvm/test/tools/yaml2obj/ELF/section-headers-exclude.yaml
M llvm/tools/llvm-readobj/ELFDumper.cpp
M llvm/tools/obj2yaml/elf2yaml.cpp
Log Message:
-----------
[LLD][LLVM] CG Graph profile using relocations
Currently when .llvm.call-graph-profile is created by llvm it explicitly encodes the symbol indices. This section is basically a black box for post processing tools. For example, if we run strip -s on the object files the symbol table changes, but indices in that section do not. In non-visible behavior indices point to wrong symbols. The visible behavior indices point outside of Symbol table: "invalid symbol index".
This patch changes the format by using R_*_NONE relocations to indicate the from/to symbols. The Frequency (Weight) will still be in the .llvm.call-graph-profile, but symbol information will be in relocation section. In LLD information from both sections is used to reconstruct call graph profile. Relocations themselves will never be applied.
With this approach post processing tools that handle relocations correctly work for this section also. Tools can add/remove symbols and as long as they handle relocation sections with this approach information stays correct.
Doing a quick experiment with clang-13.
The size went up from 107KB to 322KB, aggregate of all the input sections. Size of clang-13 binary is ~118MB. For users of -fprofile-use/-fprofile-sample-use the size of object files will go up slightly, it will not impact final binary size.
Reviewed By: jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D104080
More information about the All-commits
mailing list