[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
Fri Aug 25 12:08:41 PDT 2017


ruiu added a comment.

> I don't get this part. Consider, for example, that chunks were just integer values. You're saying that we cannot use sort to segregate them. But it's obviously wrong. Similarly, everything works if chunks are collections of ints, and we're comparing them in lexicographical order. Note that chunk is basically a collection of ints, strings etc. The only hard thing is that dyn_cast, but as we first compare by type, if we get to there, it should either both fail, or both success. What I'm saying is that we know which chunks are equal when writing that comparison function, and can write correct comparison function.

Okay, let's consider chunks [c1, c2, ..., c_n] as integers [1, 2, ..., n]. If we consider their addresses as integers, that makes sense. Now, assume that c2 equals to c3 in terms of ICF, but no other chunks equal to any other chunks.

What Less(c1, c2) and Less(c3, c2) should return? They should be [true, true] or [false, false]. [true, false] is not transitive and that breaks the rule that a comparison function for sort should satisfy. But, how do you return that consistent boolean values?


https://reviews.llvm.org/D36963





More information about the llvm-commits mailing list