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: Work around function attribute changes in LLVM 16. #564

Merged
merged 1 commit into from
Apr 10, 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 <tim.besard@gmail.com>"]
version = "0.26.3"
version = "0.26.4"

[deps]
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
Expand Down
14 changes: 12 additions & 2 deletions src/metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,12 @@ function annotate_air_intrinsics!(@nospecialize(job::CompilerJob), mod::LLVM.Mod
attrs = function_attributes(f)
function add_attributes(names...)
for name in names
if LLVM.version() >= v"16" && name in ["argmemonly", "inaccessiblememonly",
"inaccessiblemem_or_argmemonly",
"readnone", "readonly", "writeonly"]
# XXX: workaround for changes from https://reviews.llvm.org/D135780
continue
end
push!(attrs, EnumAttribute(name, 0))
end
changed = true
Expand All @@ -1080,12 +1086,16 @@ function annotate_air_intrinsics!(@nospecialize(job::CompilerJob), mod::LLVM.Mod

# atomics
elseif match(r"air.atomic.(local|global).load", fn) !== nothing
add_attributes("argmemonly", "nounwind", "readonly")
# TODO: "memory(argmem: read)" on LLVM 16+
add_attributes("argmemonly", "readonly", "nounwind")
elseif match(r"air.atomic.(local|global).store", fn) !== nothing
add_attributes("argmemonly", "nounwind", "writeonly")
# TODO: "memory(argmem: write)" on LLVM 16+
add_attributes("argmemonly", "writeonly", "nounwind")
elseif match(r"air.atomic.(local|global).(xchg|cmpxchg)", fn) !== nothing
# TODO: "memory(argmem: readwrite)" on LLVM 16+
add_attributes("argmemonly", "nounwind")
elseif match(r"^air.atomic.(local|global).(add|sub|min|max|and|or|xor)", fn) !== nothing
# TODO: "memory(argmem: readwrite)" on LLVM 16+
add_attributes("argmemonly", "nounwind")
end
end
Expand Down
Loading