Skip to content

Conversation

@maleadt
Copy link
Member

@maleadt maleadt commented Apr 11, 2019

Thanks to @vtjnash, again. Fixes JuliaGPU/CUDAnative.jl#133

Before:

define void @julia_kernel_2({ i64 } addrspace(11)* nocapture nonnull readonly dereferenceable(8)) !dbg !4 {
top:
  %1 = call %jl_value_t*** @julia.ptls_states()
  %2 = bitcast %jl_value_t*** %1 to %jl_value_t addrspace(10)**
  %3 = getelementptr inbounds %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %2, i64 2
  %4 = bitcast %jl_value_t addrspace(10)** %3 to i64**
  %5 = load i64*, i64** %4, !tbaa !14, !invariant.load !3
  %"#temp#" = alloca { i64 } addrspace(11)*
  store { i64 } addrspace(11)* %0, { i64 } addrspace(11)** %"#temp#"
  call void @llvm.dbg.declare(metadata { i64 } addrspace(11)** %"#temp#", metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !17
  ret void, !dbg !17
}

The store into a stack slot turned out problematic for the GC invariant verifier, but only in the case of CUDAnative kernels where we wrap functions and thus the following check failed to prevent that check:

/* We currently don't obey this for arguments. That's ok - they're
externally rooted. */
if (!isa<Argument>(SI.getValueOperand())) {

This check can probably go now?

After:

define void @julia_kernel_2({ i64 } addrspace(11)* nocapture nonnull readonly dereferenceable(8)) !dbg !4 {
top:
  %1 = call %jl_value_t*** @julia.ptls_states()
  %2 = bitcast %jl_value_t*** %1 to %jl_value_t addrspace(10)**
  %3 = getelementptr inbounds %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %2, i64 2
  %4 = bitcast %jl_value_t addrspace(10)** %3 to i64**
  %5 = load i64*, i64** %4, !tbaa !14, !invariant.load !3
  call void @llvm.dbg.declare(metadata { i64 } addrspace(11)* %0, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !17
  ret void, !dbg !17
}

@maleadt maleadt added compiler:codegen Generation of LLVM IR and native code gpu Affects running Julia on a GPU labels Apr 11, 2019
@maleadt maleadt requested a review from Keno April 11, 2019 17:09
@maleadt
Copy link
Member Author

maleadt commented Apr 15, 2019

Would be nice to have in 1.2, so I'll merge this.

@maleadt maleadt merged commit 2b49d26 into master Apr 15, 2019
@KristofferC KristofferC deleted the tb/dibuilder_ptrarg branch April 15, 2019 12:39
@kryptine
Copy link

kryptine commented Apr 15, 2019 via email

@StefanKarpinski
Copy link
Member

Why are you unhappy about this, @kryptine?

@KristofferC KristofferC mentioned this pull request Apr 20, 2019
58 tasks
KristofferC pushed a commit that referenced this pull request Apr 20, 2019
Simplify llvm.dbg.declare for pointer arguments

(cherry picked from commit 2b49d26)
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 gpu Affects running Julia on a GPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPO safety Base passes

4 participants