How to create metadata named llvm-c api?

I want to add debug metadata to my generated IRI llvm, which is created through API C. However, I cannot figure out how to create named metadata nodes (e.g.! Llvm.dbg.cu) or even create metadata nodes with unique numbers (i.e.. ! 0,! 1, etc.). Adding metadata operands to statements looks pretty simple, but I can't figure out how to create stand-alone metadata nodes.

+4
source share
1 answer

Like LLVM 3.0, the C API does not have a function designed to create or modify named metadata. A new feature (LLVMAddNamedMetadataOperand) was recently added to the API after release 3.0.

If you are comfortable creating LLVMs from the source code, you can get this support from the torso. See the Getting Started page on how to create an LLVM. Otherwise, you will have to wait until LLVM 3.1 is released.

When a function is available, it will be a simple call:

LLVMAddNamedMetadataOperand(module, "named_md_name", mdnode); 

If there is no metadata named "named_md_name", then it will be created. Otherwise, the existing object will be updated.

+4
source

Source: https://habr.com/ru/post/1379509/


All Articles