Skip to content

Commit 671ba03

Browse files
authored
Merge pull request #174 from maleadt/tb/update
Use Base.julia_cmd, add address space removal pass
2 parents 441d676 + c877afe commit 671ba03

File tree

5 files changed

+30
-32
lines changed

5 files changed

+30
-32
lines changed

lib/libLLVM_extra.jl

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,19 @@ function LLVMAddTargetLibraryInfoByTriple(Triple, PM::LLVMPassManagerRef)
8787
end
8888

8989
if VERSION < v"1.2.0-DEV.531"
90-
9190
function LLVMAddNVVMReflectPass(PM::LLVMPassManagerRef, smversion)
9291
@apicall(:LLVMExtraAddMVVMReflectPass,Cvoid,(LLVMPassManagerRef,), PM)
9392
end
94-
9593
else
9694

9795
if libllvm_version < v"8.0"
98-
99-
function LLVMAddNVVMReflectPass(PM::LLVMPassManagerRef, smversion)
100-
@apicall(:LLVMExtraAddNVVMReflectPass,Cvoid,(LLVMPassManagerRef,), PM)
101-
end
102-
96+
function LLVMAddNVVMReflectPass(PM::LLVMPassManagerRef, smversion)
97+
@apicall(:LLVMExtraAddNVVMReflectPass,Cvoid,(LLVMPassManagerRef,), PM)
98+
end
10399
else
104-
105-
function LLVMAddNVVMReflectPass(PM::LLVMPassManagerRef, smversion)
106-
@apicall(:LLVMExtraAddNVVMReflectFunctionPass,Cvoid,(LLVMPassManagerRef, Cuint), PM, smversion)
107-
end
108-
100+
function LLVMAddNVVMReflectPass(PM::LLVMPassManagerRef, smversion)
101+
@apicall(:LLVMExtraAddNVVMReflectFunctionPass,Cvoid,(LLVMPassManagerRef, Cuint), PM, smversion)
102+
end
109103
end
110104

111105
function LLVMAddAllocOptPass(PM::LLVMPassManagerRef)
@@ -151,23 +145,25 @@ end
151145
end
152146

153147
if VERSION >= v"1.3.0-DEV.95"
154-
155148
function LLVMAddFinalLowerGCPass(PM::LLVMPassManagerRef)
156149
@apicall(:LLVMExtraAddFinalLowerGCPass,Cvoid,(LLVMPassManagerRef,), PM)
157150
end
151+
end
158152

159-
end # v"1.3.0-DEV.95"
153+
if VERSION >= v"1.5.0-DEV.802"
154+
function LLVMAddRemoveJuliaAddrspacesPass(PM::LLVMPassManagerRef)
155+
@apicall(:LLVMExtraAddRemoveJuliaAddrspacesPass,Cvoid,(LLVMPassManagerRef,), PM)
156+
end
157+
end
160158

161159
function LLVMGetValueContext(V::LLVMValueRef)
162160
@apicall(:LLVMExtraGetValueContext,LLVMContextRef,(LLVMValueRef,),V)
163161
end
164162

165163
if VERSION >= v"0.7.0-alpha.37"
166-
167164
function LLVMGetSourceLocation(V::LLVMValueRef, index, Name, Filename, Line, Column)
168165
@apicall(:LLVMExtraGetSourceLocation,Cint,(LLVMValueRef,Cint,Ptr{Cstring},Ptr{Cstring},Ptr{Cuint},Ptr{Cuint}), V, index, Name, Filename, Line, Column)
169166
end
170-
171167
end
172168

173169
if libllvm_version >= v"8.0"

src/interop/passes.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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!
3+
lower_simdloop!, late_lower_gc_frame!, final_lower_gc!, remove_julia_addrspaces!
44

55
alloc_opt!(pm::PassManager) =
66
API.LLVMAddAllocOptPass(ref(pm))
@@ -38,3 +38,9 @@ if VERSION >= v"1.3.0-DEV.95"
3838
else
3939
final_lower_gc!(pm::PassManager) = nothing
4040
end
41+
42+
if VERSION >= v"1.5.0-DEV.802"
43+
remove_julia_addrspaces!(pm::PassManager) = API.LLVMAddRemoveJuliaAddrspacesPass(LLVM.ref(pm))
44+
else
45+
remove_julia_addrspaces!(pm::PassManager) = nothing
46+
end

test/examples.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ filter!(file -> !occursin("Kaleidoscope", file), examples)
1919
cd(examples_dir) do
2020
examples = relpath.(examples, Ref(examples_dir))
2121
@testset for example in examples
22-
cmd = julia_cmd(`$example`)
23-
@test success(pipeline(cmd, stderr=stderr))
22+
cmd = Base.julia_cmd()
23+
if Base.JLOptions().project != C_NULL
24+
cmd = `$cmd --project=$(unsafe_string(Base.JLOptions().project))`
25+
end
26+
27+
@test success(pipeline(`$cmd $example`, stderr=stderr))
2428
end
2529
end
2630

test/support.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ code = """
88
"""
99

1010
out = Pipe()
11-
run(pipeline(julia_cmd(`-e $code`), stdout=out, stderr=out))
11+
cmd = Base.julia_cmd()
12+
if Base.JLOptions().project != C_NULL
13+
cmd = `$cmd --project=$(unsafe_string(Base.JLOptions().project))`
14+
end
15+
run(pipeline(`$cmd -e $code`, stdout=out, stderr=out))
1216
close(out.in)
1317

1418
@test occursin("LLVM (http://llvm.org/)", read(out, String))

test/util.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
function julia_cmd(cmd)
2-
return `
3-
$(Base.julia_cmd())
4-
--color=$(Base.have_color ? "yes" : "no")
5-
--compiled-modules=$(Base.JLOptions().use_compiled_modules != 0 ? "yes" : "no")
6-
--history-file=no
7-
--startup-file=$(Base.JLOptions().startupfile != 2 ? "yes" : "no")
8-
--code-coverage=$(["none", "user", "all"][1+Base.JLOptions().code_coverage])
9-
$cmd
10-
`
11-
end
12-
131
macro check_ir(inst, str)
142
quote
153
@test occursin($(esc(str)), string($(esc(inst))))

0 commit comments

Comments
 (0)