forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimizer: compute side-effect-freeness for array allocations (JuliaL…
…ang#43565) This would be useful for Julia-level optimizations on arrays. Initially I want to have this in order to add array primitives support in EscapeAnalysis.jl, which should help us implement a variety of array optimizations including dead array allocation elimination, copy-elision from `Array` to `ImmutableArray` conversion (JuliaLang#42465), etc., but I found this might be already useful for us since this enables some DCE in very simple cases like: ```julia julia> function simple!(x::T) where T d = IdDict{T,T}() # dead alloc # ... computations that don't use `d` at all return nothing end simple! (generic function with 1 method) julia> @code_typed simple!("foo") CodeInfo( 1 ─ return Main.nothing ) => Nothing ``` This enhancement is super limited though, e.g. DCE won't happen when array allocation involves other primitive operations like `arrayset`: ```julia julia> code_typed() do a = Int[0,1,2] nothing end 1-element Vector{Any}: CodeInfo( 1 ─ %1 = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Vector{Int64}, svec(Any, Int64), 0, :(:ccall), Vector{Int64}, 3, 3))::Vector{Int64} │ Base.arrayset(false, %1, 0, 1)::Vector{Int64} │ Base.arrayset(false, %1, 1, 2)::Vector{Int64} │ Base.arrayset(false, %1, 2, 3)::Vector{Int64} └── return Main.nothing ) => Nothing ``` Further enhancement o optimize cases like above will be based on top of incoming EA.jl (Julia-level escape analysis) or LLVM-level escape analysis.
- Loading branch information
1 parent
b4729a8
commit ae494c8
Showing
11 changed files
with
205 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.