[LLVMdev] Difficulty inserting putchar in IR
criswell at illinois.edu
Thu Feb 9 11:11:12 PST 2012
On 2/9/12 1:02 PM, tarun agrawal wrote:
> 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);
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev