I wanted to collect the register usage stats for the program assigned by compiler(in other words “how many time each register will be accessed by the program when it will execute”). How to write LLVM pass which will analyse the code after LLVM global register allocation pass and output the stats.
Are you counting the number of static uses of a register in each function, or are you instrumenting the program to count the number of times a register is used during execution? Regardless of which you are doing, you will need to write a MachineFunctionPass that performs the analysis and/or instrumentation. You can read about the MachineFunctionPass in the “How to Write an LLVM Pass” document. This document () will also be useful. Regards, John Criswell