[LLVMdev] Difficulty inserting putchar in IR

John Criswell criswell at illinois.edu
Thu Feb 9 11:11:12 PST 2012


On 2/9/12 1:02 PM, tarun agrawal wrote:
> Hi,
>
> I have written a simple code to  insert putchar() function into IR.
> It compiled well but when  I tried to run the generated .bc file with 
> lli, its not showing
> proper output.
>
> Function *putchar_func = cast<Function>(M->
>     getOrInsertFunction("putchar", IntegerType::getInt32Ty(Context),
>                         IntegerType::getInt32Ty(Context), NULL));
>
>   Value *One = ConstantInt::get(Type::getInt32Ty(Context), 1);
>
>   CallInst *CallFibX1 = CallInst::Create(putchar_func, One, "fibx1", BB);
>   CallFibX1->setTailCall();

I'm assuming the program runs through lli but is not showing any output.

I think you're calling putchar() with a value of 1.  That may be an 
unprintable character (like ctrl-a).  Try a value that is an ASCII 
character (I think 'A' is 65, but it's been awhile).

-- John T.

>
>
>
> Thanks and Regards,
> Tarun Agrawal
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120209/0c138605/attachment.html>


More information about the llvm-dev mailing list