Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit a7a504a

Browse files
bors[bot]maleadt
andcommitted
Merge #332
332: Various fixes r=maleadt a=maleadt Co-authored-by: Tim Besard <[email protected]>
2 parents 655df5f + 58f0b6a commit a7a504a

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ test:dev:
2929
- trying
3030

3131
coverage:
32+
allow_failure: true
3233
only:
3334
- master
3435
- staging

src/compiler/debug.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ function backtrace(inst::LLVM.Instruction, bt = StackTraces.StackFrame[])
2222

2323
# move up the call chain
2424
f = LLVM.parent(LLVM.parent(inst))
25-
callers = uses(f)
25+
## functions can be used as a *value* in eg. constant expressions, so filter those out
26+
callers = filter(val -> isa(user(val), LLVM.CallInst), collect(uses(f)))
2627
if !isempty(callers)
2728
# figure out the call sites of this instruction
2829
call_sites = unique(callers) do call

src/compiler/irgen.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function irgen(ctx::CompilerContext)
181181

182182
add!(pm, ModulePass("LowerThrow", lower_throw!))
183183
add!(pm, FunctionPass("HideUnreachable", hide_unreachable!))
184-
add!(pm, FunctionPass("HideTrap", hide_trap!))
184+
add!(pm, ModulePass("HideTrap", hide_trap!))
185185
always_inliner!(pm)
186186
verifier!(pm)
187187
run!(pm, mod)
@@ -423,25 +423,26 @@ end
423423
# HACK: this pass removes calls to `trap` and replaces them with inline assembly
424424
#
425425
# if LLVM knows we're trapping, code is marked `unreachable` (see `hide_unreachable!`).
426-
function hide_trap!(fun::LLVM.Function)
426+
function hide_trap!(mod::LLVM.Module)
427427
ctx = global_ctx::CompilerContext
428-
mod = LLVM.parent(fun)
429428
changed = false
430429

431430
# inline assembly to exit a thread, hiding control flow from LLVM
432431
exit_ft = LLVM.FunctionType(LLVM.VoidType(JuliaContext()))
433432
exit = InlineAsm(exit_ft, "trap;", "", true)
434433

435-
for bb in blocks(fun)
436-
# replace calls to `trap` with inline assembly
437-
for inst in instructions(bb)
438-
if isa(inst, LLVM.CallInst) && LLVM.name(called_value(inst)) == "llvm.trap"
434+
if haskey(functions(mod), "llvm.trap")
435+
trap = functions(mod)["llvm.trap"]
436+
437+
for use in uses(trap)
438+
val = user(use)
439+
if isa(val, LLVM.CallInst)
439440
let builder = Builder(JuliaContext())
440-
position!(builder, inst)
441+
position!(builder, val)
441442
call!(builder, exit)
442443
dispose(builder)
443444
end
444-
unsafe_delete!(bb, inst)
445+
unsafe_delete!(LLVM.parent(val), val)
445446
changed = true
446447
end
447448
end

src/compiler/mcgen.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ function resolve_cpu_references!(mod::LLVM.Module)
6363
function replace_bindings!(value)
6464
changed = false
6565
for use in uses(value)
66-
target = user(use)
67-
if isa(target, LLVM.ConstantExpr)
66+
val = user(use)
67+
if isa(val, LLVM.ConstantExpr)
6868
# recurse
69-
changed |= replace_bindings!(target)
70-
elseif isa(target, LLVM.LoadInst)
69+
changed |= replace_bindings!(val)
70+
elseif isa(val, LLVM.LoadInst)
7171
# resolve
72-
replace_uses!(target, dereferenced)
73-
unsafe_delete!(LLVM.parent(target), target)
72+
replace_uses!(val, dereferenced)
73+
unsafe_delete!(LLVM.parent(val), val)
7474
# FIXME: iterator invalidation?
7575
changed = true
7676
end

src/compiler/optim.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function lower_gc_frame!(fun::LLVM.Function)
299299
barrier = functions(mod)["julia.write_barrier"]
300300

301301
for use in uses(barrier)
302-
call = user(use)
302+
call = user(use)::LLVM.CallInst
303303
unsafe_delete!(LLVM.parent(call), call)
304304
changed = true
305305
end
@@ -325,11 +325,11 @@ function lower_ptls!(mod::LLVM.Module)
325325
ptls_getter = functions(mod)["julia.ptls_states"]
326326

327327
for use in uses(ptls_getter)
328-
call = user(use)
329-
if !isempty(uses(call))
328+
val = user(use)
329+
if !isempty(uses(val))
330330
error("Thread local storage is not implemented")
331331
end
332-
unsafe_delete!(LLVM.parent(call), call)
332+
unsafe_delete!(LLVM.parent(val), val)
333333
changed = true
334334
end
335335

test/device/execution.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,15 @@ let (code, out, err) = julia_script(script, `-g1`)
524524
@test code == 1
525525
@test occursin("ERROR: CUDA error: an illegal instruction was encountered", err) ||
526526
occursin("ERROR: CUDA error: unspecified launch failure", err)
527-
@test occursin(r"ERROR: a exception was thrown during kernel execution", out)
528-
@test occursin(r"Run Julia on debug level 2 for device stack traces", out)
527+
@test occursin("ERROR: a exception was thrown during kernel execution", out)
528+
@test occursin("Run Julia on debug level 2 for device stack traces", out)
529529
end
530530

531531
let (code, out, err) = julia_script(script, `-g2`)
532532
@test code == 1
533533
@test occursin("ERROR: CUDA error: an illegal instruction was encountered", err) ||
534534
occursin("ERROR: CUDA error: unspecified launch failure", err)
535-
@test occursin(r"ERROR: a exception was thrown during kernel execution", out)
535+
@test occursin("ERROR: a exception was thrown during kernel execution", out)
536536
@test occursin("[1] Type at float.jl", out)
537537
@test occursin("[2] kernel at none:2", out)
538538
end
@@ -555,7 +555,7 @@ let (code, out, err) = julia_script(script, `-g2`)
555555
@test code == 1
556556
@test occursin("ERROR: CUDA error: an illegal instruction was encountered", err) ||
557557
occursin("ERROR: CUDA error: unspecified launch failure", err)
558-
@test occursin(r"ERROR: a exception was thrown during kernel execution", out)
558+
@test occursin("ERROR: a exception was thrown during kernel execution", out)
559559
@test occursin("foo at none:1", out)
560560
@test occursin("bar at none:2", out)
561561
end

0 commit comments

Comments
 (0)