Shuguang Feng
2009-Sep-09 16:46 UTC
[LLVMdev] [PATCH] & Question: Preserving ProfileInfo for backend.
Hi, Does the current LLVM backend support reading in profile information (without preserving across transformations)? An earlier poster http://groups.google.com/group/llvm-dev/browse_thread/thread/4bd65dbe84394bb7 noted that accessing execution counts in a MachineFunction pass (using the BasicBlock* corresponding to the respective MachineBasicBlock) returned 0 for all blocks. Running llc with --debug-pass=Structure I noticed that the NoProfileInfo pass was being executed. I tried adding a ProfileLoaderPass in the addPreRegAlloc function of the X86 target machine to load the profile information but receive the following runtime error when the pass manager attempts to add the ProfileLoader pass: llc: <path to llvm>/llvm/lib/VMCore/PassManager.cpp:1597: virtual void llvm::ModulePass::assignPassManager(llvm::PMStack&, llvm::PassManagerType): Assertion `!PMS.empty() && "Unable to find appropriate Pass Manager"' failed. I'm not very familiar with the inner workings of the pass manager framework. Is there a simple fix that can allow existing profile information to be loaded by backend passes? I realize that the profile data would not be completely accurate, but as a first order approximation it could be useful until the proper framework is implemented? Thanks!
Andreas Neustifter
2009-Sep-09 17:47 UTC
[LLVMdev] [PATCH] & Question: Preserving ProfileInfo for backend.
Hi, Shuguang Feng wrote:> Does the current LLVM backend support reading in profile information > (without preserving across transformations)? An earlier posterYes, it does.> http://groups.google.com/group/llvm-dev/browse_thread/thread/4bd65dbe84394bb7 > > noted that accessing execution counts in a MachineFunction pass (using > the BasicBlock* corresponding to the respective MachineBasicBlock) > returned 0 for all blocks. Running llc with I > noticed that the NoProfileInfo pass was being executed.Yes, llc currently does not support the loading of profiles, but I attach a patch that does that, can you try that please?> I tried > adding a ProfileLoaderPass in the addPreRegAlloc function of the X86 > target machine to load the profile information but receive the > following runtime error when the pass manager attempts to add the > ProfileLoader pass: > > llc: <path to llvm>/llvm/lib/VMCore/PassManager.cpp:1597: virtual void > llvm::ModulePass::assignPassManager(llvm::PMStack&, > llvm::PassManagerType): Assertion `!PMS.empty() && "Unable to find > appropriate Pass Manager"' failed. > > I'm not very familiar with the inner workings of the pass manager > framework. Is there a simple fix that can allow existing profile > information to be loaded by backend passes? I realize that the > profile data would not be completely accurate, but as a first order > approximation it could be useful until the proper framework is > implemented?Don't know about Passes in the backend, but this could be a problem of an FunctionPassManager trying to use a ModulePass. Andi -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-r81350.llc.profile.loader.patch Type: text/x-patch Size: 2198 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090909/12900261/attachment.bin>
Shuguang Feng
2009-Sep-09 22:15 UTC
[LLVMdev] [PATCH] & Question: Preserving ProfileInfo for backend.
Thanks for such a rapid response!> Don't know about Passes in the backend, but this could be a problem of > an FunctionPassManager trying to use a ModulePass.I manually applied the patch you provided for llc (I'm using the 2.5 release of LLVM not ToT) and it fixed my compilation error. When your patch replaced the FunctionPassManager used by llc with a PassManager the error went away. Unfortunately, I'm still seeing execution counts of -1 when I print them out in my MachineFunction pass. I access the profiling information at each MachineBasicBlock with the following code, where "bb" is a reference to the current MachineBasicBlock: PI->getExecutionCount(bb.getBasicBlock()) I believe I've integrated all the ProfileInfo* files from ToT with my LLVM-2.5 installation properly. The profiling code (and llvm-prof) seems to be working since llvm-prof is generating/printing the appropriate execution frequencies. Is there an obvious mistake that I could be making? Since I've had to customize my current installation of llvm I would like to avoid updating to the latest revision if possible. Thanks!
Possibly Parallel Threads
- [LLVMdev] [PATCH] & Question: Preserving ProfileInfo for backend.
- [LLVMdev] Loading ProfileInfo in Backend. (Was: [PATCH] & Question: Preserving ProfileInfo for backend.)
- [LLVMdev] Loading ProfileInfo in Backend. (Was: [PATCH] & Question: Preserving ProfileInfo for backend.)
- [LLVMdev] [PATCH] & Question: Preserving ProfileInfo for backend.
- [LLVMdev] Loading ProfileInfo in Backend. (Was: [PATCH] & Question: Preserving ProfileInfo for backend.)