Inserting annotations

Hello together,

how can i insert annotations in IR ?

I want actually write something like:

<br>CallInst *call = CallInst::Create( ??? , aBasicBlock);<br><br>in my pass.<br><br><br>Regards<br>Raad<br><br>


how can i insert annotations in IR ?


I want actually write something like:
CallInst *call = CallInst::Create( ??? , aBasicBlock);

It's illegal to take the address of a basic block in LLVM IR.



As far as I know, Instruction class does not inherit “Annotable” Class. Only Function inherits annotable according to the documentation of annotable class.

What you are asking would require adding annotations at instruction level, which does not seem to be possible. You can maintain external maps between instructions and your annotations,


Read about the @llvm.annotation family of intrinsics.

llvm::Annotatable is a deprecated means of maintaining “on the side” data structures internal to the compiler. Its name is misleading, and it has nothing to do with the sort of annotations most people are interested in. We would like it to go away; it is currently used only to attach the temporary MachineFunction data structure to a Function during code generation. Developers with interest Annotatable as it stands are advised to use a SmallPtrSet instead.