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

Handle IntrinsicInst uses in allocation optimization pass #23744

Merged
merged 1 commit into from
Sep 18, 2017

Conversation

yuyichao
Copy link
Contributor

This is needed on LLVM 5.0.

@yuyichao yuyichao added the compiler:codegen Generation of LLVM IR and native code label Sep 17, 2017
@yuyichao yuyichao merged commit e96478e into master Sep 18, 2017
@yuyichao yuyichao deleted the yyc/codegen/alloc branch September 18, 2017 19:33
@maleadt
Copy link
Member

maleadt commented Sep 19, 2017

This breaks my (possibly invalid) use of pointer_from_objref: https://github.com/JuliaGPU/CUDAdrv.jl/blob/fc18bbad0c2286cbd42b2bc8b101663b18df38c5/src/execution.jl#L81-L85

MWE:

function foo(obj)
    ptr = Base.pointer_from_objref(obj)
    println("Located at: ", ptr)
    println("Which contains: ", Base.unsafe_pointer_to_objref(ptr))

end

const obj = Ptr{Void}(1)
println("Original object: ", obj)
foo(obj)

Before this PR:

Original object: Ptr{Void} @0x0000000000000001
Located at: Ptr{Void} @0x00007fab0326a770
Which contains: Ptr{Void} @0x0000000000000001

But now segfaults on the unsafe_pointer_to_objref.
Still works interpreted, so I assume this is not intended.

@yuyichao
Copy link
Contributor Author

This is intended. Calling pointer_from_objref on a isbits object has always been invalid.

@maleadt
Copy link
Member

maleadt commented Sep 19, 2017

Okay, I think I can have a correct solution using Ref boxes. But as I need to pass an array of pointers, I'm doing unsafe_convert(Ptr{Void}, ref) which the GC can't track, so I assume I need the new @gc_preserve for that. But your pass can't handle that intrinsic, it trips up on:
%300 = call token (...) @llvm.julia.gc_preserve_begin(%jl_value_t addrspace(10)* %258, %jl_value_t addrspace(10)* %267, %jl_value_t addrspace(10)* %276), !dbg !162
at

assert(ID);

@yuyichao
Copy link
Contributor Author

it trips up on:
%300 = call token (...) @llvm.julia.gc_preserve_begin(%jl_value_t addrspace(10)* %258, %jl_value_t addrspace(10)* %267, %jl_value_t addrspace(10)* %276), !dbg !162

..... OK, this is because Keno is lying to me ;-p..... Will fix later....

@vtjnash
Copy link
Sponsor Member

vtjnash commented Sep 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants