On Oct 31, 2012, at 1:41 PM, Madhusudan C.S <madhusudancs at gmail.com> wrote:> I have spent last 4 weeks trying to figure out how to implement > Interprocedural Register Allocation. I must admit that I was really > overwhelmed with LLVM's codebase while trying to figure this out :) > There is so much to know! I think I have reached a point where I > have some sort of basic understanding of what needs to be done, > but I need some help from here on. So here is the summary of > what I know and for what I need more help. > > I see that lib/CodeGen/Passes.cpp adds PrologEpilogInserter (PEI > henceforth) pass after the RegAlloc pass. Do I understand correctly > that LLVM first performs a given pass on all the functions before > moving to the next pass?No, it's the other way around. You may want to read up on the pass manager and play with the -debug-pass option. /jakob
Hi Jakob, I have been trying to learn how the CodeGen passes work and I am playing around with the -debug-pass option. I tried implementing a bare CallGraphSCCPass based Pass in the CodeGen which basically does nothing for now. I mostly tried to replicate what RegAlloc passes do. I did this instead of modifying the existing RegAlloc passes to use CallGraphSCCPass because that was becoming way too complicated for simple experiments I was trying when I tried to do that. I am attaching the diffs of what I actually tried to do for reference here. It is not really well documented and there is a lot of copy/paste code there, but well, this is not really the final code to be submitted or anything, just to play around, so I have not really put efforts into comments etc. yet. So when I build LLVM and try to run the pass with the following command: $ llc --debug -cgregalloc=cg <$HOME/cpptry/manyfuncs.bc I get the following error. Args: llc --debug -cgregalloc=cg Subtarget features: SSELevel 6, 3DNowLevel 0, 64bit 1 Pass ID not registered UNREACHABLE executed at /media/python/workspace/llvm/ lib/CodeGen/Passes.cpp:324! 0 llc 0x0000000001453dfe 1 llc 0x00000000014542fa 2 libpthread.so.0 0x00007f020b750cb0 3 libc.so.6 0x00007f020a99f425 gsignal + 53 4 libc.so.6 0x00007f020a9a2b8b abort + 379 5 llc 0x000000000143b1a6 6 llc 0x0000000000f3cb02 llvm::TargetPassConfig::addPass(void const*) + 146 7 llc 0x0000000000f3ddef llvm::TargetPassConfig::addCGRegAlloc(llvm::CallGraphSCCPass*) + 47 8 llc 0x0000000000f3d7df llvm::TargetPassConfig::addMachinePasses() + 719 9 llc 0x0000000000e5a3af 10 llc 0x0000000000e5994c llvm::LLVMTargetMachine::addPassesToEmitFile(llvm::PassManagerBase&, llvm::formatted_raw_ostream&, llvm::TargetMachine::CodeGenFileType, bool, void const*, void const*) + 92 11 llc 0x00000000005f6002 main + 4946 12 libc.so.6 0x00007f020a98a76d __libc_start_main + 237 13 llc 0x00000000005f4bd1 Stack dump: 0. Program arguments: llc --debug -cgregalloc=cg Aborted (core dumped) I am not really sure, why it says "Pass ID is not registered". I did quite a lot of internet searching about it and whatever I try to look for I end up on the exact LLVM line of code which prints this error line. So, I am not sure what is going on. Is this because CallGraphSCCPass does not register anything with the MachineFunctionPass-es? Or is this because CallGraphSCCPass does not do some magic which is specific to CodeGen passes? Can you please help me with this a bit? May be some pointers? On Fri, Nov 2, 2012 at 2:03 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk>wrote:> > On Oct 31, 2012, at 1:41 PM, Madhusudan C.S <madhusudancs at gmail.com> > wrote: > > > I have spent last 4 weeks trying to figure out how to implement > > Interprocedural Register Allocation. I must admit that I was really > > overwhelmed with LLVM's codebase while trying to figure this out :) > > There is so much to know! I think I have reached a point where I > > have some sort of basic understanding of what needs to be done, > > but I need some help from here on. So here is the summary of > > what I know and for what I need more help. > > > > I see that lib/CodeGen/Passes.cpp adds PrologEpilogInserter (PEI > > henceforth) pass after the RegAlloc pass. Do I understand correctly > > that LLVM first performs a given pass on all the functions before > > moving to the next pass? > > No, it's the other way around. > > You may want to read up on the pass manager and play with the -debug-pass > option. > > /jakob > >-- Thanks and regards, Madhusudan.C.S -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121206/16e562ca/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-CGTry-pass.patch Type: application/octet-stream Size: 10711 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121206/16e562ca/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: manyfuncs.bc Type: application/octet-stream Size: 1168 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121206/16e562ca/attachment-0001.obj>
Hi, Can some one please help me with this problem? From what I understand: const PassInfo *PassRegistry::getPassInfo(const void *TI) const in lib/VMCore/PassRegistry.cpp method returns 0 when it is expected to return a pass info. I am not sure what PassInfo is expected here. I tried to put a few DEBUG statements within that method but I could not find the information needed. So some pass is not being registered. Can some one please help me? On Fri, Dec 7, 2012 at 7:23 AM, Madhusudan C.S <madhusudancs at gmail.com>wrote:> Hi Jakob, > > I have been trying to learn how the CodeGen passes work and I am playing > around with the -debug-pass option. I tried implementing a bare > CallGraphSCCPass based Pass in the CodeGen which basically does nothing for > now. I mostly tried to replicate what RegAlloc passes do. I did this > instead of modifying the existing RegAlloc passes to use CallGraphSCCPass > because that was becoming way too complicated for simple experiments I was > trying when I tried to do that. I am attaching the diffs of what I actually > tried to do for reference here. It is not really well documented and there > is a lot of copy/paste code there, but well, this is not really the final > code to be submitted or anything, just to play around, so I have not really > put efforts into comments etc. yet. > > > So when I build LLVM and try to run the pass with the following command: > $ llc --debug -cgregalloc=cg <$HOME/cpptry/manyfuncs.bc > > I get the following error. > > Args: llc --debug -cgregalloc=cg > Subtarget features: SSELevel 6, 3DNowLevel 0, 64bit 1 > Pass ID not registered > UNREACHABLE executed at /media/python/workspace/llvm/ > lib/CodeGen/Passes.cpp:324! > 0 llc 0x0000000001453dfe > 1 llc 0x00000000014542fa > 2 libpthread.so.0 0x00007f020b750cb0 > 3 libc.so.6 0x00007f020a99f425 gsignal + 53 > 4 libc.so.6 0x00007f020a9a2b8b abort + 379 > 5 llc 0x000000000143b1a6 > 6 llc 0x0000000000f3cb02 llvm::TargetPassConfig::addPass(void > const*) + 146 > 7 llc 0x0000000000f3ddef > llvm::TargetPassConfig::addCGRegAlloc(llvm::CallGraphSCCPass*) + 47 > 8 llc 0x0000000000f3d7df > llvm::TargetPassConfig::addMachinePasses() + 719 > 9 llc 0x0000000000e5a3af > 10 llc 0x0000000000e5994c > llvm::LLVMTargetMachine::addPassesToEmitFile(llvm::PassManagerBase&, > llvm::formatted_raw_ostream&, llvm::TargetMachine::CodeGenFileType, bool, > void const*, void const*) + 92 > 11 llc 0x00000000005f6002 main + 4946 > 12 libc.so.6 0x00007f020a98a76d __libc_start_main + 237 > 13 llc 0x00000000005f4bd1 > Stack dump: > 0. Program arguments: llc --debug -cgregalloc=cg > Aborted (core dumped) > > I am not really sure, why it says "Pass ID is not registered". I did quite > a lot of internet searching about it and whatever I try to look for I end > up on the exact LLVM line of code which prints this error line. So, I am > not sure what is going on. Is this because CallGraphSCCPass does not > register anything with the MachineFunctionPass-es? Or is this because > CallGraphSCCPass does not do some magic which is specific to CodeGen > passes? Can you please help me with this a bit? May be some pointers? > > > On Fri, Nov 2, 2012 at 2:03 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk>wrote: > >> >> On Oct 31, 2012, at 1:41 PM, Madhusudan C.S <madhusudancs at gmail.com> >> wrote: >> >> > I have spent last 4 weeks trying to figure out how to implement >> > Interprocedural Register Allocation. I must admit that I was really >> > overwhelmed with LLVM's codebase while trying to figure this out :) >> > There is so much to know! I think I have reached a point where I >> > have some sort of basic understanding of what needs to be done, >> > but I need some help from here on. So here is the summary of >> > what I know and for what I need more help. >> > >> > I see that lib/CodeGen/Passes.cpp adds PrologEpilogInserter (PEI >> > henceforth) pass after the RegAlloc pass. Do I understand correctly >> > that LLVM first performs a given pass on all the functions before >> > moving to the next pass? >> >> No, it's the other way around. >> >> You may want to read up on the pass manager and play with the -debug-pass >> option. >> >> /jakob >> >> > > > -- > Thanks and regards, > Madhusudan.C.S > > >-- Thanks and regards, Madhusudan.C.S -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121221/332428ec/attachment.html>