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

Conversation

slavapestov
Copy link
Contributor

  • Description: lldb does not (yet) support resilient value types, so it uses a special frontend flag where resilience is bypassed and exact type layouts are computed from the swiftmodule file. However in one corner case, resilient and non-resilient enums could actually get different layouts if the resilient case was able to make use of spare bits because the payload types had known layouts from inside the module. This patch fixes the resilience bypass to compute the correct enum layout in this case.

  • Origination: Introduced when resilience was enabled by default for the stdlib and overlays, making some value types defined in overlays resilient.

  • Scope of the issue: Manifests as a runtime crash when manipulating multi-payload enums from lldb, Swift REPL or Playgrounds.

  • Risk: Low, this changes a code path that is only hit in the above cases.

  • Reviewed by: @jrose-apple reviewed the change on swift-4.2-branch already.

  • Tested: New test case added.

  • Radar: rdar://problem/40034143

The layout of an enum type will only use spare bits if the
payload types have a fixed size in all resilience domains
where they are visible. In practice, this means that:

- If the enum is internal or resilient, we can use spare bits
  if the payload types are fixed size from inside the current
  module.

- If the enum is public and not resilient, we can use spare bits
  if the payload types are fixed size from all resilience
  domains.

The bug was that the 'fixed size in all resilience domains'
check was returning true for resilient types when the
-enable-resilience-bypass flag was on. This is wrong, because
this meant that building a module with and without
-enable-resilience-bypass could produce different lowerings
for enum types.

Fixes <rdar://problem/40034143>.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov changed the title IRGen: Fix enum lowering with -enable-resilience-bypass IRGen: Fix enum lowering with -enable-resilience-bypass [4.2-04-30-2018] May 11, 2018
@slavapestov slavapestov merged commit 94be684 into swiftlang:swift-4.2-branch-04-30-2018 May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant