[LLVMdev] IntervalPartition and Intervals per function

Prakash Prabhu prakash.prabhu at gmail.com
Wed Aug 27 13:35:35 PDT 2008


I wrote a Function pass that requires the IntervalPartition pass in
order to obtain the set of intervals for every function:

virtual void getAnalysisUsage(AnalysisUsage &AU) const {

and  get a handle to it in the runOnFunction method of my CustomPass:

bool CustomPass::runOnFunction(Function& F)
	IntervalPartition& iPart = getAnalysis<IntervalPartition>();
        const std::vector<Interval*>& intervals = iPart.getIntervals();

However when i access the intervals vector for a particular call of
runOnFunction, it seems that alll intervals computed for the earlier
functions are still in the
vector. To verify this, I added some debug in addIntervalToPartition:

void IntervalPartition::addIntervalToPartition(Interval *I)
  DOUT << "Interval Size: " << Intervals.size() << "\n";

I get the following debug output:

Pass Arguments:  -intervals -custom -preverify -domtree -verify
Target Data Layout
  ModulePass Manager
    FunctionPass Manager
      Interval Partition Construction
      Custom Pass
      Preliminary module verification
      Dominator Tree Construction
      Module Verifier

Interval Size: 0
Interval Size: 1
Interval Size: 2
Function: lresurrect
Interval Size: 3
Interval Size: 4
Interval Size: 5
Interval Size: 6
Interval Size: 7
Function: ldndate

As seen above, the intervals computed for lresurrect are still present
in the intervals vector, when function ldndate is accessed. Is this
expected ? Or maybe I am missing something here ?

(Actually I tried to lift the IntervalPartition::destroy() function
from private to public access and call it from CustomPass's
runOnFunction, but it segfaulted. I thought i'd send ask this on the
list before digging further.)


More information about the llvm-dev mailing list