Skip to content

Commit 07248c7

Browse files
Merge pull request #83904 from aschwaighofer/mark_dep_closure_inline_heuristic
ConstantTracker: Look through mark_dependence instructions
2 parents 9779591 + 2fd9048 commit 07248c7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ SILValue swift::stripFunctionConversions(SILValue val) {
135135
val = cvt->getOperand();
136136
result = val;
137137
continue;
138+
} else if (auto md = dyn_cast<MarkDependenceInst>(val)) {
139+
val = md->getValue();
140+
result = val;
138141
} else {
139142
break;
140143
}

test/SILOptimizer/inline_heuristics.sil

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,27 @@ enum E {
3030
case B((Int32) -> Int32)
3131
}
3232

33+
class C {
34+
init()
35+
}
3336

3437
// CHECK-LABEL: sil @testDirectClosure
3538
// CHECK: [[C:%[0-9]+]] = thin_to_thick_function
36-
// CHECK: apply [[C]](
39+
// CHECK: [[MD:%[0-9]+]] = mark_dependence [[C]]
40+
// CHECK: apply [[MD]](
3741
// CHECK: return
3842

3943
// CHECK-LOG-LABEL: Inline into caller: testDirectClosure
4044
// CHECK-LOG-NEXT: decision {{.*}}, b=70,
4145

42-
sil @testDirectClosure : $@convention(thin) () -> Int32 {
43-
bb0:
46+
sil @testDirectClosure : $@convention(thin) (@guaranteed C) -> Int32 {
47+
bb0(%c : $C):
4448
%0 = function_ref @takeDirectClosure : $@convention(thin) (@owned @callee_guaranteed (Int32) -> Int32) -> Int32
4549
%1 = function_ref @closure : $@convention(thin) (Int32) -> Int32
4650
%2 = thin_to_thick_function %1 : $@convention(thin) (Int32) -> Int32 to $@callee_guaranteed (Int32) -> Int32
47-
%3 = apply %0(%2) : $@convention(thin) (@owned @callee_guaranteed (Int32) -> Int32) -> Int32
48-
return %3 : $Int32
51+
%3 = mark_dependence %2 on %c
52+
%4 = apply %0(%3) : $@convention(thin) (@owned @callee_guaranteed (Int32) -> Int32) -> Int32
53+
return %4 : $Int32
4954
}
5055

5156
sil @takeDirectClosure : $@convention(thin) (@owned @callee_guaranteed (Int32) -> Int32) -> Int32 {

0 commit comments

Comments
 (0)