Wierd behavior from getAnalysis<>


I am seeing a weird behavior from getAnalysis<>. I seem to not get back a valid object type, which leads to other errors.

when I am executing the following line:

InsertDummyTargsPass& dt = getAnalysis();

I am apparently getting back an object of type llvm::Pass;

This is how I checked it: with the following code I create the Object print its address value and add it to the pass manager

InsertDummyTargsPass* p = new InsertDummyTargsPass(bp, ipInfo, exeInfo);
std::cerr << “dummytargspass :” << p;
llvm::Pass* parent = p;
std::cerr << “value of parent:” << parent;

I get from the cerr statement

dummytargspass :0x971acd8
value of parent:0x971acf4

In the InsertDummyTargsPass::runOnModule I have the following statement

printf(“value of this %x\n”, (unsigned int) this);

which gives:
value of this 971acd8

then I use in a different pass

InsertDummyTargsPass& dt = getAnalysis();
printf(“value of dt* %x\n”, (unsigned int) &dt);

which gives
value of dt* 971acf4

which suggests that I am getting back a reference of type llvm::Pass instead of InsertDummyTargsPass which is what I wanted. Can anyone tell how to fix this issue.

University of Maryland at College Park
ECE Department

I think you need to implement getAdjustedAnalysisPointer() in your pass.