Skip to content

Commit 5fb550e

Browse files
authored
Merge pull request #12013 from eeckstein/fix-bca-4.0
Fix trivial bug in callee analysis: thin functions aren't necessarily function refs.
2 parents cb8ebb3 + de3e31a commit 5fb550e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/SILOptimizer/Analysis/BasicCalleeAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ CalleeList CalleeCache::getCalleeListForCalleeKind(SILValue Callee) const {
201201
return CalleeList();
202202

203203
case ValueKind::ThinToThickFunctionInst:
204-
Callee = cast<ThinToThickFunctionInst>(Callee)->getOperand();
205-
LLVM_FALLTHROUGH;
204+
return getCalleeListForCalleeKind(
205+
cast<ThinToThickFunctionInst>(Callee)->getOperand());
206206

207207
case ValueKind::FunctionRefInst:
208208
return CalleeList(cast<FunctionRefInst>(Callee)->getReferencedFunction());

test/SILOptimizer/escape_analysis.sil

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,17 @@ bb3(%6: $X):
14301430
return %8 : $()
14311431
}
14321432

1433+
// CHECK-LABEL: CG of check_look_through_thin_to_thick
1434+
// CHECK-NEXT: Arg %0 Esc: A, Succ:
1435+
// CHECK-NEXT: End
1436+
sil @check_look_through_thin_to_thick: $(@convention(thin) () -> ()) -> () {
1437+
bb0(%0 : $@convention(thin) () -> ()):
1438+
%1 = thin_to_thick_function %0 : $@convention(thin) () -> () to $@callee_owned () -> ()
1439+
%2 = apply %1() : $@callee_owned () -> ()
1440+
%3 = tuple ()
1441+
return %3 : $()
1442+
}
1443+
14331444
// X.deinit
14341445
// CHECK-LABEL: CG of _T04main1XCfD
14351446
// CHECK: Arg %0 Esc: A, Succ:

0 commit comments

Comments
 (0)