diff options
author | Rui Ueyama <ruiu@google.com> | 2015-09-04 21:35:54 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-09-04 21:35:54 +0000 |
commit | ef907ec82d7b90df87dee727a3c61746ef89d525 (patch) | |
tree | 212afb7246c7fec1fd81d7a3ec0533946b2e56ca /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 3a03fabdd06dd92b7e6e0226c3109b0a49d36b16 (diff) | |
download | bcm5719-llvm-ef907ec82d7b90df87dee727a3c61746ef89d525.tar.gz bcm5719-llvm-ef907ec82d7b90df87dee727a3c61746ef89d525.zip |
COFF: Implement a better algorithm for ICF.
Identical COMDAT Folding is a feature to merge COMDAT sections
by contents. Two sections are considered the same if their contents,
relocations, attributes, etc, are all the same.
An interesting fact is that MSVC linker takes "iterations" parameter
for ICF because the algorithm they are using is iterative. Merging
two sections could make more sections to be mergeable because
different relocations could now point to the same section. ICF is
repeated until we get a convergence (until no section can be merged).
This algorithm is not fast. Usually it needs three iterations until a
convergence is obtained.
In the new algorithm implemented in this patch, we consider sections
and relocations as a directed acyclic graph, and we try to merge
sections whose outdegree is zero. Sections with outdegree zero are then
removed from the graph, which makes other sections to have outdegree
zero. We repeat that until all sections are processed. In this
algorithm, we don't iterate over the same sections many times.
There's an apparent issue in the algorithm -- the section graph is
not guaranteed to be acyclic. It's actually pretty often cyclic.
So this algorithm cannot eliminate all possible duplicates.
That's OK for now because the previous algorithm was not able to
eliminate cycles too. I'll address the issue in a follow-up patch.
llvm-svn: 246878
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions