[LLVMdev] extending LLVM - basic block reordering

John Criswell jtcriswel at gmail.com
Mon Oct 6 16:17:04 PDT 2014


Dear Zahra,

To reorder basic blocks, all you need to do is to write an LLVM pass 
that changes the order that the block appear within the list of basic 
blocks that belong to the function.  The only block you can't reorder is 
the entry block which, I think, always needs to be the first basic block 
in the list.

The first thing you should do is read the document "Writing an LLVM 
Pass" (http://llvm.org/docs/WritingAnLLVMPass.html).  You should also 
read the "LLVM Programmer's Manual" 
(http://llvm.org/docs/ProgrammersManual.html).  To look up specific 
information on LLVM classes, use doxygen 
(http://llvm.org/doxygen/hierarchy.html).

The first coding task would be to write a skeleton FunctionPass and run 
it through the opt program.  After that, you should be able to add code 
to your FunctionPass to reorder the basic blocks within a function.

Regards,

John Criswell


On 10/5/14, 11:34 AM, Zahra fatehi marj wrote:
> Hi.
> I want to change order of code basic blocks in memory. I visited 
> "http://llvm.org/docs/ExtendingLLVM.html" page and it advised me 
> to ask it before any effort.
> What parts of LLVM help me and how? I am a newbie on LLVM.
> Thanks.
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


-- 
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/20141006/c87a8039/attachment.html>


More information about the llvm-dev mailing list