Skip to content

Conversation

@pchintalapudi
Copy link
Member

Some arrays are only ever stored to, and can be safely removed without affecting program semantics. This PR removes such dead arrays by reusing AllocOpt infrastructure to remove dead objects. This also sets up future stack-based array optimizations by providing a method to delete newly dead arrays.

Depends on #43384 , #43547 , #43487 , and #43057 for array/escape analysis infrastructure improvements.

@aviatesk
Copy link
Member

aviatesk commented Dec 26, 2021

Can you change the base branch from which you made changes specific for this PR (for easier review)?

At a glance, it looks like you miss some cases when array allocations are "unsafe", e.g.:

function foo()
    a = Vector{Int}(undef, -10) # shouldn't be eliminated, otherwise it changes the error semantics
    nothing
end

Given that this essentially needs some shape information, I guess we can implement this at Julia level relatively easier?
But your work on LLVM level escape analysis (and shape analysis?) may enable further optimizations though.

@pchintalapudi
Copy link
Member Author

Since my branches are part of a fork, I've created a PR comparing this one and the branch elimination PR immediately before it here: pchintalapudi#1

@pchintalapudi pchintalapudi added compiler:codegen Generation of LLVM IR and native code performance Must go faster arrays [a, r, r, a, y, s] labels Dec 29, 2021
@pchintalapudi pchintalapudi force-pushed the pc/remove-array branch 3 times, most recently from de250fa to 506c3a6 Compare January 7, 2022 09:00
@pchintalapudi pchintalapudi marked this pull request as draft January 9, 2022 21:35
@pchintalapudi
Copy link
Member Author

Converting to draft because #43487, #43547, and #43384 are still under review.

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

Labels

arrays [a, r, r, a, y, s] compiler:codegen Generation of LLVM IR and native code performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants