Skip to content

Commit 5f34de2

Browse files
authored
First relocation of globals (#1684)
* First relocation of globals * Fix relocation * rework * load glob * with orcv1, maybe? * Support setting metadata on old llvm.jl * Vendor global set md * More 1.6 orc * add libdl * orcv1 * fix
1 parent 3d1d6e6 commit 5f34de2

File tree

13 files changed

+377
-97
lines changed

13 files changed

+377
-97
lines changed

src/absint.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ function absint(arg::LLVM.Value, partial::Bool=false)
103103
return (true, typ)
104104
end
105105

106+
if isa(arg, GlobalVariable)
107+
gname = LLVM.name(arg)
108+
for (k, v) in JuliaGlobalNameMap
109+
if gname == k || gname == "ejl_"*k
110+
return (true, v)
111+
end
112+
end
113+
for (k, v) in JuliaEnzymeNameMap
114+
if gname == k || gname == "ejl_"*k
115+
return (true, v)
116+
end
117+
end
118+
end
119+
106120
if isa(arg, LLVM.LoadInst) && value_type(arg) == LLVM.PointerType(LLVM.StructType(LLVMType[]), Tracked)
107121
ptr = operands(arg)[1]
108122
ce = ptr

src/api.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ struct CFnTypeInfo
103103
known_values::Ptr{IntList}
104104
end
105105

106+
SetMD(v::Union{LLVM.Instruction, LLVM.GlobalVariable}, kind::String, node::LLVM.Metadata) = ccall((:EnzymeSetStringMD, libEnzyme), Cvoid, (LLVM.API.LLVMValueRef, Cstring, LLVM.API.LLVMValueRef), v, kind, LLVM.Value(node))
106107

107108
@static if !isdefined(LLVM, :ValueMetadataDict)
108109
Base.haskey(md::LLVM.InstructionMetadataDict, kind::String) =

0 commit comments

Comments
 (0)