Skip to content

Commit a0ac09c

Browse files
committed
Fix Metadata.Value conversion.
1 parent 9b3369c commit a0ac09c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/core/metadata.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ end
4545
end
4646
reftype(::Type{Metadata}) = API.LLVMMetadataRef
4747

48-
function Value(md::Metadata, ctx::Context)
49-
return MetadataAsValue(API.LLVMMetadataAsValue(ref(ctx), md))
50-
end
51-
5248
function Metadata(val::Value)
5349
return Metadata(LLVM.API.LLVMValueAsMetadata(ref(val)))
5450
end
51+
52+
function Value(md::Metadata, ctx::Context)
53+
return MetadataAsValue(API.LLVMMetadataAsValue(ref(ctx), ref(md)))
54+
end

test/core.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ LLVM.Module("SomeModule", ctx) do mod
530530
@test convert(String, datalayout(mod)) == dummyLayout
531531

532532
if LLVM.version() >= v"8.0"
533-
md = Metadata(ConstantInt(42))
533+
md = Metadata(ConstantInt(42, ctx))
534534

535535
mod_flags = flags(mod)
536536
push!(mod_flags, LLVM.API.LLVMModuleFlagBehaviorError, "foobar", md)
@@ -942,6 +942,10 @@ LLVM.Module("SomeModule", ctx) do mod
942942
@test isempty(md)
943943
@test !haskey(md, LLVM.MD_dbg)
944944
end
945+
let val = ConstantInt(42, ctx)
946+
md = Metadata(val)
947+
@test first(operands(LLVM.Value(md, ctx))) == val
948+
end
945949

946950
@test retinst in instructions(bb3)
947951
delete!(bb3, retinst)

0 commit comments

Comments
 (0)