Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metal: switch order of unreachable rewrite passes. #623

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GPUCompiler"
uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
authors = ["Tim Besard <[email protected]>"]
version = "0.27.3"
version = "0.27.4"

[deps]
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
Expand Down
20 changes: 11 additions & 9 deletions src/metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,25 @@ function finish_ir!(@nospecialize(job::CompilerJob{MetalCompilerTarget}), mod::L
entry::LLVM.Function)
entry_fn = LLVM.name(entry)

# get rid of unreachable control flow (JuliaLang/Metal.jl#370)
if job.config.target.macos < v"15"
for f in functions(mod)
replace_unreachable!(job, f)
end
end

# add kernel metadata
if job.config.kernel
entry = add_address_spaces!(job, mod, entry)

add_argument_metadata!(job, mod, entry)

add_module_metadata!(job, mod)
end

# JuliaLang/Metal.jl#113
hide_noreturn!(mod)

# JuliaLang/Metal.jl#113
hide_noreturn!(mod)
# get rid of unreachable control flow (JuliaLang/Metal.jl#370).
# note that this currently works in tandem with the `hide_noreturn!` pass above,
# as `replace_unreachable!` doesn't handle functions that _only_ contain `unreachable`.
if job.config.target.macos < v"15"
for f in functions(mod)
replace_unreachable!(job, f)
end
end

# lower LLVM intrinsics that AIR doesn't support
Expand Down