issue writing llvm metadata

Hi,

I am looking to write customized metadata to a particular load instruction using LLVM transform pass (A function pass to be specific). I have the following code snippet.

Value *CI = ConstantInt::get(getGlobalContext(), APInt(8,2));

ArrayRef<Value*> temp = ArrayRef<Value*>( CI);

MDNode *Node = MDNode::get(load->getContext(), temp);

load->setMetadata(“mydata”,Node);

On running the pass with my input_file, I could not find the new metadata node in the .o file when i run llvm-dis with it . What am I missing ? Please help me out!

I run the pass as

opt -load path_to_my_library.so -pass_name < input_file.o > /dev/null

Should I do something different for a transform pass to work?

Thank you!

regards,
Ashwin

Hi Ashwin,

I run the pass as

*opt -load path_to_my_library.so -pass_name < input_file.o > /dev/null*

maybe write your output to a file rather than throwing it away?

Ciao, Duncan.