Skip to content

Commit

Permalink
Metal: switch order of unreachable rewrite passes. (#623)
Browse files Browse the repository at this point in the history
replace_unreachable currently doesn't handle trivial trapping functions,
but hide_noreturn does, so just switch the order of these two passes.
  • Loading branch information
maleadt authored Aug 27, 2024
1 parent 0a1e05d commit b490b6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
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

2 comments on commit b490b6f

@maleadt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/113960

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.27.4 -m "<description of version>" b490b6f6e1a44dd5864ca7fefc89542e9759012a
git push origin v0.27.4

Please sign in to comment.