Skip to content

Commit b490b6f

Browse files
authored
Metal: switch order of unreachable rewrite passes. (#623)
replace_unreachable currently doesn't handle trivial trapping functions, but hide_noreturn does, so just switch the order of these two passes.
1 parent 0a1e05d commit b490b6f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GPUCompiler"
22
uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
33
authors = ["Tim Besard <[email protected]>"]
4-
version = "0.27.3"
4+
version = "0.27.4"
55

66
[deps]
77
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"

src/metal.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,25 @@ function finish_ir!(@nospecialize(job::CompilerJob{MetalCompilerTarget}), mod::L
134134
entry::LLVM.Function)
135135
entry_fn = LLVM.name(entry)
136136

137-
# get rid of unreachable control flow (JuliaLang/Metal.jl#370)
138-
if job.config.target.macos < v"15"
139-
for f in functions(mod)
140-
replace_unreachable!(job, f)
141-
end
142-
end
143-
144137
# add kernel metadata
145138
if job.config.kernel
146139
entry = add_address_spaces!(job, mod, entry)
147140

148141
add_argument_metadata!(job, mod, entry)
149142

150143
add_module_metadata!(job, mod)
144+
end
145+
146+
# JuliaLang/Metal.jl#113
147+
hide_noreturn!(mod)
151148

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

156158
# lower LLVM intrinsics that AIR doesn't support

0 commit comments

Comments
 (0)