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

Iaroslav Markov ymarkov at cs.stonybrook.edu
Thu Jul 26 11:11:28 PDT 2012


I found the source of my problem. The problem happened because type of the parameter I called the function with was declared in a different context (getGlobalContext()) comparing to function type (mod->getContext()).

Best,
Yaroslav.
________________________________________
From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] on behalf of Iaroslav Markov [ymarkov at cs.stonybrook.edu]
Sent: Thursday, July 26, 2012 1:31 PM
To: llvmdev at cs.uiuc.edu
Subject: [LLVMdev] Calling a function with bad signature, possible bug.

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.
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list