Skip to content

Lower move-only wrapper types earlier to disable the TrivialMoveOnlyTypeEliminator pass. #71538

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 1 commit into from
Feb 11, 2024

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Feb 10, 2024

This eliminates an in-between state where only some move-only wrapper types are removed. The long term fix is to teach SILGen to emit casts more precisely.

This fixes the consuming and borrowing keywords for some basic cases. In particular, if a nontrivial struct contains a trivial 'let' field, then this pass would result in invalid SIL types:

class C {}

struct BV {
let p: UnsafeRawPointer
let c: C
}

func getPointer(bv: consuming BV) -> UnsafeRawPointer {
return bv.p
}

Ultimately, this pass makes sense, but there is something strange about the way move-only-ness propagates into fields of aggregates which needs to be fixed first. Until then, other features are blocked on basic support for these keywords.

Fixes rdar://122701694 (consuming keyword causes verification error on invalid SIL types)

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves #NNNNN, fix apple/llvm-project#MMMMM.

This fixes the `consuming` and `borrowing` keywords for some basic
cases. In particular, if a nontrivial struct contains a trivial 'let'
field, then this pass would result in invalid SIL types:

class C {}

struct BV {
  let p: UnsafeRawPointer
  let c: C
}

func getPointer(bv: consuming BV) -> UnsafeRawPointer {
  return bv.p
}

Ultimately, this pass makes sense, but there is something strange
about the way move-only-ness propagates into fields of aggregates
which needs to be fixed first. Until then, other features are blocked
on basic support for these keywords.

Fixes rdar://122701694 (`consuming` keyword causes verification error on invalid SIL types)
@atrick atrick requested a review from gottesmm February 10, 2024 20:57
@atrick atrick requested a review from kavon as a code owner February 10, 2024 20:57
@atrick
Copy link
Contributor Author

atrick commented Feb 10, 2024

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Feb 10, 2024

@swift-ci test source compatibility

@atrick atrick requested a review from meg-gupta February 10, 2024 20:58
@atrick atrick changed the title Disable the TrivialMoveOnlyTypeEliminator pass. Lower move-only wrapper types earlier to disable the TrivialMoveOnlyTypeEliminator pass. Feb 11, 2024
Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

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