|
10 | 10 | // CHECK: @{{_ZN21WithConstStaticMember7definedE|"\?defined@WithConstStaticMember@@2HB"}} = {{available_externally|linkonce_odr}} {{(dso_local )?}}constant i32 48, {{(comdat, )?}}align 4
|
11 | 11 | // CHECK: @{{_ZN21WithConstStaticMember16definedOutOfLineE|"\?definedOutOfLine@WithConstStaticMember@@2HB"}} = external {{(dso_local )?}}constant i32, align 4
|
12 | 12 |
|
13 |
| -//TODO: This test uses only values of static const members, so it does not need |
14 |
| -//to depend on external definitions. However, our code generation pattern loads |
15 |
| -//the value dynamically. Instead, we should inline known constants. That would |
16 |
| -//allow Swift code to even read the value of WithIncompleteStaticMember::notDefined. |
17 |
| -// NOTE: we allow both available_externally and linkonce_odr as there are |
18 |
| -// differences in between MSVC and itanium model semantics where the constexpr |
19 |
| -// value is emitted into COMDAT. |
20 |
| -// CHECK: @{{_ZN25WithConstexprStaticMember13definedInlineE|"\?definedInline@WithConstexprStaticMember@@2HB"}} = {{available_externally|linkonce_odr}} {{(dso_local )?}}constant i32 139, {{(comdat, )?}}align 4 |
| 13 | +// Make sure we remove constexpr globals after all uses have been inlined. |
| 14 | +// CHECK-NOT: _ZN25WithConstexprStaticMember13definedInlineE |
| 15 | +// CHECK-NOT: ?definedInline@WithConstexprStaticMember@@2HB |
| 16 | +// CHECK-NOT: @_ZN25WithConstexprStaticMember20definedInlineWithArgE |
| 17 | +// CHECK-NOT: @_ZN25WithConstexprStaticMember18definedInlineFloatE |
| 18 | +// CHECK-NOT: @_ZN25WithConstexprStaticMember23definedInlineFromMethodE |
21 | 19 |
|
22 | 20 | import StaticMemberVar
|
23 | 21 |
|
@@ -73,10 +71,38 @@ public func readDefinedOutOfLineConstMember() -> CInt {
|
73 | 71 | // CHECK: [[VALUE:%.*]] = load i32, i32* getelementptr inbounds (%Ts5Int32V, %Ts5Int32V* bitcast (i32* @{{_ZN21WithConstStaticMember16definedOutOfLineE|"\?definedOutOfLine@WithConstStaticMember@@2HB"}} to %Ts5Int32V*), i32 0, i32 0), align 4
|
74 | 72 | // CHECK: ret i32 [[VALUE]]
|
75 | 73 |
|
76 |
| -public func readConstexprStaticMember() -> CInt { |
77 |
| - return WithConstexprStaticMember.definedInline |
| 74 | +public func readConstexprStaticIntMembers() { |
| 75 | + let x = WithConstexprStaticMember.definedInline |
| 76 | + let y = WithConstexprStaticMember.definedInlineWithArg |
78 | 77 | }
|
79 | 78 |
|
80 |
| -// CHECK: define {{(protected |dllexport )?}}swiftcc i32 @"$s4main25readConstexprStaticMembers5Int32VyF"() #0 |
81 |
| -// CHECK: [[VALUE:%.*]] = load i32, i32* getelementptr inbounds (%Ts5Int32V, %Ts5Int32V* bitcast (i32* @{{_ZN25WithConstexprStaticMember13definedInlineE|"\?definedInline@WithConstexprStaticMember@@2HB"}} to %Ts5Int32V*), i32 0, i32 0), align 4 |
82 |
| -// CHECK: ret i32 [[VALUE]] |
| 79 | +// CHECK-LABEL: define {{(protected |dllexport )?}}swiftcc void @"$s4main29readConstexprStaticIntMembersyyF"() |
| 80 | +// CHECK: call swiftcc i32 @"$sSo25WithConstexprStaticMemberV13definedInlines5Int32VvgZ"() |
| 81 | +// CHECK: call swiftcc i32 @"$sSo25WithConstexprStaticMemberV013definedInlineA3Args5Int32VvgZ"() |
| 82 | +// CHECK: ret void |
| 83 | + |
| 84 | +// CHECK-LABEL: define linkonce_odr {{.*}}swiftcc i32 @"$sSo25WithConstexprStaticMemberV13definedInlines5Int32VvgZ"() |
| 85 | +// CHECK-NEXT: entry |
| 86 | +// CHECK-NEXT: ret i32 139 |
| 87 | + |
| 88 | +// CHECK-LABEL: define linkonce_odr {{.*}}swiftcc i32 @"$sSo25WithConstexprStaticMemberV013definedInlineA3Args5Int32VvgZ"() |
| 89 | +// CHECK-NEXT: entry |
| 90 | +// CHECK-NEXT: ret i32 42 |
| 91 | + |
| 92 | +public func readConstexprStaticFloatMembers() { |
| 93 | + let x = WithConstexprStaticMember.definedInlineFloat |
| 94 | + let y = WithConstexprStaticMember.definedInlineFromMethod |
| 95 | +} |
| 96 | + |
| 97 | +// CHECK-LABEL: define {{(protected |dllexport )?}}swiftcc void @"$s4main31readConstexprStaticFloatMembersyyF"() |
| 98 | +// CHECK: call swiftcc float @"$sSo25WithConstexprStaticMemberV18definedInlineFloatSfvgZ"() |
| 99 | +// CHECK: call swiftcc float @"$sSo25WithConstexprStaticMemberV23definedInlineFromMethodSfvgZ"() |
| 100 | +// CHECK: ret void |
| 101 | + |
| 102 | +// CHECK-LABEL: define linkonce_odr {{.*}}swiftcc float @"$sSo25WithConstexprStaticMemberV18definedInlineFloatSfvgZ"() |
| 103 | +// CHECK-NEXT: entry |
| 104 | +// CHECK-NEXT: ret float 1.390000e+02 |
| 105 | + |
| 106 | +// CHECK-LABEL: define linkonce_odr {{.*}}swiftcc float @"$sSo25WithConstexprStaticMemberV23definedInlineFromMethodSfvgZ"() |
| 107 | +// CHECK-NEXT: entry |
| 108 | +// CHECK-NEXT: ret float 4.200000e+01 |
0 commit comments