[PATCH] D58296: [llvm-objcopy] Make removeSectionReferences batched

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 15 11:28:06 PST 2019

rupprecht created this revision.
rupprecht added reviewers: MaskRay, jhenderson, jakehehrlich, alexshap.
Herald added subscribers: llvm-commits, jdoerfert, mgrang, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Removing a large number of sections from a file with a lot of symbols can have abyssmal (i.e. O(n^2)) performance, e.g. when running `--only-section` to extract one section out of a large file.

This comes from iterating over all symbols in the symbol table each time we remove a section, to remove references to the section we just removed.
Instead, do just one pass of symbol removal by passing a sorted list of all the sections we'd like to remove references to.

This adds another compressed large test object (3.3M compressed, 30M uncompressed), like many-sections.o.gz, but with more symbols added to reproduce an internal failure. On my machine, running `objcopy -j .keep_me huge-input.o /tmp/foo.o` takes .3s with GNU objcopy, 1.3s with an updated llvm-objcopy, and 7+ minutes with llvm-objcopy prior to this patch.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58296.187053.patch
Type: text/x-patch
Size: 7554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190215/af22c897/attachment-0001.bin>

More information about the llvm-commits mailing list