Where is liveness analysis pass?

Hello all

Currently I want to use the accurate liveness information when writing a *target independent* FunctionPass based on LLVM. The one I can find is LiveValues, a FunctionPass. But it doesn't use classic dataflow equation and can only provide approximate and conservative result. The another one is LiveVariables which use classic data flow equation, but it comes from Clang's analysis phase and only used in frontend.

My question is whether there is such a liveness analysis pass existed for FuntionPass?

Thanks for any suggestion.

Hi Zhanglin.

First I suggest to read http://llvm.org/docs/CodeGenerator.html#liveintervals. :slight_smile:

I saw the basic processing order of Live interval in backend LLVM source code as following:
1. LiveVariables::runOnMachineFunction() "lib/CodeGen/LiveVariables.cpp"
--> This pass computes live variable information for each virtual register and register allocatable physical register in the function. (Target dependent)
2. SlotIndexes::runOnMachineFunction() "lib/CodeGen/SlotIndexes.cpp"
--> This pass assigns indexes to each instruction and basic blocks
3. LiveIntervals::runOnMachineFunction() "lib/CodeGen/LiveIntervalAnalysis.cpp"
--> This pass computes live interval for live variables.
4. SimpleRegisterCoalescing::runOnMachineFunction "lib/CodeGen/SimpleRegisterCoalescing.cpp"
-> After SimpleRegisterCoalescing, live intervals are merged.

As you know, liveness inforamtion in backend is target dependent.
If you want to use target independent liveness information, I suggest you to use live variable information for virtual register in "LiveVariables::runOnMachineFunction()" pass.

Best regards,
Jin-Gu Kang