[swift-dev] Builtin.loadRaw

Joe Groff jgroff at apple.com
Thu Sep 28 16:24:46 CDT 2017



> On Sep 28, 2017, at 2:16 PM, Sam Ding via swift-dev <swift-dev at swift.org> wrote:
> 
> I am testing a test case "KeyPath.swift" on s390x for v4.0 . It is found that " Builtin.loadRaw" as the below of 
> "stdlib/public/core/UnsafeRawPointer.swift.gyb" returns a different value than that on x86-64. 
> @_inlineable
> public func load<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T {
> _debugPrecondition(0 == (UInt(bitPattern: self + offset)
> & (UInt(MemoryLayout<T>.alignment) - 1)),
> "load from misaligned raw pointer")
> 
> return Builtin.loadRaw((self + offset)._rawValue) // return a different value on s390x vs x86-64
> }
> My debugger (lldb) does not guide me to the detailed of " Builtin.loadRaw". Searching "loadRaw" and finding
> swift/include/swift/AST/Builtins.def:BUILTIN_SIL_OPERATION(LoadRaw, "loadRaw", Special)
> 
> But I could not find the definition of this "LoadRaw" from the whole swift v4.
> Can anyone give me a hint where its implementation is?

Builtins don't have any definition in Swift; they're lowered directly by the compiler. UnsafeRawPointer.load loads a value from memory at the address referenced by the pointer's value. The pointer may be getting miscalculated because of layout assumptions that hold on other platforms but not s390x.

-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20170928/abe3d386/attachment.html>


More information about the swift-dev mailing list