[PATCH] D87063: [BitcodeReader] Fix O(N^2) in placeholder replacement algorithm.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 15:48:53 PDT 2020


efriedma created this revision.
efriedma added reviewers: mehdi_amini, spatel, jdoerfert.
Herald added subscribers: mgrang, hiraditya.
Herald added a project: LLVM.
efriedma requested review of this revision.

The key here is to make sure we never RAUW a constant that's used by other constants. Since Constants form a DAG, this is just a matter of constructing the replacements and RAUW'ing the constants in the right order.  Most of the complexity here is computing that order.

One thing that's a bit unfortunate about this algorithm is that it creates a couple DenseMaps which have only entry per replaced constant. So it uses significantly more memory than the previous algorithm.  It might be possible to optimize this to some extent, but hopefully this doesn't matter in practice.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47395 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87063

Files:
  llvm/lib/Bitcode/Reader/ValueList.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87063.289595.patch
Type: text/x-patch
Size: 7626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200902/1618303f/attachment.bin>


More information about the llvm-commits mailing list