Skip to content

Revert "Revert "Enable stdlib resilience"" #15030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Serialization/SerializedModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ FileUnit *SerializedModuleLoader::loadAST(
isFramework, loadedModuleFile,
&extendedInfo);
if (loadInfo.status == serialization::Status::Valid) {
M.setResilienceStrategy(extendedInfo.getResilienceStrategy());
// In LLDB always use the default resilience strategy, so IRGen can query
// the size of resilient types.
if (!Ctx.LangOpts.DebuggerSupport)
M.setResilienceStrategy(extendedInfo.getResilienceStrategy());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test for this? We already have a frontend flag to fake debugger support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer is of course, yes we should, but do you have any suggestion how this could be tested inside of swift? It is indirectly tested by the LLDB testsuite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SIL output should be different when passing around a struct by value. You should be able to define a resilient module with a public struct, and then examine the output of -emit-silgen on a client function that takes an argument of that type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think it’s worth the effort. The lldb test suite fails without this hack, and it’s only temporary. It will go away once lldb can use remote mirrors to calculate sizes of resilient types.


// We've loaded the file. Now try to bring it into the AST.
auto fileUnit = new (Ctx) SerializedASTFile(M, *loadedModuleFile,
Expand Down
18 changes: 16 additions & 2 deletions test/DebugInfo/resilience.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// RUN: %empty-directory(%t)
//
// Compile the external swift module.
// RUN: %target-swift-frontend -g -emit-module -enable-resilience \
// RUN: -emit-module-path=%t/resilient_struct.swiftmodule \
// RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
// RUN: %target-swift-frontend -g -I %t -emit-ir -enable-resilience %s \
// RUN: | %FileCheck %s
//
// RUN: %target-swift-frontend -g -I %t -emit-ir -enable-resilience %s -o - \
// RUN: | %FileCheck %s
//
// RUN: %target-swift-frontend -g -I %t -emit-sil -enable-resilience %s -o - \
// RUN: | %FileCheck %s --check-prefix=CHECK-SIL
// RUN: %target-swift-frontend -g -I %t -emit-sil -enable-resilience %s -o - \
// RUN: -debugger-support | %FileCheck %s --check-prefix=CHECK-LLDB
import resilient_struct

func use<T>(_ t: T) {}
Expand All @@ -23,3 +31,9 @@ public func f() {
// FIXME-NOT: size:
// CHECK: =
}

// CHECK-SIL: // f()
// CHECK-LLDB: // f()
// CHECK-SIL: %0 = alloc_stack $Size, let, name "s1"
// CHECK-LLDB: %0 = metatype $@thin Size.Type
// CHECK-LLDB: debug_value %{{.*}} : $Size, let, name "s1"