[PATCH] Optimize the layout pass.

Rui Ueyama ruiu at google.com
Fri Dec 6 20:32:27 PST 2013


Hi Bigcheese,

The comparator used in the layout pass has many calls of map::find(). Because
std::sort runs the comparator N*log2(N) times, the maps are looked up with the
same key again and again. The map lookup is not a very fast operation. It made
the pass slow.

This patch eliminates the duplicate map lookups using decorate-sort-undecorate
idiom. The pass used to take 1.1 seconds when linking LLD with LLD on Windows,
but it now takes only 0.3 seconds. Overall performance gain in that case is from
6.1 seconds to 5.2 seconds.

http://llvm-reviews.chandlerc.com/D2358

Files:
  include/lld/Passes/LayoutPass.h
  lib/Passes/LayoutPass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2358.1.patch
Type: text/x-patch
Size: 7645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131206/aef1a5bd/attachment.bin>


More information about the llvm-commits mailing list