Protocol Conformance Derivation and Order Stability

windows

(Saleem Abdulrasool) #1

So, I'm chasing down some sorting instabilities since it is odd that the order is different across Windows and Linux (but is mostly harmless). I was looking at IRGen.enum_derived, and it seems that the conformances are being evaluated in a different order:

Linux/macOS sees: Equatable, Hashable
Windows sees: Hashable, Equatable

This results in the witnesses being re-ordered in SILGen, and consequently the IRGen is different. Rather than loosening the tests, @jrose and @Michael_Gottesman felt that it would be better to isolate the causes of the sorting instability.

I found two cases in which I addressed in https://github.com/apple/swift/pull/22308 (not sorting basically gives us the same order on all the targets), however, that didn't impact the derived protocol conformances. I'm not sure where to start chasing down the cause of the re-order here and am looking for some help.

CC: @Douglas_Gregor @Slava_Pestov @Joe_Groff @Michael_Gottesman