Skip to content

Commit 5ccebbf

Browse files
authored
Merge pull request #11861 from gottesmm/pr-b140dc2889844049d18cf038dd9122db0e5218cc
2 parents 5824db9 + bcc35dc commit 5ccebbf

File tree

1 file changed

+124
-5
lines changed

1 file changed

+124
-5
lines changed

test/SILOptimizer/mandatory_inlining.sil

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ struct L {
2222
}
2323

2424
sil @plus : $@convention(thin) (Int64, Int64) -> Int64
25+
sil @nativeobject_plus : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
26+
sil @partial_apply_user : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
2527
sil @fromLiteral : $@convention(thin) (Builtin.Int128, @thin Int64.Type) -> Int64
28+
sil @use_nativeobject : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
29+
30+
//////////////////////////////////////
31+
// Multiple Inline in a Block Tests //
32+
//////////////////////////////////////
2633

2734
// CHECK-LABEL: sil [transparent] @test_add : $@convention(thin) (Int64) -> Int64 {
2835
sil [transparent] @test_add : $@convention(thin) (Int64) -> Int64 {
@@ -166,6 +173,10 @@ bb0(%0 : $Int64):
166173
return %19 : $Int64
167174
}
168175

176+
///////////////////////
177+
// Existential Tests //
178+
///////////////////////
179+
169180
protocol SomeProtocol {
170181
}
171182

@@ -204,11 +215,9 @@ bb0(%0 : $*SomeProtocol):
204215
%3 = return %2 : $@thick SomeProtocol.Type
205216
}
206217

207-
sil private @top_level_code : $() -> () {
208-
bb0:
209-
%0 = tuple ()
210-
return %0 : $()
211-
}
218+
////////////////////////
219+
// Control Flow Tests //
220+
////////////////////////
212221

213222
sil @get_logic_value : $@convention(method) (@inout Bool) -> Builtin.Int1
214223
sil @add_floats : $@convention(thin) (Float32, Float32) -> Float32
@@ -387,6 +396,10 @@ bb0(%0 : $Float):
387396
return %21 : $Float
388397
}
389398

399+
///////////////////////////////////////
400+
// Recursion and Partial Apply Tests //
401+
///////////////////////////////////////
402+
390403
// CHECK-LABEL: [transparent] @test_recursive_foo : $@convention(thin) (Float) -> Float
391404
sil [transparent] @test_recursive_foo : $@convention(thin) (Float) -> Float {
392405
// CHECK-NOT: function_ref
@@ -449,6 +462,112 @@ bb0(%0 : $@callee_owned (Int64) -> Int64, %1 : $Int64):
449462
return %7 : $Int64
450463
}
451464

465+
466+
// CHECK-LABEL: [transparent] @test_recursive_nativeobject_foo : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
467+
sil [transparent] @test_recursive_nativeobject_foo : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
468+
// CHECK-NOT: function_ref
469+
// CHECK-NOT: apply
470+
// CHECK: return
471+
472+
bb0(%0 : $Builtin.NativeObject):
473+
%3 = function_ref @test_recursive_nativeobject_bar : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
474+
%5 = apply %3(%0) : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
475+
return %5 : $Builtin.NativeObject
476+
}
477+
478+
// CHECK-LABEL: sil [transparent] @test_recursive_nativeobject_bar : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
479+
sil [transparent] @test_recursive_nativeobject_bar : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
480+
// CHECK-NOT: function_ref
481+
// CHECK-NOT: apply
482+
// CHECK: return
483+
484+
bb0(%0 : $Builtin.NativeObject):
485+
%3 = function_ref @test_recursive_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
486+
%5 = apply %3(%0) : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
487+
return %5 : $Builtin.NativeObject
488+
}
489+
490+
// CHECK-LABEL: sil [transparent] @test_recursive_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
491+
// CHECK: bb0
492+
// CHECK-NEXT: return
493+
// CHECK: } // end sil function 'test_recursive_nativeobject_baz'
494+
sil [transparent] @test_recursive_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
495+
bb0(%0 : $Builtin.NativeObject):
496+
return %0 : $Builtin.NativeObject
497+
}
498+
499+
sil [transparent] @test_partial_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
500+
bb0(%0 : $Builtin.NativeObject, %1 : $Builtin.NativeObject):
501+
%6 = function_ref @nativeobject_plus : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
502+
%7 = apply %6(%0, %1) : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
503+
return %7 : $Builtin.NativeObject
504+
}
505+
506+
sil [transparent] @test_partial_nativeobject_bar : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
507+
bb0(%0 : $@callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, %1 : $Builtin.NativeObject):
508+
%7 = apply %0(%1) : $@callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
509+
return %7 : $Builtin.NativeObject
510+
}
511+
512+
// CHECK-LABEL: sil [transparent] @test_partial_nativeobject_foo : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
513+
// CHECK: bb0([[ARG:%.*]] : $Builtin.NativeObject):
514+
// CHECK: [[FN:%.*]] = function_ref @test_partial_nativeobject_baz :
515+
// CHECK: br bb1
516+
//
517+
// CHECK: bb1:
518+
// CHECK: strong_retain [[ARG]]
519+
// CHECK: [[PAI:%.*]] = partial_apply [[FN]]([[ARG]])
520+
// CHECK: br bb2
521+
//
522+
// CHECK: bb2:
523+
// CHECK: strong_retain [[ARG]]
524+
// CHECK: strong_retain [[PAI]]
525+
// CHECK: br bb3
526+
//
527+
// CHECK: bb3:
528+
// CHECK: strong_retain [[ARG]]
529+
// CHECK: strong_release [[PAI]]
530+
// CHECK: [[FN2:%.*]] = function_ref @nativeobject_plus :
531+
// CHECK: [[RESULT:%.*]] = apply [[FN2]]([[ARG]], [[ARG]])
532+
//
533+
// CHECK: bb4:
534+
// CHECK: strong_retain [[PAI]]
535+
// CHECK: [[OPAQUE_FN:%.*]] = function_ref @partial_apply_user
536+
// CHECK: apply [[OPAQUE_FN]]([[PAI]])
537+
// CHECK: strong_release [[PAI]]
538+
// CHECK: strong_release [[ARG]]
539+
// CHECK: return [[RESULT]]
540+
// CHECK: } // end sil function 'test_partial_nativeobject_foo'
541+
sil [transparent] @test_partial_nativeobject_foo : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
542+
bb0(%0 : $Builtin.NativeObject):
543+
%2 = function_ref @test_partial_nativeobject_bar : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
544+
%3 = function_ref @test_partial_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
545+
br bb1
546+
547+
bb1:
548+
strong_retain %0 : $Builtin.NativeObject
549+
%5 = partial_apply %3(%0) : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
550+
br bb2
551+
552+
bb2:
553+
strong_retain %0 : $Builtin.NativeObject
554+
strong_retain %5 : $@callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
555+
%13 = apply %2(%5, %0) : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
556+
br bb3
557+
558+
bb3:
559+
strong_retain %5 : $@callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
560+
%15 = function_ref @partial_apply_user : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
561+
apply %15(%5) : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
562+
strong_release %5 : $@callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
563+
strong_release %0 : $Builtin.NativeObject
564+
return %13 : $Builtin.NativeObject
565+
}
566+
567+
///////////////////////
568+
// Autoclosure Tests //
569+
///////////////////////
570+
452571
sil @true_getter : $@convention(thin) () -> Bool
453572

454573
sil [transparent] @short_circuit_or : $@convention(thin) (Bool, @callee_owned () -> Bool) -> Bool {

0 commit comments

Comments
 (0)