KeyPath (test/stdlib/KeyPathMultiModule.swift) of v5 tests failed on s390x. Here is a simplified sample code:
import KeyPathMultiModule_b
class LocalSub: ResilientSub {
final var storedD: String = "zim"
final var storedE: String = "zang"
}
let a = \LocalSub.storedD
let b = \LocalSub.storedE
let cc = a == b // on s390x `cc` is true, but on x86_64 is false
print (" cc =\(cc)")
Debugging this code on both x86_64 and s390x, I found the memory layout of a and b is different on x86_64, but is the same on s390x, which causes the test case failure.
The memory layout should be generated during the compiling.
My question here is what compiler code ( possible related to stdlib/public/core/KeyPath.swift) does generate the memory layout of variable a and b?
Could you please give me clue to fix this issue?
If replace the import KeyPathMultiModule_b with including file test/stdlib/Inputs/KeyPathMultiModule_b.swift, then we get the same output as on x86_64.
It seems that it is not working when build test/stdlib/Inputs/KeyPathMultiModule_b.swift separately on s390x.
Any ideas on this?
It sounds like the bug may have to do with the instantiation of external key path property descriptors then. I suspect that the most likely cause of this problem will be in the runtime implementation for key paths; maybe it's another Int vs Int32 mismatch along the lines of Fix test case regressions on s390x arch by rposts · Pull Request #21841 · apple/swift · GitHub. I would check the key path pattern instantiation code in _walkKeyPathPattern having to do with external references against the code that traverses the instantiated key path object in AnyKeyPath.== to compare them.