mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++) rdar://115062687
69 lines
2.7 KiB
Swift
69 lines
2.7 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -Xfrontend -prespecialize-generic-metadata -target %module-target-future %S/Inputs/struct-public-nonfrozen-1argument.swift -emit-library -o %t/%target-library-name(Generic) -emit-module -module-name Generic -emit-module-path %t/Generic.swiftmodule
|
|
// RUN: %target-build-swift -Xfrontend -prespecialize-generic-metadata -target %module-target-future %S/Inputs/struct-public-nonfrozen-0argument.swift -emit-library -o %t/%target-library-name(Argument) -emit-module -module-name Argument -emit-module-path %t/Argument.swiftmodule
|
|
// RUN: %swift -prespecialize-generic-metadata -target %module-target-future -emit-ir %s -L %t -I %t -lGeneric -lArgument | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
|
|
|
|
// REQUIRES: VENDOR=apple || OS=linux-gnu
|
|
// UNSUPPORTED: CPU=i386 && OS=ios
|
|
// UNSUPPORTED: CPU=armv7 && OS=ios
|
|
// UNSUPPORTED: CPU=armv7s && OS=ios
|
|
|
|
// CHECK: @"$s7Generic11OneArgumentVy0C07IntegerVGMN" = linkonce_odr hidden constant <{
|
|
// CHECK-SAME: ptr,
|
|
// CHECK-SAME: [[INT]],
|
|
// CHECK-SAME: ptr,
|
|
// CHECK-SAME: ptr,
|
|
// CHECK-SAME: i32,
|
|
// CHECK-SAME: i32,
|
|
// CHECK-SAME: i64
|
|
// CHECK-SAME: }> <{
|
|
// : ptr getelementptr inbounds (
|
|
// : %swift.vwtable,
|
|
// :
|
|
// CHECK-SAME: $s7Generic11OneArgumentVy0C07IntegerVGWV
|
|
// : ",
|
|
// : i32 0,
|
|
// : i32 0
|
|
// : ),
|
|
// CHECK-SAME: [[INT]] 512,
|
|
// CHECK-SAME: $s7Generic11OneArgumentVMn
|
|
// CHECK-SAME: $s8Argument7IntegerVN
|
|
// CHECK-SAME: i32 0,
|
|
// CHECK-SAME: i32 {{4|8}},
|
|
// CHECK-SAME: i64 1
|
|
// CHECK-SAME: }>,
|
|
// CHECK-SAME: align [[ALIGNMENT]]
|
|
|
|
@inline(never)
|
|
func consume<T>(_ t: T) {
|
|
withExtendedLifetime(t) { t in
|
|
}
|
|
}
|
|
|
|
import Generic
|
|
import Argument
|
|
|
|
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #{{[0-9]+}} {
|
|
// CHECK: [[CANONICALIZED_METADATA_RESPONSE:%[0-9]+]] = call swiftcc %swift.metadata_response @swift_getCanonicalSpecializedMetadata(
|
|
// CHECK-SAME: [[INT]] 0,
|
|
// CHECK-SAME: ptr getelementptr inbounds (
|
|
// CHECK-SAME: %swift.full_type,
|
|
// CHECK-SAME: $s7Generic11OneArgumentVy0C07IntegerVGMN
|
|
// CHECK-SAME: i32 0,
|
|
// CHECK-SAME: i32 2
|
|
// CHECK-SAME: ),
|
|
// CHECK-SAME: $s7Generic11OneArgumentVy0C07IntegerVGMJ
|
|
// CHECK-NEXT: [[CANONICALIZED_METADATA:%[0-9]+]] = extractvalue %swift.metadata_response [[CANONICALIZED_METADATA_RESPONSE]], 0
|
|
// CHECK-NEXT: call swiftcc void @"$s4main7consumeyyxlF"(
|
|
// CHECK-SAME: ptr noalias {{%[0-9]+}},
|
|
// CHECK-SAME: ptr [[CANONICALIZED_METADATA]]
|
|
// CHECK-SAME: )
|
|
// CHECK: }
|
|
func doit() {
|
|
consume( OneArgument(Integer(13)) )
|
|
}
|
|
doit()
|
|
|
|
|
|
|