[all-commits] [llvm/llvm-project] 2b7472: [DWARFLinker] mark odr candidates inside the same ...

avl-llvm via All-commits all-commits at lists.llvm.org
Tue Jun 28 09:49:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2b747241a6a0180c99dc4e46dbf62791080a9680
      https://github.com/llvm/llvm-project/commit/2b747241a6a0180c99dc4e46dbf62791080a9680
  Author: Alexey Lapshin <a.v.lapshin at mail.ru>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M llvm/include/llvm/DWARFLinker/DWARFLinker.h
    M llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
    M llvm/include/llvm/DWARFLinker/DWARFLinkerDeclContext.h
    M llvm/lib/DWARFLinker/DWARFLinker.cpp
    M llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
    A llvm/test/tools/dsymutil/X86/odr-two-units-in-single-file.test

  Log Message:
  -----------
  [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




More information about the All-commits mailing list