Skip to content

Conversation

slavapestov
Copy link
Contributor

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.

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
Copy link
Contributor Author

@jrose-apple Please review for 4.2

@jrose-apple
Copy link
Contributor

I've convinced myself the logic in the description makes sense, but I don't (yet) see how that corresponds to the code change. What makes internal and resilient enums use Maximal but public non-resilient enums use Minimal here? How does this affect other callers using Minimal?

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Slava came to explain this in person. The short form is that this is like saying "pretend LLDB is inside the current module, but don't pretend the entire world is non-resilient". This is closer to how IRGen normally behaves, and does of course fix this issue. So, LGTM.

@slavapestov
Copy link
Contributor Author

That’s a good explanation, thanks.

@slavapestov slavapestov merged commit dd5df04 into swiftlang:swift-4.2-branch May 10, 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.

2 participants