[LLVMdev] insert printf into IR

Duncan Sands baldrick at free.fr
Thu Mar 31 23:44:19 PDT 2011


Hi George,

>    I am trying to insert printf ("%d", v), where v is an integer param, into the IR.
> I am doing something wrong because I keep getting segfaults.

if you are doing development with LLVM then you should build LLVM with
assertions enabled.  That way you get understandable failures rather
than obscure segmentation faults.

> Function *f = cast<Function>(temp);

If printf was already present in the module but with a different type then
temp will be a bitcast of the existing declaration (the bitcast changing
the type), and this will fail.

Ciao, Duncan.



More information about the llvm-dev mailing list