How to preserve struct member identifiers when compiling to LLVM IR with Clang?
Say I have the following C structure definition:
struct stringStructure
{
char *stringVariable;
};
For the above, Clang produces the following LLVM IR:
%struct.stringStructure = type { i8* }
...which includes everything in my definition except the variable identifier stringVariable
.
I'd like to find some way to export the identifier into the generated LLVM IR, so that I can refer to it by name from my application (which uses the LLVM C++ API).
I've tried adding the annotate
attribute, as follows:
char *stringVariable __attribute__((annotate("stringVariable")));
...but the annotation doesn't seem to make it through (the structure is still just defined as type { i8* }
).
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LLVM IR does not preserve many features of the source language. You can check this via the code like
Only one type will be emitted at all since types in LLVM are structurally equivalent. If you want to preserve arbitrary information about the constructs of your source code you have to emit/use debug information.