How to instrument source code

Hi all,

I’m a newbie to LLVM. I’m trying to extract number of instructions from a program source code

I’m able to extract instruction count by analysis pass but only can print it out using "opt load ". Can I use this obtained instruction_count and put it back in the source code.
I couldn’t find any examples that instrument source code as transformation passes modify bitcode files.

If this sounds absurd, is there any other way to extract code features and then insert it back in source code.