Skip to content

Commit 7d2a75d

Browse files
authored
Merge pull request #17327 from shajrawi/devirt_inline
2 parents 26af64d + adb53c4 commit 7d2a75d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/SILOptimizer/Utils/Devirtualize.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,9 @@ bool swift::canDevirtualizeClassMethod(FullApplySite AI,
516516

517517
// We need to disable the “effectively final” opt if a function is inlinable
518518
if (isEffectivelyFinalMethod &&
519-
F->getResilienceExpansion() == ResilienceExpansion::Minimal) {
519+
((F->getResilienceExpansion() == ResilienceExpansion::Minimal) ||
520+
AI.getFunction()->getResilienceExpansion() ==
521+
ResilienceExpansion::Minimal)) {
520522
DEBUG(llvm::dbgs() << " FAIL: Could not optimize function because "
521523
"it is an effectively-final inlinable: "
522524
<< F->getName() << "\n");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-frontend %s -whole-module-optimization -emit-sil | %FileCheck %s
2+
3+
public class C {
4+
public func f() {}
5+
}
6+
7+
//CHECK-LABEL: sil [serialized] @$S32devirtualize_inlinable_mandatory1gyyAA1CCF : $@convention(thin) (@guaranteed C) -> () {
8+
//CHECK: class_method %0 : $C, #C.f!1 : (C) -> () -> (), $@convention(method) (@guaranteed C) -> ()
9+
//CHECK-NOT: function_ref
10+
//CHECK: return
11+
@inlinable public func g(_ x: C) {
12+
x.f()
13+
}

0 commit comments

Comments
 (0)