Skip to content

Commit 0002a6b

Browse files
maleadtclaude
andauthored
Remove temporary per-compile IR dump that taxed all downstream CI (#861)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 240b139 commit 0002a6b

2 files changed

Lines changed: 19 additions & 80 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "GPUCompiler"
22
uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
3-
version = "1.22.5"
3+
version = "1.22.6"
44
authors = ["Tim Besard <tim.besard@gmail.com>"]
55

66
[workspace]

src/optim.jl

Lines changed: 18 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -49,94 +49,33 @@ function aggressiveinstcombine_pass(@nospecialize(job::CompilerJob))
4949
end
5050
end
5151

52-
# A crash in an optimization pass is a compiler bug, and the only reliable way to debug one
53-
# that reproduces only in CI is to get the offending module off the machine. On a failure we
54-
# write out the IR *entering* `optimize!` -- a faithful, re-optimizable reproducer (parse it
55-
# and call `optimize!` again), unlike a module recovered later via `optimize=false`, which has
56-
# already been through back-end IR finalization -- and, on a CI agent, publish it:
57-
# - Buildkite: `buildkite-agent artifact upload`, plus an error annotation pointing to it.
58-
# - GitHub Actions: drop it in `$RUNNER_TEMP` for an `actions/upload-artifact` step and
59-
# surface it as a workflow notice.
60-
# Snapshotting costs a `string(mod)` per compile, so it is gated to CI (auto-detected) or an
61-
# explicit `JULIA_GPUCOMPILER_DUMP_IR`; everything else pays nothing.
62-
function dump_failing_ir_enabled()
63-
if haskey(ENV, "JULIA_GPUCOMPILER_DUMP_IR")
64-
return parse(Bool, ENV["JULIA_GPUCOMPILER_DUMP_IR"])
65-
end
66-
return haskey(ENV, "BUILDKITE") || get(ENV, "GITHUB_ACTIONS", "false") == "true"
67-
end
68-
69-
function dump_failing_ir(ir::AbstractString, @nospecialize(err))
70-
path = tempname() * ".ll"
71-
try
72-
write(path, ir)
73-
catch e
74-
@error "GPUCompiler: could not write failing IR" exception=(e, catch_backtrace())
75-
return nothing
76-
end
77-
name = basename(path)
78-
79-
if parse(Bool, get(ENV, "BUILDKITE", "false"))
80-
try
81-
run(`buildkite-agent artifact upload $path`)
82-
annotation = "GPUCompiler optimization failed: `$(sprint(showerror, err))`. " *
83-
"Un-optimized IR uploaded as artifact `$name` (download with " *
84-
"`buildkite-agent artifact download $name .` and re-run the optimizer on it " *
85-
"to reproduce)."
86-
run(pipeline(`buildkite-agent annotate --style error --context gpucompiler-optimization`;
87-
stdin=IOBuffer(annotation)))
88-
catch e
89-
@error "GPUCompiler: failed to upload failing IR via buildkite-agent" exception=(e, catch_backtrace())
90-
end
91-
elseif get(ENV, "GITHUB_ACTIONS", "false") == "true"
92-
try
93-
dir = mkpath(joinpath(get(ENV, "RUNNER_TEMP", tempdir()), "gpucompiler-dumps"))
94-
cp(path, joinpath(dir, name); force=true)
95-
println("::notice title=GPUCompiler optimization failure::wrote $name to $dir")
96-
catch e
97-
@error "GPUCompiler: failed to stage failing IR for upload" exception=(e, catch_backtrace())
98-
end
99-
end
100-
101-
@info "GPUCompiler: wrote failing module to $path"
102-
return path
103-
end
104-
10552
function optimize!(@nospecialize(job::CompilerJob), mod::LLVM.Module; opt_level=2)
10653
tm = llvm_machine(job.config.target)
10754
tti = llvm_targetinfo(job.config.target)
10855

10956
global current_job
11057
current_job = job
11158

112-
# snapshot the (re-optimizable) input so a pass crash can surface a reproducer
113-
input_ir = dump_failing_ir_enabled() ? string(mod) : nothing
114-
115-
try
116-
@dispose pb=NewPMPassBuilder() begin
117-
tti === nothing || LLVM.target_transform_info!(pb, tti)
118-
119-
register!(pb, GPULowerCPUFeaturesPass())
120-
register!(pb, GPULowerPTLSPass())
121-
register!(pb, GPULowerGCFramePass())
122-
register!(pb, GPULinkRuntimePass())
123-
register!(pb, GPULinkLibrariesPass())
124-
register!(pb, GPUFinishRuntimeIntrinsicsPass())
125-
register!(pb, AddKernelStatePass())
126-
register!(pb, LowerKernelStatePass())
127-
register!(pb, CleanupKernelStatePass())
128-
129-
add!(pb, NewPMModulePassManager()) do mpm
130-
buildNewPMPipeline!(mpm, job, opt_level)
131-
end
132-
run!(pb, mod, tm)
59+
@dispose pb=NewPMPassBuilder() begin
60+
tti === nothing || LLVM.target_transform_info!(pb, tti)
61+
62+
register!(pb, GPULowerCPUFeaturesPass())
63+
register!(pb, GPULowerPTLSPass())
64+
register!(pb, GPULowerGCFramePass())
65+
register!(pb, GPULinkRuntimePass())
66+
register!(pb, GPULinkLibrariesPass())
67+
register!(pb, GPUFinishRuntimeIntrinsicsPass())
68+
register!(pb, AddKernelStatePass())
69+
register!(pb, LowerKernelStatePass())
70+
register!(pb, CleanupKernelStatePass())
71+
72+
add!(pb, NewPMModulePassManager()) do mpm
73+
buildNewPMPipeline!(mpm, job, opt_level)
13374
end
134-
optimize_module!(job, mod)
135-
run!(DeadArgumentEliminationPass(), mod, tm)
136-
catch err
137-
input_ir === nothing || dump_failing_ir(input_ir, err)
138-
rethrow()
75+
run!(pb, mod, tm)
13976
end
77+
optimize_module!(job, mod)
78+
run!(DeadArgumentEliminationPass(), mod, tm)
14079
return
14180
end
14281

0 commit comments

Comments
 (0)