Skip to content

Julia level SROA ignores swapfield and replacefield #53052

@gbaraldi

Description

@gbaraldi
Member

I'm not sure if this can cause correctness issues, but we might be losing optimizations because of this.

# check whether this statement is `getfield` / `setfield!` (or other "interesting" statement)

Activity

topolarity

topolarity commented on Feb 22, 2024

@topolarity
Member

Not a soundness problem, since these count as an "escaping" usage:

# Check if there are any uses we did not account for. If so, the variable
# escapes and we cannot eliminate the allocation. This works, because we're guaranteed
# not to include any intermediaries that have dead uses. As a result, missing uses will only ever
# show up in the nuses_total count.

But still worth fixing.

gbaraldi

gbaraldi commented on Feb 22, 2024

@gbaraldi
MemberAuthor

They are as escaping as setfield! (and kind of behave very much like it) with swap just being get + set.

vtjnash

vtjnash commented on Feb 22, 2024

@vtjnash
SponsorMember

There is not usually any loss of optimization, since generally the value already "escaped" to another thread anyways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:optimizerOptimization passes (mostly in base/compiler/ssair/)performanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @vtjnash@oscardssmith@gbaraldi@topolarity

        Issue actions

          Julia level SROA ignores swapfield and replacefield · Issue #53052 · JuliaLang/julia