Skip to content

Conversation

eeckstein
Copy link
Contributor

Enum types may have incomplete lifetimes in address form for trivial case values. When promoted to value form, they will end up with incomplete ossa lifetimes. Because we know that the incomplete enum values are trivial enum cases we complete their lifetimes with end_lifetime instead of destroy_value. This is especially important for Embedded Swift where we are not allowed to insert destroys which were not there before.

Fixes a compiler crash in Embedded Swift caused by de-virtualizing such an inserted destroy and ending up with a non-specialized generic function.

rdar://158807801

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci test windows

@nate-chandler
Copy link
Contributor

Please add some specify_test tests that illustrate why this is an argument that should be passed into the utility rather than something that it should discover on its own for example by checking that a value is trivial.

Enum types may have incomplete lifetimes in address form for trivial case values. When promoted to value form, they will end up with incomplete ossa lifetimes.
Because we know that the incomplete enum values are trivial enum cases we complete their lifetimes with `end_lifetime` instead of `destroy_value`.
This is especially important for Embedded Swift where we are not allowed to insert destroys which were not there before.

Fixes a compiler crash in Embedded Swift caused by de-virtualizing such an inserted destroy and ending up with a non-specialized generic function.

rdar://158807801
@eeckstein
Copy link
Contributor Author

I added a test.

that illustrate why this is an argument that should be passed into the utility rather than something that it should discover on its own for example by checking that a value is trivial.

This is not about the value being trivial. The utility cannot know that an end_lifetime should be used, because this is something only the caller (in this case mem2reg) knows: It needs to use end_lifetime because the incomplete values are (non-trivial) enums with a trivial or no payload.

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit 2c1dea9 into swiftlang:main Aug 25, 2025
5 checks passed
@eeckstein eeckstein deleted the fix-mem2reg branch August 25, 2025 15:46
@meg-gupta
Copy link
Contributor

lgtm

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.

3 participants