[llvm-dev] Is there a way to determine what CPU resource is used by which instruction?

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 20 07:20:16 PDT 2015

> On Oct 19, 2015, at 11:58 AM, Rail Shafigulin via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I'm trying to figure out if there is a way to figure out what processor resource is used by which instruction during scheduling. This is purely for debugging purposes. Since I'm somewhat new to LLVM it is a bit difficult for me to figure this out.
> Initial idea was to insert comments in the generated assembly which would tell me what what resource is used. MachineInstr has a  uint8_t AsmPrinterFlags, which I want to use to pass information from the scheduler to AsmPrinter about which resource is used. I've asked on the IRC channel how to do it but nobody seems to know. A scheduling debug log was also mentioned (supposedly it should provide me with the same information) but I don't know how to generate one.

Look for a #define like this in the llvm CodeGen files:
#define DEBUG_TYPE “misched"

This allows you to use
llc -debug-only=misched
clang -mllvm -ldebug-only=misched

to enable the debugging output for that file/topic. You may use the flag multiple times to enable multiple debugging outputs.

- Matthias

More information about the llvm-dev mailing list