如何创建通过LLVM-C API命名的元数据? [英] How do I create named metadata via the llvm-c api?

查看:236
本文介绍了如何创建通过LLVM-C API命名的元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要调试元数据添加到我的生成LLVM IR,这是通过C API创建的。但是,我想不出如何创建一个名为元数据节点(如!llvm.dbg.cu),甚至是如何创建具有唯一编号的元数据节点(即!0!1,等等)。添加元数据操作数指令看起来pretty简单,但我无法弄清楚如何创建独立的元数据节点。

I want to add debug metadata to my generated llvm IR, which is created via the C API. However, I can't figure out how to create named metadata nodes (such as !llvm.dbg.cu), or even how to create metadata nodes with unique numbers (ie. !0, !1, etc.). Adding metadata operands to instructions looks pretty simple, but I cannot figure out how to create standalone metadata nodes.

推荐答案

截至LLVM 3.0,没有用于创建或修改命名元数据C API暴露不起作用。一个新的功能(LLVMAddNamedMetadataOperand)是最近添加该API ,3.0发布之后。

As at LLVM 3.0, there is no function exposed in the C API for creating or modifying named metadata. A new function (LLVMAddNamedMetadataOperand) was recently added to the API, after the 3.0 release.

如果你是从源代码舒服建设LLVM,你可以从树干这种支持。请参阅入门关于如何建立LLVM 页面。否则,你将不得不等待,直到LLVM 3.1被释放。

If you're comfortable building LLVM from source, you can get this support from the trunk. See the Getting Started page on how to build LLVM. Otherwise you'll have to wait until LLVM 3.1 is released.

在功能可用时,它会调用一个简单的问题:

When the function is available, it'll be a simple matter of calling:

LLVMAddNamedMetadataOperand(module, "named_md_name", mdnode);

如果有一个名为named_md_name没有名为元数据,那么人们将被创建。否则现有对象将被更新。

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

这篇关于如何创建通过LLVM-C API命名的元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆