| // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s |
| |
| // REQUIRES: CPU=x86_64 |
| |
| sil_stage canonical |
| |
| import Builtin |
| import Swift |
| |
| struct BigStruct { |
| var x, y, z, w, v, u : Int |
| } |
| |
| sil @alloc_small : $(@inout Builtin.UnsafeValueBuffer, Int) -> () { |
| entry(%b : $*Builtin.UnsafeValueBuffer, %v : $Int): |
| %0 = alloc_value_buffer $Int in %b : $*Builtin.UnsafeValueBuffer |
| store %v to %0 : $*Int |
| %r = tuple () |
| return %r : $() |
| } |
| // CHECK-LABEL: define{{( protected)?}} swiftcc void @alloc_small([24 x i8]* nocapture dereferenceable({{.*}}), i64) |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: [[T0:%.*]] = bitcast [24 x i8]* %0 to %TSi* |
| // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds %TSi, %TSi* [[T0]], i32 0, i32 0 |
| // CHECK-NEXT: store i64 %1, i64* [[T2]], align 8 |
| // CHECK-NEXT: ret void |
| |
| sil @project_small : $(@inout Builtin.UnsafeValueBuffer, Int) -> () { |
| entry(%b : $*Builtin.UnsafeValueBuffer, %v : $Int): |
| %0 = project_value_buffer $Int in %b : $*Builtin.UnsafeValueBuffer |
| store %v to %0 : $*Int |
| %r = tuple () |
| return %r : $() |
| } |
| // CHECK-LABEL: define{{( protected)?}} swiftcc void @project_small([24 x i8]* nocapture dereferenceable({{.*}}), i64) |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: [[T0:%.*]] = bitcast [24 x i8]* %0 to %TSi* |
| // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds %TSi, %TSi* [[T0]], i32 0, i32 0 |
| // CHECK-NEXT: store i64 %1, i64* [[T2]], align 8 |
| // CHECK-NEXT: ret void |
| |
| sil @dealloc_small : $(@inout Builtin.UnsafeValueBuffer) -> () { |
| entry(%b : $*Builtin.UnsafeValueBuffer): |
| dealloc_value_buffer $Int in %b : $*Builtin.UnsafeValueBuffer |
| %r = tuple () |
| return %r : $() |
| } |
| // CHECK-LABEL: define{{( protected)?}} swiftcc void @dealloc_small([24 x i8]* nocapture dereferenceable({{.*}})) |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: ret void |
| |
| sil @alloc_big : $(@inout Builtin.UnsafeValueBuffer, BigStruct) -> () { |
| entry(%b : $*Builtin.UnsafeValueBuffer, %v : $BigStruct): |
| %0 = alloc_value_buffer $BigStruct in %b : $*Builtin.UnsafeValueBuffer |
| store %v to %0 : $*BigStruct |
| %r = tuple () |
| return %r : $() |
| } |
| // CHECK-LABEL: define{{( protected)?}} swiftcc void @alloc_big([24 x i8]* nocapture dereferenceable({{.*}}), %T13value_buffers9BigStructV* noalias nocapture dereferenceable({{.*}})) |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: [[T0:%.*]] = call noalias i8* @swift_slowAlloc(i64 48, i64 7) |
| // CHECK-NEXT: [[T1:%.*]] = bitcast [24 x i8]* %0 to i8** |
| // CHECK-NEXT: store i8* [[T0]], i8** [[T1]], align 8 |
| // CHECK-NEXT: [[ADDR:%.*]] = bitcast i8* [[T0]] to %T13value_buffers9BigStructV* |
| // CHECK-NEXT: [[PARAM1:%.*]] = bitcast %T13value_buffers9BigStructV* [[ADDR]] to i8* |
| // CHECK-NEXT: [[PARAM2:%.*]] = bitcast %T13value_buffers9BigStructV* %1 to i8* |
| // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[PARAM1]], i8* [[PARAM2]], i64 48, i32 8, i1 false) |
| // CHECK-NEXT: ret void |
| |
| sil @project_big : $(@inout Builtin.UnsafeValueBuffer, BigStruct) -> () { |
| entry(%b : $*Builtin.UnsafeValueBuffer, %v : $BigStruct): |
| %0 = project_value_buffer $BigStruct in %b : $*Builtin.UnsafeValueBuffer |
| store %v to %0 : $*BigStruct |
| %r = tuple () |
| return %r : $() |
| } |
| // CHECK-LABEL: define{{( protected)?}} swiftcc void @project_big([24 x i8]* nocapture dereferenceable({{.*}}), %T13value_buffers9BigStructV* noalias nocapture dereferenceable({{.*}})) |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: [[T0:%.*]] = bitcast [24 x i8]* %0 to %T13value_buffers9BigStructV** |
| // CHECK-NEXT: [[ADDR:%.*]] = load %T13value_buffers9BigStructV*, %T13value_buffers9BigStructV** [[T0]], align 8 |
| // CHECK-NEXT: [[PARAM1:%.*]] = bitcast %T13value_buffers9BigStructV* [[ADDR]] to i8* |
| // CHECK-NEXT: [[PARAM2:%.*]] = bitcast %T13value_buffers9BigStructV* %1 to i8* |
| // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[PARAM1]], i8* [[PARAM2]], i64 48, i32 8, i1 false) |
| // CHECK-NEXT: ret void |
| |
| sil @dealloc_big : $(@inout Builtin.UnsafeValueBuffer) -> () { |
| entry(%b : $*Builtin.UnsafeValueBuffer): |
| dealloc_value_buffer $BigStruct in %b : $*Builtin.UnsafeValueBuffer |
| %r = tuple () |
| return %r : $() |
| } |
| // CHECK-LABEL: define{{( protected)?}} swiftcc void @dealloc_big([24 x i8]* nocapture dereferenceable({{.*}})) |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: [[T0:%.*]] = bitcast [24 x i8]* %0 to i8** |
| // CHECK-NEXT: [[ADDR:%.*]] = load i8*, i8** [[T0]], align 8 |
| // CHECK-NEXT: call void @swift_slowDealloc(i8* [[ADDR]], i64 48, i64 7) |
| // CHECK-NEXT: ret void |