[PATCH] D125469: [DWARFLinker] mark odr candidates inside the same object file.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 07:56:07 PDT 2022


avl created this revision.
avl added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a subscriber: hiraditya.
Herald added a project: All.
avl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is extracted from D86539 <https://reviews.llvm.org/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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125469

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125469.428946.patch
Type: text/x-patch
Size: 16428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220512/deb52cdd/attachment.bin>


More information about the llvm-commits mailing list