Hi, I am working on a project where I need to get a list of llvm Functions that were called during an execution (for futher analysis). To do this I have maintained a vector<llvm:: Function*> which I print out to a .ll file at the end. However this takes a lot of time since the number of call Instructions is HUGE. I feel that the bottleneck is the conversion from llvm:: Function to std::string How can I speed this up? I don't necessarily need it in .ll format, if there is a way to dump the entire llvm::Function object as a byte stream to a .dat file and read it back as objects in a separate script, that would work too. I'm not sure how to do this (tried few things didn't work), any help would be appreciated! Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200720/2f10aef4/attachment-0001.html>
if you're trying to serialize LLVM IR and read it back again later - yeah, probably best to use th binary searialization rather than the textual. If I were doing this I'd try building something using clang with -emit-llvm (that'll produce LLVM IR bitcode in the .o file) and debug that to see which APIs are used to do that. On Mon, Jul 20, 2020 at 3:19 AM Yugesh Kothari via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Hi, > > I am working on a project where I need to get a list of llvm Functions that were called during an execution (for futher analysis). > To do this I have maintained a vector<llvm:: Function*> which I print out to a .ll file at the end. However this takes a lot of time since the number of call Instructions is HUGE. > I feel that the bottleneck is the conversion from llvm:: Function to std::string > > How can I speed this up? > > I don't necessarily need it in .ll format, if there is a way to dump the entire llvm::Function object as a byte stream to a .dat file and read it back as objects in a separate script, that would work too. I'm not sure how to do this (tried few things didn't work), any help would be appreciated! > > Thanks! > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Replicating what clang -emit-llvm does sound like the better way to do it. I was looking under IRPrintingPasses but couldn't find anything specific that would allow me to print out say a std::vector<llvm:: Instruction*>. What do you think would be the easiest way to do this? Can I do some hack where I can get away without writing my own llvm pass? I'm not even sure what the right question to ask is, since this is the first time I'm working with llvm. Thanks! On Mon, 20 Jul, 2020, 10:37 pm David Blaikie, <dblaikie at gmail.com> wrote:> if you're trying to serialize LLVM IR and read it back again later - > yeah, probably best to use th binary searialization rather than the > textual. If I were doing this I'd try building something using clang > with -emit-llvm (that'll produce LLVM IR bitcode in the .o file) and > debug that to see which APIs are used to do that. > > On Mon, Jul 20, 2020 at 3:19 AM Yugesh Kothari via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > > > Hi, > > > > I am working on a project where I need to get a list of llvm Functions > that were called during an execution (for futher analysis). > > To do this I have maintained a vector<llvm:: Function*> which I print > out to a .ll file at the end. However this takes a lot of time since the > number of call Instructions is HUGE. > > I feel that the bottleneck is the conversion from llvm:: Function to > std::string > > > > How can I speed this up? > > > > I don't necessarily need it in .ll format, if there is a way to dump the > entire llvm::Function object as a byte stream to a .dat file and read it > back as objects in a separate script, that would work too. I'm not sure how > to do this (tried few things didn't work), any help would be appreciated! > > > > Thanks! > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > https://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/20200721/161bdb06/attachment.html>