Just a quick confirmation that the new Fix
functor operates as expected, running @code_llvm
confirms it still compiles to the same thing.
julia> f() = map([1,2,3]) do x x+1 ; end
f (generic function with 1 method)
julia> g() = map(x->x+1,[1,2,3])
g (generic function with 1 method)
julia> h() = FixLast(map, [1,2,3])(x->x+1)
h (generic function with 1 method)
julia> i() = Fix{(2,)}(map, ([1,2,3],))(x->x+1)
i (generic function with 1 method)
result
julia> @code_llvm f()
; @ REPL[17]:1 within `f`
; Function Attrs: uwtable
define nonnull {}* @julia_f_2255() #0 {
pass.2:
%gcframe9 = alloca [4 x {}*], align 16
%gcframe9.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 0
%0 = bitcast [4 x {}*]* %gcframe9 to i8*
call void @llvm.memset.p0i8.i32(i8* noundef nonnull align 16 dereferenceable(32) %0, i8 0, i32 32, i1 false)
%1 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 2
%2 = bitcast {}** %1 to { {}* }*
%3 = call {}*** inttoptr (i64 1699154720 to {}*** ()*)() #3
; ┌ @ array.jl:126 within `vect`
; │┌ @ array.jl:679 within `_array_for` @ array.jl:676
; ││┌ @ abstractarray.jl:840 within `similar` @ abstractarray.jl:841
; │││┌ @ boot.jl:468 within `Array` @ boot.jl:459
%4 = bitcast [4 x {}*]* %gcframe9 to i64*
store i64 8, i64* %4, align 16
%5 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 1
%6 = bitcast {}** %5 to {}***
%7 = load {}**, {}*** %3, align 8
store {}** %7, {}*** %6, align 8
%8 = bitcast {}*** %3 to {}***
store {}** %gcframe9.sub, {}*** %8, align 8
%9 = call nonnull {}* inttoptr (i64 1698961392 to {}* ({}*, i64)*)({}* inttoptr (i64 294838384 to {}*), i64 3)
%10 = bitcast {}* %9 to i64**
%11 = load i64*, i64** %10, align 8
; │└└└
; │┌ @ array.jl:966 within `setindex!`
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 1, i64 2>, <2 x i64>* %12, align 8
%13 = getelementptr inbounds i64, i64* %11, i64 2
store i64 3, i64* %13, align 8
; └└
; ┌ @ abstractarray.jl:2933 within `map`
; │┌ @ array.jl:716 within `collect_similar`
store {}* %9, {}** %1, align 16
%14 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 3
store {}* %9, {}** %14, align 8
%15 = call nonnull {}* @j__collect_2257({}* nonnull %9, { {}* }* nocapture readonly %2) #0
%16 = load {}*, {}** %5, align 8
%17 = bitcast {}*** %3 to {}**
store {}* %16, {}** %17, align 8
; └└
ret {}* %15
}
julia> @code_llvm g()
; @ REPL[18]:1 within `g`
; Function Attrs: uwtable
define nonnull {}* @julia_g_2258() #0 {
pass.2:
%gcframe9 = alloca [4 x {}*], align 16
%gcframe9.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 0
%0 = bitcast [4 x {}*]* %gcframe9 to i8*
call void @llvm.memset.p0i8.i32(i8* noundef nonnull align 16 dereferenceable(32) %0, i8 0, i32 32, i1 false)
%1 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 2
%2 = bitcast {}** %1 to { {}* }*
%3 = call {}*** inttoptr (i64 1699154720 to {}*** ()*)() #3
; ┌ @ array.jl:126 within `vect`
; │┌ @ array.jl:679 within `_array_for` @ array.jl:676
; ││┌ @ abstractarray.jl:840 within `similar` @ abstractarray.jl:841
; │││┌ @ boot.jl:468 within `Array` @ boot.jl:459
%4 = bitcast [4 x {}*]* %gcframe9 to i64*
store i64 8, i64* %4, align 16
%5 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 1
%6 = bitcast {}** %5 to {}***
%7 = load {}**, {}*** %3, align 8
store {}** %7, {}*** %6, align 8
%8 = bitcast {}*** %3 to {}***
store {}** %gcframe9.sub, {}*** %8, align 8
%9 = call nonnull {}* inttoptr (i64 1698961392 to {}* ({}*, i64)*)({}* inttoptr (i64 294838384 to {}*), i64 3)
%10 = bitcast {}* %9 to i64**
%11 = load i64*, i64** %10, align 8
; │└└└
; │┌ @ array.jl:966 within `setindex!`
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 1, i64 2>, <2 x i64>* %12, align 8
%13 = getelementptr inbounds i64, i64* %11, i64 2
store i64 3, i64* %13, align 8
; └└
; ┌ @ abstractarray.jl:2933 within `map`
; │┌ @ array.jl:716 within `collect_similar`
store {}* %9, {}** %1, align 16
%14 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 3
store {}* %9, {}** %14, align 8
%15 = call nonnull {}* @j__collect_2260({}* nonnull %9, { {}* }* nocapture readonly %2) #0
%16 = load {}*, {}** %5, align 8
%17 = bitcast {}*** %3 to {}**
store {}* %16, {}** %17, align 8
; └└
ret {}* %15
}
julia> @code_llvm h()
; @ REPL[19]:1 within `h`
; Function Attrs: uwtable
define nonnull {}* @julia_h_2261() #0 {
pass.2:
%gcframe9 = alloca [4 x {}*], align 16
%gcframe9.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 0
%0 = bitcast [4 x {}*]* %gcframe9 to i8*
call void @llvm.memset.p0i8.i32(i8* noundef nonnull align 16 dereferenceable(32) %0, i8 0, i32 32, i1 false)
%1 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 2
%2 = bitcast {}** %1 to { {}* }*
%3 = call {}*** inttoptr (i64 1699154720 to {}*** ()*)() #3
; ┌ @ array.jl:126 within `vect`
; │┌ @ array.jl:679 within `_array_for` @ array.jl:676
; ││┌ @ abstractarray.jl:840 within `similar` @ abstractarray.jl:841
; │││┌ @ boot.jl:468 within `Array` @ boot.jl:459
%4 = bitcast [4 x {}*]* %gcframe9 to i64*
store i64 8, i64* %4, align 16
%5 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 1
%6 = bitcast {}** %5 to {}***
%7 = load {}**, {}*** %3, align 8
store {}** %7, {}*** %6, align 8
%8 = bitcast {}*** %3 to {}***
store {}** %gcframe9.sub, {}*** %8, align 8
%9 = call nonnull {}* inttoptr (i64 1698961392 to {}* ({}*, i64)*)({}* inttoptr (i64 294838384 to {}*), i64 3)
%10 = bitcast {}* %9 to i64**
%11 = load i64*, i64** %10, align 8
; │└└└
; │┌ @ array.jl:966 within `setindex!`
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 1, i64 2>, <2 x i64>* %12, align 8
%13 = getelementptr inbounds i64, i64* %11, i64 2
store i64 3, i64* %13, align 8
; └└
; ┌ @ Untitled-6:4 within `FixLast`
; │┌ @ Untitled-6:4 within `#_#24`
; ││┌ @ abstractarray.jl:2933 within `map`
; │││┌ @ array.jl:716 within `collect_similar`
store {}* %9, {}** %1, align 16
%14 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 3
store {}* %9, {}** %14, align 8
%15 = call nonnull {}* @j__collect_2263({}* nonnull %9, { {}* }* nocapture readonly %2) #0
%16 = load {}*, {}** %5, align 8
%17 = bitcast {}*** %3 to {}**
store {}* %16, {}** %17, align 8
; └└└└
ret {}* %15
}
julia> @code_llvm i()
; @ REPL[20]:1 within `i`
; Function Attrs: uwtable
define nonnull {}* @julia_i_2264() #0 {
pass.2:
%gcframe9 = alloca [4 x {}*], align 16
%gcframe9.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 0
%0 = bitcast [4 x {}*]* %gcframe9 to i8*
call void @llvm.memset.p0i8.i32(i8* noundef nonnull align 16 dereferenceable(32) %0, i8 0, i32 32, i1 false)
%1 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 2
%2 = bitcast {}** %1 to { {}* }*
%3 = call {}*** inttoptr (i64 1699154720 to {}*** ()*)() #3
; ┌ @ array.jl:126 within `vect`
; │┌ @ array.jl:679 within `_array_for` @ array.jl:676
; ││┌ @ abstractarray.jl:840 within `similar` @ abstractarray.jl:841
; │││┌ @ boot.jl:468 within `Array` @ boot.jl:459
%4 = bitcast [4 x {}*]* %gcframe9 to i64*
store i64 8, i64* %4, align 16
%5 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 1
%6 = bitcast {}** %5 to {}***
%7 = load {}**, {}*** %3, align 8
store {}** %7, {}*** %6, align 8
%8 = bitcast {}*** %3 to {}***
store {}** %gcframe9.sub, {}*** %8, align 8
%9 = call nonnull {}* inttoptr (i64 1698961392 to {}* ({}*, i64)*)({}* inttoptr (i64 294838384 to {}*), i64 3)
%10 = bitcast {}* %9 to i64**
%11 = load i64*, i64** %10, align 8
; │└└└
; │┌ @ array.jl:966 within `setindex!`
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 1, i64 2>, <2 x i64>* %12, align 8
%13 = getelementptr inbounds i64, i64* %11, i64 2
store i64 3, i64* %13, align 8
; └└
; ┌ @ Untitled-6:60 within `Fix`
; │┌ @ Untitled-6:60 within `#_#7`
; ││┌ @ Untitled-6:60 within `macro expansion`
; │││┌ @ abstractarray.jl:2933 within `map`
; ││││┌ @ array.jl:716 within `collect_similar`
store {}* %9, {}** %1, align 16
%14 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe9, i64 0, i64 3
store {}* %9, {}** %14, align 8
%15 = call nonnull {}* @j__collect_2266({}* nonnull %9, { {}* }* nocapture readonly %2) #0
%16 = load {}*, {}** %5, align 8
%17 = bitcast {}*** %3 to {}**
store {}* %16, {}** %17, align 8
; └└└└└
ret {}* %15
}