Skip to content

Commit 94115dc

Browse files
authored
Update to LLVM.jl v9.1. (#626)
1 parent 160d9a4 commit 94115dc

File tree

11 files changed

+48
-48
lines changed

11 files changed

+48
-48
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ steps:
135135
136136
julia -e 'println("+++ :julia: Running tests")
137137
using Pkg
138-
Pkg.test("Enzyme"; coverage=true)'
138+
Pkg.test("Enzyme"; coverage=true, julia_args=`--depwarn=no`)'
139139
agents:
140140
queue: "juliagpu"
141141
if: build.message !~ /\[skip tests\]/ && !build.pull_request.draft

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
2020
[compat]
2121
ExprTools = "0.1"
2222
InteractiveUtils = "1"
23-
LLVM = "9"
23+
LLVM = "9.1"
2424
Libdl = "1"
2525
Logging = "1"
2626
PrecompileTools = "1"

src/driver.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ const __llvm_initialized = Ref(false)
248248
end
249249
replace_uses!(call, fptr)
250250
end
251-
unsafe_delete!(LLVM.parent(call), call)
251+
erase!(call)
252252
end
253253
end
254254
end
255255

256256
# all deferred compilations should have been resolved
257257
@compiler_assert isempty(uses(dyn_marker)) job
258-
unsafe_delete!(ir, dyn_marker)
258+
erase!(dyn_marker)
259259
end
260260

261261
if libraries

src/gcn.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ function lower_throw_extra!(mod::LLVM.Module)
8282
# remove the call
8383
nargs = length(parameters(f))
8484
call_args = arguments(call)
85-
unsafe_delete!(LLVM.parent(call), call)
85+
erase!(LLVM.parent(call), call)
8686

8787
# HACK: kill the exceptions' unused arguments
8888
for arg in call_args
8989
# peek through casts
9090
if isa(arg, LLVM.AddrSpaceCastInst)
9191
cast = arg
9292
arg = first(operands(cast))
93-
isempty(uses(cast)) && unsafe_delete!(LLVM.parent(cast), cast)
93+
isempty(uses(cast)) && erase!(cast)
9494
end
9595

9696
if isa(arg, LLVM.Instruction) && isempty(uses(arg))
97-
unsafe_delete!(LLVM.parent(arg), arg)
97+
erase!(arg)
9898
end
9999
end
100100

src/irgen.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function irgen(@nospecialize(job::CompilerJob))
3030
# TODO: Do we need to remove these?
3131
if job.config.entry_abi === :specfunc
3232
if startswith(LLVM.name(llvmf), "jfptr_")
33-
unsafe_delete!(mod, llvmf)
33+
erase!(llvmf)
3434
end
3535
end
3636
end
@@ -39,7 +39,7 @@ function irgen(@nospecialize(job::CompilerJob))
3939
if Sys.iswindows() && "__julia_personality" in functions(mod)
4040
llvmf = functions(mod)["__julia_personality"]
4141
@compiler_assert isempty(uses(llvmf)) job
42-
unsafe_delete!(mod, llvmf)
42+
erase!(llvmf)
4343
end
4444
end
4545

@@ -172,7 +172,7 @@ function lower_throw!(mod::LLVM.Module)
172172

173173
# remove the call
174174
call_args = arguments(call)
175-
unsafe_delete!(LLVM.parent(call), call)
175+
erase!(call)
176176

177177
# HACK: kill the exceptions' unused arguments
178178
# this is needed for throwing objects with @nospecialize constructors.
@@ -181,11 +181,11 @@ function lower_throw!(mod::LLVM.Module)
181181
if isa(arg, LLVM.AddrSpaceCastInst)
182182
cast = arg
183183
arg = first(operands(cast))
184-
isempty(uses(cast)) && unsafe_delete!(LLVM.parent(cast), cast)
184+
isempty(uses(cast)) && erase!(cast)
185185
end
186186

187187
if isa(arg, LLVM.Instruction) && isempty(uses(arg))
188-
unsafe_delete!(LLVM.parent(arg), arg)
188+
erase!(arg)
189189
end
190190
end
191191

@@ -477,7 +477,7 @@ function lower_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.
477477
fn = LLVM.name(f)
478478
@assert isempty(uses(f))
479479
replace_metadata_uses!(f, new_f)
480-
unsafe_delete!(mod, f)
480+
erase!(f)
481481
LLVM.name!(new_f, fn)
482482

483483
return new_f
@@ -644,7 +644,7 @@ function add_kernel_state!(mod::LLVM.Module)
644644
end
645645
end
646646
replace_metadata_uses!(f, workmap[f])
647-
unsafe_delete!(mod, f)
647+
erase!(f)
648648
end
649649

650650
# update uses of the new function, modifying call sites to include the kernel state
@@ -678,7 +678,7 @@ function add_kernel_state!(mod::LLVM.Module)
678678

679679
replace_uses!(val, new_val)
680680
@assert isempty(uses(val))
681-
unsafe_delete!(LLVM.parent(val), val)
681+
erase!(val)
682682
elseif val isa LLVM.CallBase
683683
# the function is being passed as an argument. to avoid having to
684684
# rewrite the target function, instead case the rewritten function to
@@ -700,7 +700,7 @@ function add_kernel_state!(mod::LLVM.Module)
700700

701701
replace_uses!(val, new_val)
702702
@assert isempty(uses(val))
703-
unsafe_delete!(LLVM.parent(val), val)
703+
erase!(val)
704704
elseif val isa LLVM.StoreInst
705705
# the function is being stored, which again we'll permit like before.
706706
elseif val isa ConstantExpr
@@ -761,7 +761,7 @@ function lower_kernel_state!(fun::LLVM.Function)
761761
replace_uses!(inst, state_arg)
762762

763763
@assert isempty(uses(inst))
764-
unsafe_delete!(LLVM.parent(inst), inst)
764+
erase!(inst)
765765

766766
changed = true
767767
end
@@ -781,7 +781,7 @@ function cleanup_kernel_state!(mod::LLVM.Module)
781781
intr = functions(mod)["julia.gpu.state_getter"]
782782
if isempty(uses(intr))
783783
# if we're not emitting a kernel, we can't resolve the intrinsic to an argument.
784-
unsafe_delete!(mod, intr)
784+
erase!(intr)
785785
changed = true
786786
end
787787
end

src/mcgen.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function resolve_cpu_references!(mod::LLVM.Module)
5151
elseif isa(val, LLVM.LoadInst)
5252
# resolve
5353
replace_uses!(val, dereferenced)
54-
unsafe_delete!(LLVM.parent(val), val)
54+
erase!(val)
5555
# FIXME: iterator invalidation?
5656
changed = true
5757
end

src/metal.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function add_address_spaces!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
290290
fn = LLVM.name(f)
291291
@assert isempty(uses(f))
292292
replace_metadata_uses!(f, new_f)
293-
unsafe_delete!(mod, f)
293+
erase!(f)
294294
LLVM.name!(new_f, fn)
295295

296296
# clean-up after this pass (which runs after optimization)
@@ -384,7 +384,7 @@ function pass_by_reference!(@nospecialize(job::CompilerJob), mod::LLVM.Module, f
384384
# NOTE: if we ever have legitimate uses of the old function, create a shim instead
385385
fn = LLVM.name(f)
386386
@assert isempty(uses(f))
387-
unsafe_delete!(mod, f)
387+
erase!(f)
388388
LLVM.name!(new_f, fn)
389389

390390
return new_f
@@ -432,7 +432,7 @@ function argument_type_name(typ)
432432
elseif typ isa LLVM.IntegerType && width(typ) == 32
433433
"uint"
434434
elseif typ isa LLVM.VectorType
435-
argument_type_name(eltype(typ)) * string(Int(size(typ)))
435+
argument_type_name(eltype(typ)) * string(Int(length(typ)))
436436
else
437437
error("Cannot encode unknown type `$typ`")
438438
end
@@ -551,7 +551,7 @@ function add_input_arguments!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
551551

552552
replace_uses!(val, new_val)
553553
@assert isempty(uses(val))
554-
unsafe_delete!(LLVM.parent(val), val)
554+
erase!(val)
555555
elseif val isa LLVM.ConstantExpr && opcode(val) == LLVM.API.LLVMBitCast
556556
# XXX: why isn't this caught by the value materializer above?
557557
target = operands(val)[1]
@@ -575,7 +575,7 @@ function add_input_arguments!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
575575
for (f, new_f) in workmap
576576
rewrite_uses!(f, new_f)
577577
@assert isempty(uses(f))
578-
unsafe_delete!(mod, f)
578+
erase!(f)
579579
end
580580

581581
# replace uses of the intrinsics with references to the input arguments
@@ -591,10 +591,10 @@ function add_input_arguments!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
591591
end
592592

593593
@assert isempty(uses(val))
594-
unsafe_delete!(LLVM.parent(val), val)
594+
erase!(val)
595595
end
596596
@assert isempty(uses(intr))
597-
unsafe_delete!(mod, intr)
597+
erase!(intr)
598598
end
599599

600600
return
@@ -820,7 +820,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
820820
"llvm.assume"
821821
])
822822
if intr in unsupported_intrinsics
823-
unsafe_delete!(bb, call)
823+
erase!(call)
824824
changed = true
825825
end
826826

@@ -854,7 +854,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
854854
elseif typ == LLVM.DoubleType()
855855
"f64"
856856
elseif typ isa LLVM.VectorType
857-
"v$(size(typ))$(type_suffix(eltype(typ)))"
857+
"v$(length(typ))$(type_suffix(eltype(typ)))"
858858
else
859859
error("Unsupported intrinsic type: $typ")
860860
end
@@ -877,7 +877,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
877877

878878
new_value = call!(builder, call_ft, new_intr, arguments(call))
879879
replace_uses!(call, new_value)
880-
unsafe_delete!(bb, call)
880+
erase!(call)
881881
changed = true
882882
end
883883
end
@@ -915,7 +915,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
915915

916916
new_value = bitcast!(builder, new_value, typ)
917917
replace_uses!(call, new_value)
918-
unsafe_delete!(bb, call)
918+
erase!(call)
919919
changed = true
920920
end
921921
end
@@ -1032,7 +1032,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
10321032

10331033
new_value = call!(builder, call_ft, new_intr, arguments(call))
10341034
replace_uses!(call, new_value)
1035-
unsafe_delete!(bb, call)
1035+
erase!(call)
10361036
changed = true
10371037
end
10381038
end
@@ -1134,7 +1134,7 @@ function replace_unreachable!(@nospecialize(job::CompilerJob), f::LLVM.Function)
11341134
br!(builder, return_block)
11351135

11361136
# move the return
1137-
delete!(exit_block, ret)
1137+
remove!(ret)
11381138
position!(builder, return_block)
11391139
insert!(builder, ret)
11401140
end
@@ -1159,13 +1159,13 @@ function replace_unreachable!(@nospecialize(job::CompilerJob), f::LLVM.Function)
11591159
# remove preceding traps to avoid reconstructing unreachable control flow
11601160
prev = previnst(unreachable)
11611161
if isa(prev, LLVM.CallInst) && name(called_operand(prev)) == "llvm.trap"
1162-
unsafe_delete!(bb, prev)
1162+
erase!(prev)
11631163
end
11641164

11651165
# replace the unreachable with a branch to the return block
11661166
position!(builder, unreachable)
11671167
br!(builder, return_block)
1168-
unsafe_delete!(bb, unreachable)
1168+
erase!(unreachable)
11691169

11701170
# patch up any phi nodes in the return block
11711171
for inst in instructions(return_block)

src/optim.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ function cpu_features!(mod::LLVM.Module)
324324
# remove the intrinsic and its uses
325325
for val in materialized
326326
@assert isempty(uses(val))
327-
unsafe_delete!(LLVM.parent(val), val)
327+
erase!(val)
328328
end
329329
@assert isempty(uses(f))
330-
unsafe_delete!(mod, f)
330+
erase!(f)
331331
end
332332

333333
return changed
@@ -368,7 +368,7 @@ function lower_gc_frame!(fun::LLVM.Function)
368368
replace_uses!(call, ptr)
369369
end
370370

371-
unsafe_delete!(LLVM.parent(call), call)
371+
erase!(call)
372372

373373
changed = true
374374
end
@@ -382,7 +382,7 @@ function lower_gc_frame!(fun::LLVM.Function)
382382

383383
for use in uses(barrier)
384384
call = user(use)::LLVM.CallInst
385-
unsafe_delete!(LLVM.parent(call), call)
385+
erase!(call)
386386
changed = true
387387
end
388388

@@ -412,7 +412,7 @@ function lower_ptls!(mod::LLVM.Module)
412412
for use in uses(ptls_getter)
413413
val = user(use)
414414
if isempty(uses(val))
415-
unsafe_delete!(LLVM.parent(val), val)
415+
erase!(val)
416416
changed = true
417417
else
418418
# the validator will detect this

src/ptx.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,12 @@ function nvvm_reflect!(fun::LLVM.Function)
471471
# remove the calls to the function
472472
for val in to_remove
473473
@assert isempty(uses(val))
474-
unsafe_delete!(LLVM.parent(val), val)
474+
erase!(val)
475475
end
476476

477477
# maybe also delete the function
478478
if isempty(uses(reflect_function))
479-
unsafe_delete!(mod, reflect_function)
479+
erase!(reflect_function)
480480
end
481481

482482
end

src/rtlib.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
link_library!(mod::LLVM.Module, lib::LLVM.Module) = link_library!(mod, [lib])
44
function link_library!(mod::LLVM.Module, libs::Vector{LLVM.Module})
55
# linking is destructive, so copy the libraries
6-
libs = [LLVM.Module(lib) for lib in libs]
6+
libs = [copy(lib) for lib in libs]
77

88
for lib in libs
99
link!(mod, lib)
@@ -34,7 +34,7 @@ function LLVM.call!(builder, rt::Runtime.RuntimeMethodInstance, args=LLVM.Value[
3434
if !isdeclaration(f) && (rt.name !== :gc_pool_alloc && rt.name !== :report_exception)
3535
# XXX: uses of the gc_pool_alloc intrinsic can be introduced _after_ the runtime
3636
# is linked, as part of the lower_gc_frame! optimization pass.
37-
# XXX: report_exception can also be used after the runtime is linked during
37+
# XXX: report_exception can also be used after the runtime is linked during
3838
# CUDA/Enzyme nested compilation
3939
error("Calling an intrinsic function that clashes with an existing definition: ",
4040
string(ft), " ", rt.name)
@@ -89,7 +89,7 @@ function emit_function!(mod, config::CompilerConfig, f, method)
8989
decl = functions(mod)[name]
9090
@assert value_type(decl) == value_type(entry)
9191
replace_uses!(decl, entry)
92-
unsafe_delete!(mod, decl)
92+
erase!(decl)
9393
end
9494
LLVM.name!(entry, name)
9595
end

0 commit comments

Comments
 (0)