Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Call @printf in LLVM through the module builder system

Tags:

llvm

llvm-ir

I am learning LLVM. I understand that thre are a number of useful C functions that are provided in LLVM already as intrinsic. So I'm trying to call the @printf function from my code.

I found the respective parts in the LLVM reference manual that describe the IR code to do that, which is relative clear:

declare i32 @printf(i8* noalias nocapture, ...)
call i32 (i8*, ...)* @printf(i8* %msg, i32 12, i8 42)

etc. But I am not able to find how to do that using the IRBuilder<> class. I checked the builder class but I wasn't able to figure anything out.

I don't want to pass any fancy variables, basically just something like

printf( "%lu", variable_64_bit );

in C or something like that.

Could anybody give me an idea what I must do to call the printf function through the builder.

Thanks in advance

like image 900
Rick Avatar asked May 14 '15 09:05

Rick


1 Answers

I found an answer to this problem elsewhere. In fact it goes somewhat beyond my original question but it was helpful for me and hopefully it will help somebody else as well.

like image 53
Rick Avatar answered Oct 26 '22 01:10

Rick