1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/Object/multiple-sections.yaml
Alexander Yermolovich d12ae1eaf8 [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
2021-06-24 09:09:33 -07:00

68 lines
1.8 KiB
YAML

# RUN: yaml2obj %s -o %t.o
# RUN: llvm-readobj -a --cg-profile --addrsig %t.o | FileCheck %s
# Test that multiple sections with the same type does not trigger an error.
# CHECK: ElfHeader {
# CHECK: VersionSymbols [
# CHECK: VersionDefinitions [
# CHECK: VersionRequirements [
# CHECK: CGProfile [
# CHECK: CGProfile [
# CHECK: Addrsig [
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .symtab2
Type: SHT_SYMTAB
Link: .strtab
Content: ''
EntSize: 24
- Name: .versym
Type: SHT_GNU_versym
Entries: [ 0 ]
Link: .dynsym
- Name: .versym2
Type: SHT_GNU_versym
Entries: [ 0 ]
Link: .dynsym
- Name: .verdef
Type: SHT_GNU_verdef
Info: 0x0000000000000000
Entries:
- Name: .verdef2
Type: SHT_GNU_verdef
Info: 0x0000000000000000
Entries:
- Name: .verneed
Type: SHT_GNU_verneed
Info: 0x0000000000000000
Dependencies:
- Name: .verneed2
Type: SHT_GNU_verneed
Info: 0x0000000000000000
Dependencies:
- Name: .llvm.call-graph-profile
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Content: ''
EntSize: 8
- Name: .llvm.call-graph-profile2
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Content: ''
EntSize: 8
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Content: ''
- Name: .llvm_addrsig2
Type: SHT_LLVM_ADDRSIG
Content: ''
Symbols:
- Name: f
DynamicSymbols: []
...