IRGen: Fix enum lowering with -enable-resilience-bypass [4.2-04-30-2018] #16528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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