Skip to content

Fix OSSA RAUW utility for move_value that changes ownership. #83403

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
Jul 30, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jul 29, 2025

CSE "looks through" ownership operations, which can lead to problematic substitutions. This fix cleans up owned operands even when the newly substituted value has no ownership.

For example:

%0 = enum $Optional<Interface>, #Optional.none!enumelt
%1 = move_value [lexical] %0
%2 = enum $Optional<Interface>, #Optional.none!enumelt
%3 = struct $EndpointCommon (%2)
%4 = struct $EndpointCommon (%1)

CSE combines the two .none enums:

%0 = enum $Optional<Interface>, #Optional.none!enumelt
%2 = enum $Optional<Interface>, #Optional.none!enumelt

Then combines the two structs:

%3 = struct $EndpointCommon (%2)
%4 = struct $EndpointCommon (%1)

Leaving a dead move_value:

%1 = move_value [lexical] %0

which is invalid OSSA. Now, when replacing the owned struct, we add destroys for its operands.

Fixes rdar://156431548 Error! Found a leaked owned value that was never consumed.

@atrick atrick requested a review from eeckstein as a code owner July 29, 2025 18:15
@atrick atrick requested a review from meg-gupta July 29, 2025 18:16
@atrick
Copy link
Contributor Author

atrick commented Jul 29, 2025

@swift-ci test

CSE "looks through" ownership operations, which can lead to problematic substitutions. This fix cleans up owned operands even when the newly substituted value has no ownership.

For example:

    %0 = enum $Optional<Interface>, #Optional.none!enumelt
    %1 = move_value [lexical] %0
    %2 = enum $Optional<Interface>, #Optional.none!enumelt
    %3 = struct $EndpointCommon (%2)
    %4 = struct $EndpointCommon (%1)

CSE combines the two .none enums:

    %0 = enum $Optional<Interface>, #Optional.none!enumelt
    %2 = enum $Optional<Interface>, #Optional.none!enumelt

Then combines the two structs:

    %3 = struct $EndpointCommon (%2)
    %4 = struct $EndpointCommon (%1)

Leaving a dead move_value:

    %1 = move_value [lexical] %0

which is invalid OSSA. Now, when replacing the owned struct, we add destroys for its operands.

Fixes rdar://156431548 Error! Found a leaked owned value that was never consumed.
@atrick
Copy link
Contributor Author

atrick commented Jul 29, 2025

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jul 30, 2025

Failing on main
SymbolGraph/Relationships/MemberOf/Basic.swift

@atrick
Copy link
Contributor Author

atrick commented Jul 30, 2025

@swift-ci smoke test macOS

@atrick atrick enabled auto-merge July 30, 2025 05:05
@atrick atrick merged commit 648722e into swiftlang:main Jul 30, 2025
4 of 5 checks passed
@atrick atrick deleted the fix-ossa-rauw branch July 30, 2025 15:46
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