-
Notifications
You must be signed in to change notification settings - Fork 41
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
Support for LLVM 15 and opaque pointers #326
Conversation
src/core/function.jl
Outdated
@@ -10,6 +10,8 @@ register(Function, API.LLVMFunctionValueKind) | |||
Function(mod::Module, name::String, ft::FunctionType) = | |||
Function(API.LLVMAddFunction(mod, name, ft)) | |||
|
|||
FunctionType(Fn::Function) = FunctionType(API.LLVMGetFunctionType(Fn)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do this already using eltype(llvmtype(fn))
. Probably wouldn't hurt to have the FunctionType
ctor for visibility, but it doesn't need an additional API call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't do this, at least not with eltype(llvmtype(fn)
because
julia> f = LLVM.Function(mod, "f", fun_type)
declare i32 @f(i32, i32)
julia> llvmtype(f)
ptr
and eltype(ptrtype)
is illegal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right; that will require a lot of updates across the stack then (we're doing eltype(llvmtype(...))
in a lot of places).
I'm not entirely sold on FunctionType(::Function)
, as that looks more like a conversion than a type query, but I don't have anything better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llvmeltype
is probably illegal everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still legal for Arrays, Vectors, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case illegal uses should be caught by that error method. Otherwise it segfaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe making it function_type(::Function)
, so it doesn't look like a constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github shows 122 results for eltype(llvmtype(
+ 15 llvmeltype
. I suspect lots of those are fine, but yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function_type
sounds good. Maybe we should rename llvmtype
to value_type
then? Or that may be too breaking for what it's worth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llvmtype isn't too bad, and value_type
isn't super clear IMO, and llvm_value_type
is a handful.
We should probably wait to merge this until JuliaLang/julia#48700 has landed. Using that PR, I'm getting an assertion failure:
Actually, let me just have CI use that branch over here. |
I looked a bit into that failure and am quite confused, we don't use unordered ordering anywhere in the tests. |
Comes from LLVM.jl though:
|
It fails in type inference which is odd. |
It's a generated function that gets expanded by type inference, which calls into LLVM and triggers an assertion while generating IR. |
Looked into the issue, and the |
Expat_jll broke?
Hasn't been touched in ages... Maybe the cache is corrupted? |
It didn't even find it, so I guess so |
Thanks for the PR! I want to have this live on master for a bit so that we can iron out any necessary API changes, so I won't tag immediately. |
Co-authored-by: Tim Besard <[email protected]>
Initial set of changes for LLVM 15
This already passes a good amount of tests, and also doesn't segfault during the tests.
I'm up to bikeshedding how best to make the version checks.