Skip to content

Commit

Permalink
Metal: Work around function attribute changes in LLVM 16. (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt authored Apr 10, 2024
1 parent ed8c3a8 commit 82fe477
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 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 <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

2 comments on commit 82fe477

@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/104623

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.26.4 -m "<description of version>" 82fe477e03aa7661f9ec29dc352d521cbd54fd59
git push origin v0.26.4

Please sign in to comment.