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

Metadata APIs need to be generalized to Value* #417

Closed
maleadt opened this issue Jun 12, 2024 · 1 comment
Closed

Metadata APIs need to be generalized to Value* #417

maleadt opened this issue Jun 12, 2024 · 1 comment

Comments

@maleadt
Copy link
Owner

maleadt commented Jun 12, 2024

LLVM currently defines them as:

int LLVMHasMetadata(LLVMValueRef Inst) {
  return unwrap<Instruction>(Inst)->hasMetadata();
}

LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID) {
  auto *I = unwrap<Instruction>(Inst);
  assert(I && "Expected instruction");
  if (auto *MD = I->getMetadata(KindID))
    return wrap(MetadataAsValue::get(I->getContext(), MD));
  return nullptr;
}

This triggers an assertion with:

using LLVM

@dispose ctx=Context() mod=LLVM.Module("SomeModule") begin
    st = LLVM.StructType("SomeType")
    ft = LLVM.FunctionType(st, [st])
    fn = LLVM.Function(mod, "SomeFunction", ft)

    @show metadata(fn)
end
@maleadt
Copy link
Owner Author

maleadt commented Jun 18, 2024

Worked around in #418

@maleadt maleadt closed this as completed Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant