[LLVMdev] Wierd behavior from getAnalysis<>

Pape Sylla papesylla at gmail.com
Tue Sep 14 08:40:50 PDT 2010


Hello,

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<InsertDummyTargsPass>();

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;
        PM.add(p);

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<InsertDummyTargsPass>();
    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.


Pape
University of Maryland at College Park
ECE Department
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100914/d1d8011c/attachment.html>


More information about the llvm-dev mailing list