[PATCH] D36963: Use sorting instead of a lot of stable_partitions for `ICF::segregate` function

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 16:20:24 PDT 2017


ruiu added a comment.

So, I thought about the algorithm again for a while, and I believe I found a flaw in using `sort` in ICF.

To see that, assume chunks A, B, C, D where A = C but all the others are distinctive. In order to use `sort`, you have to define a `<` relation for the chunks, which at least satisfy `A < C == false` and `C < A == false`. For other chunks, `<` relation can be arbitrary as long as it is transitive and asymmetric.

Consider a relation A<B<C<D. This is not transitive because although A=C, both A<B and B<C are true. So, this `<` relation is not OK.

Thus, a valid `<` relation must respect chunk equality. For example, a relation B<A<C<D is valid. In other words, a valid `<` must know A=C before doing anything. But this is not doable because, if we do know that before defining a `<` relation, we could just simply use that fact to find all chunks that are equal to a given chunk. That means `sort` is not usable in ICF.

What do you think?


https://reviews.llvm.org/D36963





More information about the llvm-commits mailing list