llvm-project/llvm/lib/DWARFLinker
Alexey Lapshin 2b747241a6 [DWARFLinker] mark odr candidates inside the same object file.
This patch is extracted from D86539.

Current implementation of lookForDIEsToKeep() function skips types
duplications basing on the getCanonicalDIEOffset() data:

```
if (AttrSpec.Form != dwarf::DW_FORM_ref_addr && (UseOdr || IsModuleRef) &&
    Info.Ctxt &&
    Info.Ctxt != ReferencedCU->getInfo(Info.ParentIdx).Ctxt &&
    Info.Ctxt->getCanonicalDIEOffset() && isODRAttribute(AttrSpec.Attr))  <<<<<
  continue;
```

But that field is set after all compile units inside object file are processed:

```
for (auto &CurrentUnit : OptContext.CompileUnits)
  lookForDIEsToKeep(.., &CurrentUnit, ..);  // check CanonicalDIEOffset

DIECloner.cloneAllCompileUnits(); // set CanonicalDIEOffset
```

Thus, if the object file contains several compilation units - types would
not be deduplicated. The above solution works well for the case when the object file
contains only one compilation unit. But if the object file contains several compilation
units then types would not be deduplicated between these compilation units.

This patch changes the algorithm so that types were deduplicated between
compilation units from the same object file.

It produces binary incompatible output for the cases when several compilation units
are located inside the same object file.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D125469
2022-06-28 19:48:49 +03:00
..
CMakeLists.txt [DWARFLinker] Link against BinaryFormat 2021-01-08 18:57:36 -08:00
DWARFLinker.cpp [DWARFLinker] mark odr candidates inside the same object file. 2022-06-28 19:48:49 +03:00
DWARFLinkerCompileUnit.cpp [DWARFLinker] mark odr candidates inside the same object file. 2022-06-28 19:48:49 +03:00
DWARFLinkerDeclContext.cpp Cleanup includes: DebugInfo & CodeGen 2022-03-12 17:26:40 +01:00
DWARFStreamer.cpp [MC] De-capitalize SwitchSection. NFC 2022-06-10 22:50:55 -07:00