[LLVMdev] Calling a function with bad signature, possible bug.

Iaroslav Markov ymarkov at cs.stonybrook.edu
Thu Jul 26 10:30:10 PDT 2012


Hello,

I'm having troubles with writing a pass. In my pass I've have created a function that has two parameters - both of type i8*. Initially I wrote this function in C, that I translated it into IR, and then by using llc -march=cpp I got it's implementation in cpp code that actually inserts IR instructions. Then, I inserted this cpp code in my pass.

And in some places of a program my pass inserts instrumentation that calls this function. 

The problem I'm experiencing is very strange. I'm getting "Calling a function with bad signature", when my pass inserts a call to this function. But I don't have any problems with my pass if I run clang -emit-llvm -S, then llc and then gcc. With this approach I get a binary with my instrumentation inserted.

This line causes a problem - assert((i >= FTy->getNumParams() ||
            FTy->getParamType(i) == Args[i]->getType()) &&
           "Calling a function with a bad signature!");

I tried to get a dump of  FTy->getParamType(i) and  Args[i]->getType(), but I wasn't able to do it in gdb - everytime I create a breakpoint it just misses it. So I made the following:

FTy->getParamType(i)->dump();
      errs() << "\nparamtype end----------- \n";
      Args[i]->getType()->dump();
      errs() << "\ngettype end ------------\n";
      errs() << i << "\ni------------------\n";
      errs() << FTy->getNumParams() << "\ngetnumparams end ------------\n";
      errs() << "assert " << (FTy->getParamType(i) == Args[i]->getType()) << "\n";
      assert((i >= FTy->getNumParams() ||
            FTy->getParamType(i) == Args[i]->getType()) &&
           "Calling a function with a bad signature!");

I know, this is a bizzare, but still. The output I've got:


doTaint
i8*
paramtype end----------- 
i8*
gettype end ------------
0
i------------------
2
getnumparams end ------------
assert 0

You see - totally unexplainable: FTy->getParamType(i) and Args[i]->getType() are the same, but assertion still fails.

Can anybody comment on this.

Best,
Yaroslav.



More information about the llvm-dev mailing list