<html><body><p><font size="2">Hi Slava & Joe,</font><br><br><font size="2">Thank you for the response.</font><br><br><font size="2">The failed test case is "generic instantiation" of KeyPath.swift. Here is details of log:</font><ul><ul><font size="2">[ RUN ] key paths.key path generic instantiation</font><br><font size="2">stdout>>> check failed at /home/wk/sw4/swift/test/stdlib/KeyPath.swift, line 193</font><br><font size="2">stdout>>> expected: Swift.ReferenceWritableKeyPath<a.S<Swift.Int>, Swift.Int> (of type Swift.ReferenceWritableKeyPath<a.S<Swift.Int>, Swift.Int>)</font><br><font size="2">stdout>>> actual: Swift.ReferenceWritableKeyPath<a.S<Swift.Int>, Swift.Int> (of type Swift.ReferenceWritableKeyPath<a.S<Swift.Int>, Swift.Int>)</font><br><font size="2">stdout>>> check failed at /home/wk/sw4/swift/test/stdlib/KeyPath.swift, line 197</font><br><font size="2">stdout>>> expected: Swift.ReferenceWritableKeyPath<a.S<Swift.String>, Swift.Int> (of type Swift.ReferenceWritableKeyPath<a.S<Swift.String>, Swift.Int>)</font><br><font size="2">stdout>>> actual: Swift.ReferenceWritableKeyPath<a.S<Swift.String>, Swift.Int> (of type Swift.ReferenceWritableKeyPath<a.S<Swift.String>, Swift.Int>)</font><br><font size="2">stdout>>> check failed at /home/wk/sw4/swift/test/stdlib/KeyPath.swift, line 201</font><br><font size="2">stdout>>> expected: Swift.ReferenceWritableKeyPath<a.S<StdlibUnittest.LifetimeTracked>, Swift.Int> (of type Swift.ReferenceWritableKeyPath<a.S<StdlibUnittest.LifetimeTracked>, Swift.Int>)</font><br><font size="2">stdout>>> actual: Swift.ReferenceWritableKeyPath<a.S<StdlibUnittest.LifetimeTracked>, Swift.Int> (of type Swift.ReferenceWritableKeyPath<a.S<StdlibUnittest.LifetimeTracked>, Swift.Int>)</font><br><font size="2">[ FAIL ] key paths.key path generic instantiation</font></ul></ul><br><font size="2">Other test cases of KeyPath.siwft are all passed. </font><br><font size="2">It is found that the failure reason is @stdlib/public/core/KeyPath.swift</font><br>
<ul><ul><font size="2"> 85 if aComponent.header.endOfReferencePrefix</font><br><font size="2"> 86 != bComponent.header.endOfReferencePrefix</font><br><font size="2"> 87 ||</font><b><font size="2"> aComponent.value != bComponent.value</font></b><font size="2"> </font><font size="2" color="#0000FF">// this is true on s390x, aComponent.value="struct(0)", bComponent.value="struct(48)"</font><br><font size="2"> 88 || aType != bType {</font><br><font size="2"> 89 return false</font><br><font size="2"> 90 }</font></ul></ul><br><font size="2">Then tracing to:</font><br>
<ul><font size="2">2094 func tryToResolveOffset() {</font><br><font size="2">2095 if header.payload == RawKeyPathComponent.Header.unresolvedFieldOffsetPayload {</font><br><font size="2">2096 // Look up offset in type metadata. The value in the pattern is the</font><br><font size="2">2097 // offset within the metadata object.</font><br><font size="2">2098 let metadataPtr = unsafeBitCast(base, to: UnsafeRawPointer.self)</font><br><font size="2">2099 let offsetOfOffset = patternBuffer.pop(UInt32.self)</font><br><font size="2">2100 print("+++++++++++ int_offsetOfOffset=\(Int(offsetOfOffset))\n")</font><br><font size="2">2101 </font><b><font size="2">var offset = metadataPtr.load(fromByteOffset: Int(offsetOfOffset), </font></b><font size="2" color="#0000FF"> // given the same input parameters (offsetOfOfferset=56), </font><br><b><font size="2">2102 as: UInt32.self) // </font></b><font size="2" color="#0000FF"> different "offset" (0 on s390x, and 48 on x86_64)</font><br><font size="2">2103 // Rewrite the header for a resolved offset.</font></ul><br><br><font size="2">Then it comes </font><font size="2" color="#0000FF">Builtin.loadRaw</font><font size="2"> of </font><font size="2">UnsafeRawPointer.swift.gyb</font><br><br><font size="2">As My lldb and gdb do not stop @ </font>emitBuiltinLoadRaw()<font size="2">, </font><br><font size="2">I inserted a "printf" in the fucntion, but it does not print out anything.</font><br><br><font size="2">Yes, I think it maybe related to </font>alignment or endianness<font size="2">, so we need to find the source code of LoadRaw.</font><br><br><br><font size="2">Thanks,</font><br><br><font size="2"> </font><br><font size="2">Sam Ding,</font><br><font size="2">Linux on z Systems Open Source Ecosystem</font><br><font size="2">IBM Toronto Lab, <br></font><font size="2" color="#0000FF">email: </font><font size="2">samding@ca.ibm.com</font><br><font size="2" color="#0000FF">phone:</font><font size="2"> (905)413-2947</font><br><br><img width="16" height="16" src="cid:1__=8FBB0B39DFDE84398f9e8a93df938690918c8FB@" border="0" alt="Inactive hide details for Slava Pestov ---09/28/2017 05:24:37 PM---Hi Sam, The builtin is defined in lib/SILGen/SILGenBuiltin.c"><font size="2" color="#424282">Slava Pestov ---09/28/2017 05:24:37 PM---Hi Sam, The builtin is defined in lib/SILGen/SILGenBuiltin.cpp, look for the function named emitBuil</font><br><br><font size="2" color="#5F5F5F">From: </font><font size="2">Slava Pestov <spestov@apple.com></font><br><font size="2" color="#5F5F5F">To: </font><font size="2">Sam Ding <samding@ca.ibm.com></font><br><font size="2" color="#5F5F5F">Cc: </font><font size="2">swift-dev <swift-dev@swift.org></font><br><font size="2" color="#5F5F5F">Date: </font><font size="2">09/28/2017 05:24 PM</font><br><font size="2" color="#5F5F5F">Subject: </font><font size="2">Re: [swift-dev] Builtin.loadRaw</font><br><font size="2" color="#5F5F5F">Sent by: </font><font size="2">spestov@apple.com</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br>Hi Sam,<br><br>The builtin is defined in lib/SILGen/SILGenBuiltin.cpp, look for the function named emitBuiltinLoadRaw().<br><br>However I suspect the problem in this case is not that the builtin is implemented incorrectly (it eventually lowers to an LLVM load instruction) but that something further upstream is going wrong, perhaps with alignment or endianness.<br><br>Can you tell us which unit tests are failing specifically?<br><br>Slava<br>
<ul><ul>On Sep 28, 2017, at 2:16 PM, Sam Ding via swift-dev <<a href="mailto:swift-dev@swift.org"><u><font color="#0000FF">swift-dev@swift.org</font></u></a>> wrote:<br>
<p><font size="2">I am testing a test case "KeyPath.swift" on s390x for v4.0 . It is found that " Builtin.loadRaw" as the below of <br>"stdlib/public/core/UnsafeRawPointer.swift.gyb" returns a different value than that on x86-64. </font><ul><ul><font size="2">@_inlineable<br>public func load<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T {<br>_debugPrecondition(0 == (UInt(bitPattern: self + offset)<br>& (UInt(MemoryLayout<T>.alignment) - 1)),<br>"load from misaligned raw pointer")</font><br><font size="2"><br>return </font><font size="2" color="#0000FF">Builtin.loadRaw</font><font size="2">((self + offset)._rawValue) // return a different value on s390x vs x86-64<br>}</font></ul></ul><font size="2">My debugger (lldb) does not guide me to the detailed of " </font><font size="2" color="#0000FF">Builtin.loadRaw</font><font size="2">". Searching "loadRaw" and finding</font><ul><ul><font size="2">swift/include/swift/AST/Builtins.def:</font><font size="2" color="#001FE2">BUILTIN_SIL_OPERATION(LoadRaw, "loadRaw", Special)</font><font size="2"> </font></ul></ul><font size="2"><br>But I could not find the definition of this "</font><font size="2" color="#001FE2">LoadRaw</font><font size="2">" from the whole swift v4.<br>Can anyone give me a hint where its implementation is?</font><br><font size="2"><br>Thanks,</font><br><br><font size="2"><br>Sam Ding,<br>Linux on z Systems Open Source Ecosystem<br>IBM Toronto Lab, </font><font size="2" color="#0000FF"><br>email: </font><a href="mailto:samding@ca.ibm.com"><u><font size="2" color="#0000FF">samding@ca.ibm.com</font></u></a><font size="2" color="#0000FF"><br>phone:</font><font size="2"> (905)413-2947</font><br>_______________________________________________<br>swift-dev mailing list<u><font color="#0000FF"><br></font></u><a href="mailto:swift-dev@swift.org"><u><font color="#0000FF">swift-dev@swift.org</font></u></a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev">https://lists.swift.org/mailman/listinfo/swift-dev</a></ul></ul><br><br><BR>
</body></html>