mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Case #1. Literal zero = natural alignment %1 = integer_literal $Builtin.Int64, 0 %2 = builtin "uncheckedAssertAlignment" (%0 : $Builtin.RawPointer, %1 : $Builtin.Int64) : $Builtin.RawPointer %3 = pointer_to_address %2 : $Builtin.RawPointer to [align=1] $*Int Erases the `pointer_to_address` `[align=]` attribute: Case #2. Literal nonzero = forced alignment. %1 = integer_literal $Builtin.Int64, 16 %2 = builtin "uncheckedAssertAlignment" (%0 : $Builtin.RawPointer, %1 : $Builtin.Int64) : $Builtin.RawPointer %3 = pointer_to_address %2 : $Builtin.RawPointer to [align=1] $*Int Promotes the `pointer_to_address` `[align=]` attribute to a higher value. Case #3. Folded dynamic alignment %1 = builtin "alignof"<T>(%0 : $@thin T.Type) : $Builtin.Word %2 = builtin "uncheckedAssertAlignment" (%0 : $Builtin.RawPointer, %1 : $Builtin.Int64) : $Builtin.RawPointer %3 = pointer_to_address %2 : $Builtin.RawPointer to [align=1] $*T Erases the `pointer_to_address` `[align=]` attribute.
20 lines
704 B
Swift
20 lines
704 B
Swift
// RUN: %target-swift-emit-sil -O -parse-as-library %s | %FileCheck %s
|
|
|
|
// Test the absence of a 'strict' flag.
|
|
// Test the absence of an 'align' flag.
|
|
//
|
|
// CHECK-LABEL: $s18unsafe_pointer_gen13test_raw_load2rpSiSV_tF
|
|
// CHECK: pointer_to_address {{%.*}} : $Builtin.RawPointer to $*Int
|
|
public func test_raw_load(rp: UnsafeRawPointer) -> Int {
|
|
return rp.load(as: Int.self)
|
|
}
|
|
|
|
// Test the absence of a 'strict' flag.
|
|
// Test the absence of an 'align' flag.
|
|
//
|
|
// CHECK-LABEL: $s18unsafe_pointer_gen20test_mutableraw_load2rpSiSv_tF
|
|
// CHECK: pointer_to_address {{%.*}} : $Builtin.RawPointer to $*Int
|
|
public func test_mutableraw_load(rp: UnsafeMutableRawPointer) -> Int {
|
|
return rp.load(as: Int.self)
|
|
}
|