fateme Hoseini via llvm-dev
2016-Apr-05 20:28 UTC
[llvm-dev] Add Call instruction in IR for a non-existing function
Hello everyone, I am trying to add checkpoints to my IR code. In order to do that I need to add this instruction: call void @m5_checkpoint(i64 0, i64 0) to some of the basic blocks in my benchmark. m5_checkpoint is a function defined for checkpointing in another simulator and is not included in my benchmark source code. So I need to create this instruction and I couldn't figure out how to do this by reading the manual. I will appreciate if anyone can help me . Regards, Fami -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160405/120592d6/attachment.html>
serge guelton via llvm-dev
2016-Apr-05 20:38 UTC
[llvm-dev] Add Call instruction in IR for a non-existing function
On Tue, Apr 05, 2016 at 04:28:18PM -0400, fateme Hoseini via llvm-dev wrote:> Hello everyone, > I am trying to add checkpoints to my IR code. In order to do that I need to > add this instruction: > call void @m5_checkpoint(i64 0, i64 0) > to some of the basic blocks in my benchmark. > m5_checkpoint is a function defined for checkpointing in another simulator > and is not included in my benchmark source code. So I need to create this > instruction and I couldn't figure out how to do this by reading the manual. > I will appreciate if anyone can help me . > Regards, > FamiHi Fami, you need to declare your function as an external global Symbol in order to use it (you will still need to provide the symbol at linktime though). One way to do this is to call the module method getOrInsertFunction after creating the correct Functiontype: auto *FT = llvm::FunctionType::get(...); M.getOrInsertFunction("m5_checkpoint", FT) hope it helps, Serge
Kevin Hu via llvm-dev
2016-Apr-05 20:48 UTC
[llvm-dev] Add Call instruction in IR for a non-existing function
Hi, I think it's called getOrInsertFunction() in module class, with reference from: http://llvm.org/releases/2.6/docs/tutorial/JITTutorial1.html Also, when you encounter questions for LLVM C++ APIs in the future, you can write desired output code and use llc to generate proper C++API code, which I think is a very neat feature of LLVM. e.g. clang -c -emit-llvm your_desired_output.c llc -march=cpp your_desired_output.bc Hope this helps. Regards, Kevin On Tue, Apr 5, 2016 at 3:28 PM fateme Hoseini via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello everyone, > I am trying to add checkpoints to my IR code. In order to do that I need > to add this instruction: > call void @m5_checkpoint(i64 0, i64 0) > to some of the basic blocks in my benchmark. > m5_checkpoint is a function defined for checkpointing in another simulator > and is not included in my benchmark source code. So I need to create this > instruction and I couldn't figure out how to do this by reading the manual. > I will appreciate if anyone can help me . > Regards, > Fami > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160405/4fc705c0/attachment.html>
fateme Hoseini via llvm-dev
2016-Apr-07 14:10 UTC
[llvm-dev] Add Call instruction in IR for a non-existing function
Thank you all. Kevin, I didn't get your point. Do you mean to change the bc file and them create C++ out of it? Regards, Fami On Tue, Apr 5, 2016 at 4:48 PM, Kevin Hu <hxy9243 at gmail.com> wrote:> Hi, > > I think it's called getOrInsertFunction() in module class, with reference > from: > > http://llvm.org/releases/2.6/docs/tutorial/JITTutorial1.html > > Also, when you encounter questions for LLVM C++ APIs in the future, you > can write desired output code and use llc to generate proper C++API code, > which I think is a very neat feature of LLVM. > > e.g. > clang -c -emit-llvm your_desired_output.c > llc -march=cpp your_desired_output.bc > > Hope this helps. > Regards, > Kevin > > > On Tue, Apr 5, 2016 at 3:28 PM fateme Hoseini via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hello everyone, >> I am trying to add checkpoints to my IR code. In order to do that I need >> to add this instruction: >> call void @m5_checkpoint(i64 0, i64 0) >> to some of the basic blocks in my benchmark. >> m5_checkpoint is a function defined for checkpointing in another >> simulator and is not included in my benchmark source code. So I need to >> create this instruction and I couldn't figure out how to do this by reading >> the manual. I will appreciate if anyone can help me . >> Regards, >> Fami >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160407/96503a58/attachment.html>