[llvm-dev] llvm pass is very slow
John Criswell via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 16 08:30:57 PDT 2018
On 7/14/18 9:21 PM, Muhui Jiang via llvm-dev wrote:
> Hi
>
> I write a LLVM function pass. The pass will loop the basicblock in the
> function, check the instruction's type with dyn_cast<switchinst>,
> print the instruction and the basicblock's successors. I think it is
> not very complex.
>
> My bitcode file is about 30M. My CPU is i7-7700(3.6GHz). It has been
> running for 60 hours but it is still running. I am not sure whether
> this is a normal behavior. If so, any options or suggestions to help
> me speed up the analysis. Many Thanks
The first thing you should check is whether you've written the loop
properly. It's possible that you've somehow written an infinite loop.
If your pass is adding instructions, be careful that you're not
invalidating the iterator that you're using to loop over the
instructions. That might cause a non-obvious error.
The second thing to consider is to use the InstVisitor class instead of
writing a loop. Look at InstVisitor.h in the LLVM source code; it has
comments that show you how to use it. In a nutshell, your FunctionPass
will be a subclass of InstVisitor. You then implement the
visitSwitchInst() method and call visit() on the function in
runOnFunction, and you're done.
http://llvm.org/doxygen/classllvm_1_1InstVisitor.html
Regards,
John Criswell
>
> Regards
> Muhui
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180716/6d6f58e9/attachment.html>
More information about the llvm-dev
mailing list