Skip to content

Commit d246512

Browse files
authored
Merge pull request #29759 from eeckstein/fix-optimizer-tests
2 parents c2ac96f + 9de45ac commit d246512

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed

test/SILOptimizer/bridged_casts_folding.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -O -emit-sil -enforce-exclusivity=unchecked %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -enable-ownership-stripping-after-serialization -O -emit-sil -enforce-exclusivity=unchecked %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -enable-ownership-stripping-after-serialization -O -emit-sil %s | %FileCheck %s
33

44
// REQUIRES: objc_interop
55

@@ -904,9 +904,14 @@ var anyHashable: AnyHashable = 0
904904

905905
// CHECK-LABEL: $s21bridged_casts_folding29testUncondCastSwiftToSubclassAA08NSObjectI0CyF
906906
// CHECK: [[GLOBAL:%[0-9]+]] = global_addr @$s21bridged_casts_folding11anyHashables03AnyE0Vv
907+
// CHECK: [[GLOBAL_COPY:%[0-9]+]] = alloc_stack
908+
// CHECK: [[GLOBAL_EXCL:%[0-9]+]] = begin_access [read] [static] [no_nested_conflict] [[GLOBAL]]
909+
910+
// TODO: this copy_addr should be eliminated: rdar://problem/59345115
911+
// CHECK: copy_addr [[GLOBAL_EXCL]] to [initialization] [[GLOBAL_COPY]]
907912
// CHECK: [[FUNC:%.*]] = function_ref @$ss11AnyHashableV10FoundationE19_bridgeToObjectiveCSo8NSObjectCyF
908-
// CHECK-NEXT: apply [[FUNC]]([[GLOBAL]])
909-
// CHECK-NEXT: unconditional_checked_cast {{%.*}} : $NSObject to NSObjectSubclass
913+
// CHECK: apply [[FUNC]]([[GLOBAL_COPY]])
914+
// CHECK: unconditional_checked_cast {{%.*}} : $NSObject to NSObjectSubclass
910915
// CHECK: } // end sil function '$s21bridged_casts_folding29testUncondCastSwiftToSubclassAA08NSObjectI0CyF'
911916
@inline(never)
912917
public func testUncondCastSwiftToSubclass() -> NSObjectSubclass {

test/SILOptimizer/illegal_escaping_address.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -enforce-exclusivity=unchecked -parse-as-library %s
1+
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -parse-as-library %s
22

33
// Check that the compiler does not crash for illegal escaping of an address
44
// of a local variable.

test/SILOptimizer/let_propagation.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s -emit-sil -enforce-exclusivity=unchecked -O | %FileCheck %s
1+
// RUN: %target-swift-frontend -primary-file %s -emit-sil -O | %FileCheck %s
22

33
// Check that LoadStoreOpts can handle "let" variables properly.
44
// Such variables should be loaded only once and their loaded values can be reused.
@@ -311,12 +311,13 @@ public func testLetTuple(s: S3) -> Int32 {
311311

312312
// Check that s.x.0 is reloaded every time.
313313
// CHECK-LABEL: sil {{.*}}testVarTuple
314-
// CHECK: tuple_element_addr
315-
// CHECK: %[[X:[0-9]+]] = struct_element_addr
316-
// CHECK: load %[[X]]
317-
// CHECK: load %[[X]]
318-
// CHECK: load %[[X]]
319-
// CHECK: load %[[X]]
314+
// CHECK: [[X0:%[0-9]+]] = load
315+
// CHECK: [[X1:%[0-9]+]] = load
316+
// CHECK: builtin "sadd_with_overflow{{.*}}"([[X0]] {{.*}}, [[X1]]
317+
// CHECK: [[X2:%[0-9]+]] = load
318+
// CHECK: builtin "sadd_with_overflow{{.*}} [[X2]]
319+
// CHECK: [[X3:%[0-9]+]] = load
320+
// CHECK: builtin "sadd_with_overflow{{.*}} [[X3]]
320321
// CHECK: return
321322
public func testVarTuple(s: S3) -> Int32 {
322323
var counter: Int32 = 0

test/SILOptimizer/sil_combine_protocol_conf.swift

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend %s -O -wmo -emit-sil -Xllvm -sil-disable-pass=DeadFunctionElimination -enforce-exclusivity=unchecked | %FileCheck %s
1+
// RUN: %target-swift-frontend %s -O -wmo -emit-sil -Xllvm -sil-disable-pass=DeadFunctionElimination | %FileCheck %s
22

33
// case 1: class protocol -- should optimize
44
internal protocol SomeProtocol : class {
@@ -237,14 +237,24 @@ internal class OtherClass {
237237
// CHECK-LABEL: sil hidden [noinline] @$s25sil_combine_protocol_conf10OtherClassC12doWorkStructSiyF : $@convention(method) (@guaranteed OtherClass) -> Int {
238238
// CHECK: bb0([[ARG:%.*]] :
239239
// CHECK: debug_value
240+
// CHECK: [[STACK1:%.*]] = alloc_stack $PropProtocol
240241
// CHECK: [[R1:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg1
241-
// CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[R1]] : $*PropProtocol to $*@opened("{{.*}}") PropProtocol
242+
// CHECK: [[ACC1:%.*]] = begin_access [read] [dynamic] [no_nested_conflict] [[R1]]
243+
244+
// TODO: this copy_addr should be eliminated: rdar://problem/59345115
245+
// CHECK: copy_addr [[ACC1]] to [initialization] [[STACK1]]
246+
// CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[STACK1]] : $*PropProtocol to $*@opened("{{.*}}") PropProtocol
242247
// CHECK: [[U1:%.*]] = unchecked_addr_cast [[O1]] : $*@opened("{{.*}}") PropProtocol to $*PropClass
243248
// CHECK: [[S1:%.*]] = struct_element_addr [[U1]] : $*PropClass, #PropClass.val
244249
// CHECK: [[S11:%.*]] = struct_element_addr [[S1]] : $*Int, #Int._value
245250
// CHECK: load [[S11]]
251+
// CHECK: [[STACK2:%.*]] = alloc_stack $GenericPropProtocol
246252
// CHECK: [[R2:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg2
247-
// CHECK: [[O2:%.*]] = open_existential_addr immutable_access [[R2]] : $*GenericPropProtocol to $*@opened("{{.*}}") GenericPropProtocol
253+
// CHECK: [[ACC2:%.*]] = begin_access [read] [dynamic] [no_nested_conflict] [[R2]]
254+
255+
// TODO: this copy_addr should be eliminated: rdar://problem/59345115
256+
// CHECK: copy_addr [[ACC2]] to [initialization] [[STACK2]]
257+
// CHECK: [[O2:%.*]] = open_existential_addr immutable_access [[STACK2]] : $*GenericPropProtocol to $*@opened("{{.*}}") GenericPropProtocol
248258
// CHECK: [[W2:%.*]] = witness_method $@opened("{{.*}}") GenericPropProtocol, #GenericPropProtocol.val!getter.1 : <Self where Self : GenericPropProtocol> (Self) -> () -> Int, [[O2]] : $*@opened("{{.*}}") GenericPropProtocol : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
249259
// CHECK: apply [[W2]]<@opened("{{.*}}") GenericPropProtocol>([[O2]]) : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
250260
// CHECK: struct_extract
@@ -253,8 +263,13 @@ internal class OtherClass {
253263
// CHECK: tuple_extract
254264
// CHECK: tuple_extract
255265
// CHECK: cond_fail
266+
// CHECK: [[STACK4:%.*]] = alloc_stack $NestedPropProtocol
256267
// CHECK: [[R4:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg3
257-
// CHECK: [[O4:%.*]] = open_existential_addr immutable_access [[R4]] : $*NestedPropProtocol to $*@opened("{{.*}}") NestedPropProtocol
268+
// CHECK: [[ACC4:%.*]] = begin_access [read] [dynamic] [no_nested_conflict] [[R4]]
269+
270+
// TODO: this copy_addr should be eliminated: rdar://problem/59345115
271+
// CHECK: copy_addr [[ACC4]] to [initialization] [[STACK4]]
272+
// CHECK: [[O4:%.*]] = open_existential_addr immutable_access [[STACK4]] : $*NestedPropProtocol to $*@opened("{{.*}}") NestedPropProtocol
258273
// CHECK: [[U4:%.*]] = unchecked_addr_cast [[O4]] : $*@opened("{{.*}}") NestedPropProtocol to $*Outer.Inner
259274
// CHECK: [[S4:%.*]] = struct_element_addr [[U4]] : $*Outer.Inner, #Outer.Inner.val
260275
// CHECK: [[S41:%.*]] = struct_element_addr [[S4]] : $*Int, #Int._value
@@ -263,8 +278,13 @@ internal class OtherClass {
263278
// CHECK: tuple_extract
264279
// CHECK: tuple_extract
265280
// CHECK: cond_fail
281+
// CHECK: [[STACK5:%.*]] = alloc_stack $GenericNestedPropProtocol
266282
// CHECK: [[R5:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg4
267-
// CHECK: [[O5:%.*]] = open_existential_addr immutable_access [[R5]] : $*GenericNestedPropProtocol to $*@opened("{{.*}}") GenericNestedPropProtocol
283+
// CHECK: [[ACC5:%.*]] = begin_access [read] [dynamic] [no_nested_conflict] [[R5]]
284+
285+
// TODO: this copy_addr should be eliminated: rdar://problem/59345115
286+
// CHECK: copy_addr [[ACC5]] to [initialization] [[STACK5]]
287+
// CHECK: [[O5:%.*]] = open_existential_addr immutable_access [[STACK5]] : $*GenericNestedPropProtocol to $*@opened("{{.*}}") GenericNestedPropProtocol
268288
// CHECK: [[W5:%.*]] = witness_method $@opened("{{.*}}") GenericNestedPropProtocol, #GenericNestedPropProtocol.val!getter.1 : <Self where Self : GenericNestedPropProtocol> (Self) -> () -> Int, [[O5:%.*]] : $*@opened("{{.*}}") GenericNestedPropProtocol : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
269289
// CHECK: apply [[W5]]<@opened("{{.*}}") GenericNestedPropProtocol>([[O5]]) : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
270290
// CHECK: struct_extract
@@ -331,8 +351,13 @@ internal class OtherKlass {
331351
// CHECK: bb0([[ARG:%.*]] :
332352
// CHECK: debug_value
333353
// CHECK: integer_literal
354+
// CHECK: [[STACK1:%.*]] = alloc_stack $AGenericProtocol
334355
// CHECK: [[R1:%.*]] = ref_element_addr [[ARG]] : $OtherKlass, #OtherKlass.arg2
335-
// CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[R1]] : $*AGenericProtocol to $*@opened("{{.*}}") AGenericProtocol
356+
// CHECK: [[ACC1:%.*]] = begin_access [read] [dynamic] [no_nested_conflict] [[R1]]
357+
358+
// TODO: this copy_addr should be eliminated: rdar://problem/59345115
359+
// CHECK: copy_addr [[ACC1]] to [initialization] [[STACK1]]
360+
// CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[STACK1]] : $*AGenericProtocol to $*@opened("{{.*}}") AGenericProtocol
336361
// CHECK: [[W1:%.*]] = witness_method $@opened("{{.*}}") AGenericProtocol, #AGenericProtocol.val!getter.1 : <Self where Self : AGenericProtocol> (Self) -> () -> Int, [[O1]] : $*@opened("{{.*}}") AGenericProtocol : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
337362
// CHECK: apply [[W1]]<@opened("{{.*}}") AGenericProtocol>([[O1]]) : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
338363
// CHECK: struct_extract

test/SILOptimizer/static_arrays.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=FunctionSignatureOpts -module-name=test -emit-sil -enforce-exclusivity=unchecked | %FileCheck %s
1+
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=FunctionSignatureOpts -module-name=test -emit-sil | %FileCheck %s
22

33
// Also do an end-to-end test to check all components, including IRGen.
44
// RUN: %empty-directory(%t)

0 commit comments

Comments
 (0)