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.
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.
Thank you for the very useful guidance. It helped me. I understood http://llvm.org/docs/WritingAnLLVMPass.html and http://llvm.org/docs/CMake.html#cmake-out-of-source-pass and applied to my pass. But I have another problem. After any change in pass, I must build LLVM again? It takes a long time. Is there a way to build only pass?