[PATCH] D85579: [ELF] --gdb-index: skip SHF_GROUP .debug_info

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 03:28:23 PDT 2020


grimar added inline comments.


================
Comment at: lld/ELF/SyntheticSections.cpp:2889
+    nameAttrs[i] = readPubNamesAndTypes<ELFT>(dobj, chunks[i].compilationUnits);
   });
 
----------------
Previously, `parallelForEachN` loop assumed that there is a one `.debug_info` section in an object.
Now it is not true and parallelizing for sections by itself (instead of doing it for files) doesn't look optimal.

Also, you do not need to build a list sections, because you are not using them (you call `dobj.getInfoSection();` anyways), so
you only need a list of files to work with.

With that we can have a simpler code:

```
  SetVector<ObjFile<ELFT> *> files;
  for (InputSectionBase *s : inputSections) {
    InputSection *isec = dyn_cast<InputSection>(s);
    if (!isec)
      continue;
    // .debug_gnu_pub{names,types} are useless in executables.
    // They are present in input object files solely for creating
    // a .gdb_index. So we can remove them from the output.
    if (s->name == ".debug_gnu_pubnames" || s->name == ".debug_gnu_pubtypes")
      s->markDead();
    else if (isec->name == ".debug_info")
      files.insert(isec->getFile<ELFT>());
  }

  std::vector<GdbChunk> chunks(files.size());
  std::vector<std::vector<NameAttrEntry>> nameAttrs(files.size());

  parallelForEachN(0, files.size(), [&](size_t i) {
    // To keep memory usage low, we don't want to keep cached DWARFContext, so
    // avoid getDwarf() here.
    DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(files[i]));
    auto &dobj = static_cast<const LLDDwarfObj<ELFT> &>(dwarf.getDWARFObj());
...
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85579/new/

https://reviews.llvm.org/D85579



More information about the llvm-commits mailing list