How to attach metadata to LLVM IR using the C++ API?

后端 未结 2 1401
灰色年华
灰色年华 2021-01-21 13:50

Can anyone point me to a concrete example of attaching metadata to llvm-ir using the c++ api?

I\'ve read this page http://llvm.org/docs/SourceLevelDebugging.html.

<
2条回答
  •  醉酒成梦
    2021-01-21 14:37

    There are two things you can do.

    1. Attach metadata nodes to instructions (like the !dbg nodes from the link you referenced). For that, there's the Instruction::setMetadata method
    2. Create named metadata nodes in a Module, not attached to any particular instruction. For that, use Module::getOrInsertNamedMetadata.

提交回复
热议问题