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

Implement module-independent data retrieval operations for LLVMNamedMDNodeRef #995

Merged
merged 5 commits into from
Jan 15, 2021

Conversation

junlarsen
Copy link
Member

I'd like to expand the LLVM C API, more specifically the Modules/NamedMDNode API as it has a rather interesting way to retrieve data owned by a LLVMNamedMDNodeRef

In the C++ API, all the data associated with a llvm::NamedMDNode is owned by the node itself so it would only make sense to pull said data from the node itself. For unknown? reasons [1], the C API requires the owning module of a LLVMNamedMDNodeRef to retrieve the data. Looking closer at the implementation we can tell that we shouldn't need the module to retrieve parts of this data.

The functions I have added in this patch have the same functionality as the ones present in the C API. The only difference is that we don't need to provide a module to look up a LLVMNamedMDNodeRef inside of, instead we provide the instance returned by LLVMGetNamedMetadata or LLVMGetOrInsertNamedMetadata.

[1]: I imagine it was designed this way because in the C++ API, llvm::NamedMDNodes may be detached and not associated with a Module so providing the owning module was the natural choice, but this is not possible to do through the C API alone which means we can do better.

These parameters are present in the original code because it uses them to look up the metadata node inside the module
@saudet
Copy link
Member

saudet commented Jan 13, 2021

BTW, would you be able to help this guy? https://stackoverflow.com/questions/65634369/llvm-ir-with-java-api

@saudet saudet merged commit cce3d80 into bytedeco:master Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants