Skip to content

[move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen. #66505

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
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
6 changes: 4 additions & 2 deletions lib/IRGen/GenType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2897,9 +2897,11 @@ static bool tryEmitDeinitCall(IRGenFunction &IGF,
return false;
}

auto deinitTable = IGF.getSILModule().lookUpMoveOnlyDeinit(nominal);
auto deinitTable = IGF.getSILModule().lookUpMoveOnlyDeinit(
nominal, false /*deserialize lazily*/);

// If we do not have a deinit table, call the value witness instead.
// If we do not have a deinit table already deserialized, call the value
// witness instead.
if (!deinitTable) {
irgen::emitDestroyCall(IGF, T, indirect());
indirectCleanup();
Expand Down
66 changes: 54 additions & 12 deletions test/Interpreter/Inputs/moveonly_split_module_source_input.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,61 @@

#if TEST_LIBRARY_EVOLUTION
#if TEST_LIBRARY_WITH_LIBRARY_EVOLUTION
public struct MoveOnly : ~Copyable {
var name = "John"
public init() {}
deinit {
print("==> I am in the deinit resiliently!")
print("==> My name is: \(name)!")
}
#if MAKE_LARGE
var x0 = 0, x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 0,
x8 = 0, x9 = 0, x10 = 0, x11 = 0, x12 = 0, x13 = 0, x14 = 0, x15 = 0,
x16 = 0, x17 = 0, x18 = 0, x19 = 0, x20 = 0, x21 = 0, x22 = 0,
x23 = 0, x24 = 0, x25 = 0, x26 = 0, x27 = 0, x28 = 0, x29 = 0,
x30 = 0, x31 = 0, x32 = 0, x33 = 0, x34 = 0, x35 = 0, x36 = 0,
x37 = 0, x38 = 0
#endif
var name = "John"

public init() {}
deinit {
print("==> LIBRARY_EVOLUTION: I am in the deinit!")
print("==> My name is: \(name)!")
}
}
#else

#if TEST_LIBRARY_WITHOUT_LIBRARY_EVOLUTION

public struct MoveOnly : ~Copyable {
#if MAKE_LARGE
var x0 = 0, x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 0,
x8 = 0, x9 = 0, x10 = 0, x11 = 0, x12 = 0, x13 = 0, x14 = 0, x15 = 0,
x16 = 0, x17 = 0, x18 = 0, x19 = 0, x20 = 0, x21 = 0, x22 = 0,
x23 = 0, x24 = 0, x25 = 0, x26 = 0, x27 = 0, x28 = 0, x29 = 0,
x30 = 0, x31 = 0, x32 = 0, x33 = 0, x34 = 0, x35 = 0, x36 = 0,
x37 = 0, x38 = 0
#endif
var name = "John"
public init() {}
deinit {
print("==> LIBRARY: I am in the deinit!")
print("==> My name is: \(name)!")
}
}

#else

struct MoveOnly : ~Copyable {
var name = "John"
deinit {
print("==> I am in the deinit!")
print("==> My name is: \(name)!")
}
#if MAKE_LARGE
var x0 = 0, x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 0,
x8 = 0, x9 = 0, x10 = 0, x11 = 0, x12 = 0, x13 = 0, x14 = 0, x15 = 0,
x16 = 0, x17 = 0, x18 = 0, x19 = 0, x20 = 0, x21 = 0, x22 = 0,
x23 = 0, x24 = 0, x25 = 0, x26 = 0, x27 = 0, x28 = 0, x29 = 0,
x30 = 0, x31 = 0, x32 = 0, x33 = 0, x34 = 0, x35 = 0, x36 = 0,
x37 = 0, x38 = 0
#endif

var name = "John"
deinit {
print("==> I am in the deinit!")
print("==> My name is: \(name)!")
}
}

#endif
#endif
54 changes: 54 additions & 0 deletions test/Interpreter/moveonly_deinit_separate_library.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Normal test

// RUN: %empty-directory(%t/normal)
// RUN: %target-build-swift-dylib(%t/normal/%target-library-name(MoveOnlySplit)) %S/Inputs/moveonly_split_module_source_input.swift -emit-module -emit-module-path %t/normal/MoveOnlySplit.swiftmodule -module-name MoveOnlySplit -DTEST_LIBRARY_WITHOUT_LIBRARY_EVOLUTION
// RUN: %target-codesign %t/normal/%target-library-name(MoveOnlySplit)

// RUN: %target-build-swift %s -lMoveOnlySplit -I %t/normal -L %t/normal -o %t/normal/main %target-rpath(%t/normal)
// RUN: %target-codesign %t/normal/main
// RUN: %target-run %t/normal/main %t/normal/%target-library-name(MoveOnlySplit) | %FileCheck %s

// Normal large

// RUN: %empty-directory(%t/normal_large)
// RUN: %target-build-swift-dylib(%t/normal_large/%target-library-name(MoveOnlySplit)) %S/Inputs/moveonly_split_module_source_input.swift -emit-module -emit-module-path %t/normal_large/MoveOnlySplit.swiftmodule -module-name MoveOnlySplit -DTEST_LIBRARY_WITHOUT_LIBRARY_EVOLUTION -DMAKE_LARGE
// RUN: %target-codesign %t/normal_large/%target-library-name(MoveOnlySplit)

// RUN: %target-build-swift %s -lMoveOnlySplit -I %t/normal_large -L %t/normal_large -o %t/normal_large/main %target-rpath(%t/normal_large)
// RUN: %target-codesign %t/normal_large/main
// RUN: %target-run %t/normal_large/main %t/normal_large/%target-library-name(MoveOnlySplit) | %FileCheck %s

// Library evolution test

// RUN: %empty-directory(%t/library_evolution)
// RUN: %target-build-swift-dylib(%t/library_evolution/%target-library-name(MoveOnlySplit)) %S/Inputs/moveonly_split_module_source_input.swift -emit-module -emit-module-path %t/library_evolution/MoveOnlySplit.swiftmodule -module-name MoveOnlySplit -DTEST_LIBRARY_WITH_LIBRARY_EVOLUTION
// RUN: %target-codesign %t/library_evolution/%target-library-name(MoveOnlySplit)

// RUN: %target-build-swift %s -lMoveOnlySplit -I %t/library_evolution -L %t/library_evolution -o %t/library_evolution/main %target-rpath(%t/library_evolution)
// RUN: %target-codesign %t/library_evolution/main
// RUN: %target-run %t/library_evolution/main %t/library_evolution/%target-library-name(MoveOnlySplit) | %FileCheck -check-prefix=CHECK-LIBRARY-EVOLUTION %s

// Library evolution large

// RUN: %empty-directory(%t/library_evolution_large)
// RUN: %target-build-swift-dylib(%t/library_evolution_large/%target-library-name(MoveOnlySplit)) %S/Inputs/moveonly_split_module_source_input.swift -emit-module -emit-module-path %t/library_evolution_large/MoveOnlySplit.swiftmodule -module-name MoveOnlySplit -DTEST_LIBRARY_WITH_LIBRARY_EVOLUTION -DMAKE_LARGE
// RUN: %target-codesign %t/library_evolution_large/%target-library-name(MoveOnlySplit)

// RUN: %target-build-swift %s -lMoveOnlySplit -I %t/library_evolution_large -L %t/library_evolution_large -o %t/library_evolution_large/main %target-rpath(%t/library_evolution_large)
// RUN: %target-codesign %t/library_evolution_large/main
// RUN: %target-run %t/library_evolution_large/main %t/library_evolution_large/%target-library-name(MoveOnlySplit) | %FileCheck -check-prefix=CHECK-LIBRARY-EVOLUTION %s


// REQUIRES: executable_test

import MoveOnlySplit

func main() {
// CHECK: ==> LIBRARY: I am in the deinit!
// CHECK: ==> My name is: John!
// CHECK-LIBRARY-EVOLUTION: ==> LIBRARY_EVOLUTION: I am in the deinit!
// CHECK-LIBRARY-EVOLUTION: ==> My name is: John!
let server = MoveOnly()
}

main()
17 changes: 12 additions & 5 deletions test/Interpreter/moveonly_split_module_source_deinit.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@

// Normal test.
// RUN: %empty-directory(%t/normal)
// RUN: %target-swiftc_driver -emit-module -module-name server -emit-module-path %t/normal/server.swiftmodule %s %S/Inputs/moveonly_split_module_source_input.swift
// RUN: %target-swiftc_driver -emit-executable -module-name server -emit-module-path %t/normal/server.swiftmodule %s %S/Inputs/moveonly_split_module_source_input.swift -o %t/normal/server
// RUN: %target-codesign %t/normal/server
// RUN: %target-run %t/normal/server | %FileCheck %s

// RUN: %empty-directory(%t)
// RUN: %target-swiftc_driver -emit-module -module-name server -emit-module-path %t/server.swiftmodule %s %S/Inputs/moveonly_split_module_source_input.swift
// RUN: %target-swiftc_driver -emit-executable -module-name server -emit-module-path %t/server.swiftmodule %s %S/Inputs/moveonly_split_module_source_input.swift -o %t/server
// RUN: %target-codesign %t/server
// RUN: %target-run %t/server | %FileCheck %s
// Large test.
// RUN: %empty-directory(%t/large)
// RUN: %target-swiftc_driver -emit-module -module-name server -emit-module-path %t/large/server.swiftmodule %s %S/Inputs/moveonly_split_module_source_input.swift -DMAKE_LARGE
// RUN: %target-swiftc_driver -emit-executable -module-name server -emit-module-path %t/large/server.swiftmodule %s %S/Inputs/moveonly_split_module_source_input.swift -o %t/large/server
// RUN: %target-codesign %t/large/server
// RUN: %target-run %t/large/server | %FileCheck %s

// REQUIRES: executable_test

Expand Down

This file was deleted.