Skip to content

IRGen: Fix enum lowering with -enable-resilience-bypass [4.2-04-30-2018] #16528

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
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
4 changes: 3 additions & 1 deletion lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4067,8 +4067,10 @@ IRGenModule::getAddrOfGlobalUTF16ConstantString(StringRef utf8) {
/// - For classes, the superclass might change the size or number
/// of stored properties
bool IRGenModule::isResilient(NominalTypeDecl *D, ResilienceExpansion expansion) {
if (Types.isCompletelyFragile())
if (expansion == ResilienceExpansion::Maximal &&
Types.isCompletelyFragile()) {
return false;
}
return D->isResilient(getSwiftModule(), expansion);
}

Expand Down
9 changes: 9 additions & 0 deletions test/IRGen/Inputs/resilience_bypass/first.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class C {}

public struct S {
public let c: C

public init() {
self.c = C()
}
}
6 changes: 6 additions & 0 deletions test/IRGen/Inputs/resilience_bypass/second.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import first

public enum E {
case a(S)
case b(S)
}
16 changes: 16 additions & 0 deletions test/IRGen/resilience_bypass.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/first.swiftmodule -module-name=first %S/Inputs/resilience_bypass/first.swift
// RUN: %target-swift-frontend -emit-module -emit-module-path=%t/second.swiftmodule -module-name=second %S/Inputs/resilience_bypass/second.swift -I %t
// RUN: %target-swift-frontend -emit-ir -enable-resilience-bypass %s -I %t | %FileCheck %s -DINT=i%target-ptrsize

import second

// CHECK: define{{( protected)?}} swiftcc [[INT]] @"$S17resilience_bypass7getSizeSiyF"() {{.*}} {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret [[INT]] {{5|9}}
// CHECK-NEXT: }

public func getSize() -> Int {
return MemoryLayout<E>.size
}