1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/lib
Fangrui Song 875f91ef4b [Internalize] Rename instead of removal if a to-be-internalized comdat has more than one member
Beside the `comdat any` deduplication feature, instrumentations use comdat to
establish dependencies among a group of sections, to prevent section based
linker garbage collection from discarding some members without discarding all.
LangRef acknowledges this usage with the following wording:

> All global objects that specify this key will only end up in the final object file if the linker chooses that key over some other key.

On ELF, for PGO instrumentation, a `__llvm_prf_cnts` section and its associated
`__llvm_prf_data` section are placed in the same GRP_COMDAT group.  A
`__llvm_prf_data` is usually not referenced and expects the liveness of its
associated `__llvm_prf_cnts` to retain it.

The `setComdat(nullptr)` code (added by D10679) in InternalizePass can break the
use case (a `__llvm_prf_data` may be dropped with its associated `__llvm_prf_cnts` retained).
The main goal of this patch is to fix the dependency relationship.

I think it makes sense for InternalizePass to internalize a comdat and thus
suppress the deduplication feature, e.g. a relocatable link of a regular LTO can
create an object file affected by InternalizePass.
If a non-internal comdat in a.o is prevailed by an internal comdat in b.o, the
a.o references to the comdat definitions will be non-resolvable (references
cannot bind to STB_LOCAL definitions in b.o).

On PE-COFF, for a non-external selection symbol, deduplication is naturally
suppressed with link.exe and lld-link. However, this is fuzzy on ELF and I tend
to believe the spec creator has not thought about this use case (see D102973).

GNU ld and gold are still using the "signature is name based" interpretation.
So even if D102973 for ld.lld is accepted, for portability, a better approach is
to rename the comdat. A comdat with one single member is the common case,
leaving the comdat can waste (sizeof(Elf64_Shdr)+4*2) bytes, so we optimize by
deleting the comdat; otherwise we rename the comdat.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D103043
2021-05-25 14:15:27 -07:00
..
Analysis [NFC] Fix 'unused' warning 2021-05-25 12:23:57 -07:00
AsmParser Revert "[OpaquePtr] Make atomicrmw work with opaque pointers" 2021-05-25 10:14:58 -07:00
BinaryFormat
Bitcode Revert "[OpaquePtr] Make atomicrmw work with opaque pointers" 2021-05-25 10:14:58 -07:00
Bitstream
CodeGen [SelectionDAG] Propagate scoped AA metadata when lowering mem intrinsics. 2021-05-25 14:42:26 -04:00
DebugInfo Add support for DWARF embedded source to llvm-symbolizer. 2021-05-20 21:40:28 +04:00
Demangle [Demangle][Rust] Parse function signatures 2021-05-22 11:49:08 +02:00
DWARFLinker [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
ExecutionEngine [JITLink][MachO][arm64] Build GOT entries for defined symbols too. 2021-05-25 12:19:09 -07:00
Extensions
FileCheck
Frontend [NFC][OMP] Fix 'unused' warning 2021-05-24 17:14:38 -07:00
Fuzzer
FuzzMutate
InterfaceStub
IR Revert "[OpaquePtr] Make atomicrmw work with opaque pointers" 2021-05-25 10:14:58 -07:00
IRReader
LineEditor
Linker Linker: Avoid scheduling the link of a global value twice due to an alias 2021-04-28 13:22:10 -07:00
LTO [SampleFDO] New hierarchical discriminator for Flow Sensitive SampleFDO 2021-05-18 16:23:43 -07:00
MC [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
MCA [MCA][RegisterFile] Refactor the move elimination logic to address PR50258. 2021-05-08 18:10:35 +01:00
Object [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
ObjectYAML [AMDGPU] Add gfx1034 target 2021-05-13 14:25:18 -04:00
Option
Passes Revert "[LoopUnrollAndJam] Change LoopUnrollAndJamPass to LoopNest pass" 2021-05-25 11:39:49 +09:00
ProfileData [CoverageMapping] Handle gaps in counter IDs for source-based coverage 2021-05-19 10:46:38 -07:00
Remarks
Support [SystemZ][z/OS] Implement getHostCPUName for z/OS 2021-05-25 11:18:12 -04:00
TableGen [TableGen] Make the NUL character invalid in .td files 2021-05-13 10:17:45 -04:00
Target [Hexagon] Remove unused function from HexagonISelDAGToDAGHVX.cpp 2021-05-25 14:47:15 -05:00
Testing
TextAPI [TextAPI] Reformat llvm_unreachable message 2021-05-11 09:59:26 -07:00
ToolDrivers
Transforms [Internalize] Rename instead of removal if a to-be-internalized comdat has more than one member 2021-05-25 14:15:27 -07:00
WindowsManifest
XRay
CMakeLists.txt