[LLVMdev] Lifetime analysis of variables within a module
Antonio Martínez Álvarez
amartinez76 at gmail.com
Wed Oct 31 08:49:15 PDT 2012
Hi all,
I'm looking for a LLVM method/class/strategy to know the lifetime of
every variable/value used in a given Module.
I want to know the variables that must be alive at the input and at the
end of every function call (and every BasicBlock).
By creating a pass inheriting from ModulePass I can reach up to here:
virtual bool runOnFunction(Function &F) {
...
for (Function::iterator bbi = F.begin(), bbf = F.end(); bbi != bbf;
bbi++)
{
...
for (BasicBlock::iterator insi = bbi->begin(), insf = bbi->end();
insi != insf; insi++)
{
...
for (User::op_iterator opi = insi->op_begin(), opf =
insi->op_end(); opi != opf; opi++)
{
if(isa<Instruction>(opi) || isa<Argument>(opi))
{
// Here I am <===============
}
How can I use LiveIntervals/LiveVariables/LiveRange to obtain the live
range for a given variable of interest?
BTW, do you know any working example of using MachineFunctionPass or
LiveIntervals LLVM passes? Every time I use it, opt generates output
such as:
opt: PassManager.cpp:597: void
llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI &&
"Expected required passes to be initialized"' failed.
0 libLLVM-3.1.so 0x00007f42eb6469ef
...
7 libLLVM-3.1.so 0x00007f42eb1ccafa
llvm::PMTopLevelManager::schedulePass(llvm::Pass*) + 1226
Thank you in advance !!!!
More information about the llvm-dev
mailing list