|
| 1 | +// Target-specific tests for C++ constructor call code generation. |
| 2 | + |
| 3 | +// RUN: %swift -module-name MySwift -target armv7-unknown-linux-androideabi -dump-clang-diagnostics -I %S/Inputs -enable-experimental-cxx-interop -emit-ir %s -parse-stdlib -parse-as-library -disable-legacy-type-info | %FileCheck %s -check-prefix=ITANIUM_ARM |
| 4 | + |
| 5 | +// REQUIRES: OS=linux-android || OS=linux-androideabi |
| 6 | + |
| 7 | +// REQUIRES: CODEGENERATOR=X86 |
| 8 | +// REQUIRES: CODEGENERATOR=ARM |
| 9 | + |
| 10 | +import Constructors |
| 11 | +import TypeClassification |
| 12 | + |
| 13 | +public func createHasVirtualBase() -> HasVirtualBase { |
| 14 | + // ITANIUM_ARM: define protected swiftcc void @"$s7MySwift20createHasVirtualBaseSo0bcD0VyF"(%TSo14HasVirtualBaseV* noalias nocapture sret({{.*}}) %0) |
| 15 | + // To verify that the thunk is inlined, make sure there's no intervening |
| 16 | + // `define`, i.e. the call to the C++ constructor happens in |
| 17 | + // createHasVirtualBase(), not some later function. |
| 18 | + // ITANIUM_ARM-NOT: define |
| 19 | + // Note `this` return type. |
| 20 | + // ITANIUM_ARM: call %struct.HasVirtualBase* @_ZN14HasVirtualBaseC1E7ArgType(%struct.HasVirtualBase* %{{[0-9]+}}, [1 x i32] %{{[0-9]+}}) |
| 21 | + return HasVirtualBase(ArgType()) |
| 22 | +} |
| 23 | + |
| 24 | +public func createImplicitDefaultConstructor() -> ImplicitDefaultConstructor { |
| 25 | + // ITANIUM_ARM: define protected swiftcc i32 @"$s7MySwift32createImplicitDefaultConstructorSo0bcD0VyF"() |
| 26 | + // ITANIUM_ARM-NOT: define |
| 27 | + // Note `this` return type. |
| 28 | + // ITANIUM_ARM: call %struct.ImplicitDefaultConstructor* @_ZN26ImplicitDefaultConstructorC2Ev(%struct.ImplicitDefaultConstructor* %{{[0-9]+}}) |
| 29 | + return ImplicitDefaultConstructor() |
| 30 | +} |
| 31 | + |
| 32 | +public func createStructWithSubobjectCopyConstructorAndValue() { |
| 33 | + // ITANIUM_ARM-LABEL: define protected swiftcc void @"$s7MySwift48createStructWithSubobjectCopyConstructorAndValueyyF"() |
| 34 | + // ITANIUM_ARM: [[MEMBER:%.*]] = alloca %TSo33StructWithCopyConstructorAndValueV |
| 35 | + // ITANIUM_ARM: [[OBJ:%.*]] = alloca %TSo42StructWithSubobjectCopyConstructorAndValueV |
| 36 | + // ITANIUM_ARM: [[TMP:%.*]] = alloca %TSo33StructWithCopyConstructorAndValueV |
| 37 | + // ITANIUM_ARM: [[MEMBER_AS_STRUCT:%.*]] = bitcast %TSo33StructWithCopyConstructorAndValueV* [[MEMBER]] to %struct.StructWithCopyConstructorAndValue* |
| 38 | + // ITANIUM_ARM: call %struct.StructWithCopyConstructorAndValue* @_ZN33StructWithCopyConstructorAndValueC2Ev(%struct.StructWithCopyConstructorAndValue* [[MEMBER_AS_STRUCT]]) |
| 39 | + // ITANIUM_ARM: [[TMP_STRUCT:%.*]] = bitcast %TSo33StructWithCopyConstructorAndValueV* [[TMP]] to %struct.StructWithCopyConstructorAndValue* |
| 40 | + // ITANIUM_ARM: [[MEMBER_AS_STRUCT_2:%.*]] = bitcast %TSo33StructWithCopyConstructorAndValueV* [[MEMBER]] to %struct.StructWithCopyConstructorAndValue* |
| 41 | + // ITANIUM_ARM: call %struct.StructWithCopyConstructorAndValue* @_ZN33StructWithCopyConstructorAndValueC2ERKS_(%struct.StructWithCopyConstructorAndValue* [[TMP_STRUCT]], %struct.StructWithCopyConstructorAndValue* [[MEMBER_AS_STRUCT_2]]) |
| 42 | + // ITANIUM_ARM: ret void |
| 43 | + let member = StructWithCopyConstructorAndValue() |
| 44 | + let obj = StructWithSubobjectCopyConstructorAndValue(member: member) |
| 45 | +} |
| 46 | + |
| 47 | +public func createTemplatedConstructor() { |
| 48 | + // ITANIUM_ARM-LABEL: define protected swiftcc void @"$s7MySwift26createTemplatedConstructoryyF"() |
| 49 | + // ITANIUM_ARM: [[OBJ:%.*]] = alloca %TSo20TemplatedConstructorV |
| 50 | + // ITANIUM_ARM: [[IVAL:%.*]] = load [1 x i32], [1 x i32]* |
| 51 | + // ITANIUM_ARM: [[OBJ_AS_STRUCT:%.*]] = bitcast %TSo20TemplatedConstructorV* [[OBJ]] to %struct.TemplatedConstructor* |
| 52 | + // ITANIUM_ARM: call %struct.TemplatedConstructor* @_ZN20TemplatedConstructorC2I7ArgTypeEET_(%struct.TemplatedConstructor* [[OBJ_AS_STRUCT]], [1 x i32] [[IVAL]]) |
| 53 | + // ITANIUM_ARM: ret void |
| 54 | + |
| 55 | + // ITANIUM_ARM-LABEL: define {{.*}}%struct.TemplatedConstructor* @_ZN20TemplatedConstructorC2I7ArgTypeEET_(%struct.TemplatedConstructor* {{.*}}, [1 x i32] {{.*}}) |
| 56 | + let templated = TemplatedConstructor(ArgType()) |
| 57 | +} |
0 commit comments