File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -576,6 +576,9 @@ struct SILDeclRef {
576
576
// / for e.g a lazy variable getter.
577
577
bool hasUserWrittenCode () const ;
578
578
579
+ // / True if the referenced entity is a getter function.
580
+ bool isGetter () const ;
581
+
579
582
// / Return the scope in which the parent class of a method (i.e. class
580
583
// / containing this declaration) can be subclassed, returning NotApplicable if
581
584
// / this is not a method, there is no such class, or the class cannot be
Original file line number Diff line number Diff line change @@ -387,6 +387,12 @@ bool SILDeclRef::hasUserWrittenCode() const {
387
387
llvm_unreachable (" Unhandled case in switch!" );
388
388
}
389
389
390
+ bool SILDeclRef::isGetter () const {
391
+ if (auto *accessor = dyn_cast_or_null<AccessorDecl>(getFuncDecl ()))
392
+ return accessor->isGetter ();
393
+ return false ;
394
+ }
395
+
390
396
namespace {
391
397
enum class LinkageLimit {
392
398
// / No limit.
Original file line number Diff line number Diff line change @@ -1197,9 +1197,16 @@ void SILGenModule::emitOrDelayFunction(SILDeclRef constant) {
1197
1197
1198
1198
auto emitAfter = lastEmittedFunction;
1199
1199
1200
+ // When compiling at Onone, getters shouldn't be delayed, even if they don't
1201
+ // have user written code because they can still be accessible in the
1202
+ // debugger.
1203
+ bool isOnoneGetter =
1204
+ constant.isGetter () &&
1205
+ M.getOptions ().OptMode == OptimizationMode::NoOptimization;
1206
+
1200
1207
// Implicit decls may be delayed if they can't be used externally.
1201
1208
auto linkage = constant.getLinkage (ForDefinition);
1202
- bool mayDelay = !constant.hasUserWrittenCode () &&
1209
+ bool mayDelay = !isOnoneGetter && ! constant.hasUserWrittenCode () &&
1203
1210
!constant.isDynamicallyReplaceable () &&
1204
1211
!isPossiblyUsedExternally (linkage, M.isWholeModule ());
1205
1212
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ class Baz: Foo {
55
55
56
56
struct Qux {
57
57
@Bar ( wrappedValue: Baz ( ) ) private var baz : Baz
58
+ // Baz instance that is never accessed.
59
+ @Bar ( wrappedValue: Baz ( ) ) private var baz2 : Baz
58
60
59
61
func f( ) {
60
62
print ( self . baz) // break here
@@ -64,3 +66,4 @@ let qux = Qux()
64
66
qux. f ( )
65
67
66
68
// CHECK: !DISubprogram(name: "baz.get"
69
+ // CHECK: !DISubprogram(name: "baz2.get"
You can’t perform that action at this time.
0 commit comments