Skip to content

Commit 1337258

Browse files
committed
Add remove_ni and julia_licm
1 parent 827cffa commit 1337258

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

lib/libLLVM_extra.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ function LLVMAddRemoveJuliaAddrspacesPass(PM)
168168
end
169169
end
170170

171+
if VERSION >= v"1.6.0-DEV.1476"
172+
function LLVMAddRemoveNIPass(PM)
173+
ccall(:LLVMExtraAddRemoveNIPass,Cvoid,(LLVMPassManagerRef,), PM)
174+
end
175+
end
176+
177+
if VERSION >= v"1.6.0-DEV.1477"
178+
function LLVMAddJuliaLICMPass(PM)
179+
ccall(:LLVMExtraJuliaLICMPass,Cvoid,(LLVMPassManagerRef,), PM)
180+
end
181+
end
182+
171183
function LLVMGetValueContext(V)
172184
ccall(:LLVMExtraGetValueContext,LLVMContextRef,(LLVMValueRef,),V)
173185
end

src/interop/passes.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export alloc_opt!, barrier_noop!, gc_invariant_verifier!, lower_exc_handlers!,
22
combine_mul_add!, multi_versioning!, propagate_julia_addrsp!, lower_ptls!,
3-
lower_simdloop!, late_lower_gc_frame!, final_lower_gc!, remove_julia_addrspaces!
3+
lower_simdloop!, late_lower_gc_frame!, final_lower_gc!, remove_julia_addrspaces!,
4+
remove_ni!, julia_licm!
45

56
alloc_opt!(pm::PassManager) =
67
API.LLVMAddAllocOptPass(pm)
@@ -44,3 +45,15 @@ if VERSION >= v"1.5.0-DEV.802"
4445
else
4546
remove_julia_addrspaces!(pm::PassManager) = nothing
4647
end
48+
49+
if VERSION >= v"1.6.0-DEV.1476"
50+
remove_ni!(pm::PassManager) = API.LLVMAddRemoveNIPass(pm)
51+
else
52+
remove_ni!(pm::PassManager) = nothing # Could implement this in pure Julia if necessary
53+
end
54+
55+
if VERSION >= v"1.6.0-DEV.1477"
56+
julia_licm!(pm::PassManager) = API.LLVMAddJuliaLICMPass(pm)
57+
else
58+
julia_licm!(pm::PassManager) = nothing
59+
end

test/interop.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Context() do ctx
116116
LLVM.Module("SomeModule", ctx) do mod
117117
ModulePassManager() do pm
118118

119+
julia_licm!(pm)
119120
alloc_opt!(pm)
120121
barrier_noop!(pm)
121122
gc_invariant_verifier!(pm)
@@ -127,6 +128,7 @@ propagate_julia_addrsp!(pm)
127128
lower_ptls!(pm)
128129
lower_ptls!(pm, true)
129130
lower_simdloop!(pm)
131+
remove_ni!(pm)
130132
late_lower_gc_frame!(pm)
131133
final_lower_gc!(pm)
132134

0 commit comments

Comments
 (0)