MachineModule pass

Hello everyone,
As I mentioned in my previous posts,I am using a machinefunction pass to find all the loops in the program and do some analysis on them. I have completed my pass now and it works correctly. but the only issue is that,I have noticed that if I have two functions in my program, and one of them is part of the loop for another one ,by using runonmachinefunction(), I will get one loop per each function. whereas the correct result is to find one loop at depth 1 and the other one at depth 2 as an inner loop.
In order to get this result, I am trying to use write a MachineModule Pass, but I can’t seem to find any MachineModule.h in codegen. Right now, is this even possible to write a machinemodule pass? If not what other options do I have to get the results I need.
Thank you,
Fami

Dear Fami,

Currently, there is no MachineModulePass in LLVM.

There was recently a discussion on the list about adding such a pass. Other LLVM users and myself are interested in such an infrastructure. You can search for that discussion on the LLVM Developer's mailing list archives.

Regarding your specific inquiry, you may be able to get what you want without a MachineModulePass. Right now, it sounds like you are thinking of the entire program as one large control flow graph. However, the LLVM IR (and MachineInstr IR) do not represent code that way. Each function has its own control flow graph; the basic blocks within these graphs may call to (and return from) other functions.

Most likely, you can adjust your analysis so that it uses loop analysis for local control flow and call graph analysis for inter-procedural control flow. In other words, it may not be necessary to view the entire program as one big control flow graph for your purposes.

Regards,

John Criswell