|
310 | 310 | # amenable to caching analysis infrastructure |
311 | 311 | function memcpy_alloca_to_loadstore(mod::LLVM.Module) |
312 | 312 | dl = datalayout(mod) |
| 313 | + ctx = context(mod) |
| 314 | + seen = TypeTreeTable() |
313 | 315 | for f in functions(mod) |
314 | 316 | if length(blocks(f)) != 0 |
315 | 317 | bb = first(blocks(f)) |
@@ -413,6 +415,41 @@ function memcpy_alloca_to_loadstore(mod::LLVM.Module) |
413 | 415 | bitcast!(B, src, LLVM.PointerType(elty, addrspace(value_type(src)))) |
414 | 416 |
|
415 | 417 | src = load!(B, elty, src) |
| 418 | + |
| 419 | + T_jlvalue = LLVM.StructType(LLVMType[]) |
| 420 | + T_prjlvalue = LLVM.PointerType(T_jlvalue, Tracked) |
| 421 | + |
| 422 | + legal, source_typ, byref = abs_typeof(src) |
| 423 | + codegen_typ = value_type(src) |
| 424 | + if legal |
| 425 | + if codegen_typ isa LLVM.PointerType || codegen_typ isa LLVM.IntegerType |
| 426 | + else |
| 427 | + @assert byref == GPUCompiler.BITS_VALUE |
| 428 | + source_typ |
| 429 | + end |
| 430 | + |
| 431 | + ec = typetree(source_typ, ctx, string(dl), seen) |
| 432 | + if byref == GPUCompiler.MUT_REF || byref == GPUCompiler.BITS_REF |
| 433 | + ec = copy(ec) |
| 434 | + merge!(ec, TypeTree(API.DT_Pointer, ctx)) |
| 435 | + only!(ec, -1) |
| 436 | + end |
| 437 | + metadata(src)["enzyme_type"] = to_md(ec, ctx) |
| 438 | + metadata(src)["enzymejl_source_type_$(source_typ)"] = MDNode(LLVM.Metadata[]) |
| 439 | + metadata(src)["enzymejl_byref_$(byref)"] = MDNode(LLVM.Metadata[]) |
| 440 | + |
| 441 | + @static if VERSION < v"1.11-" |
| 442 | + else |
| 443 | + legal2, obj = absint(src) |
| 444 | + if legal2 obj isa Memory && obj == typeof(obj).instance |
| 445 | + metadata(src)["nonnull"] = MDNode(LLVM.Metadata[]) |
| 446 | + end |
| 447 | + end |
| 448 | + |
| 449 | + elseif codegen_typ == T_prjlvalue |
| 450 | + metadata(src)["enzyme_type"] = |
| 451 | + to_md(typetree(Ptr{Cvoid}, ctx, dl, seen), ctx) |
| 452 | + end |
416 | 453 | FT = LLVM.FunctionType( |
417 | 454 | LLVM.VoidType(), |
418 | 455 | [LLVM.IntType(64), value_type(dst0)], |
|
0 commit comments