[LLVMdev] Loading ProfileInfo in Backend. (Was: [PATCH] & Question: Preserving ProfileInfo for backend.)

Shuguang Feng shuguang.feng at gmail.com
Thu Sep 10 09:21:47 PDT 2009


> It *is* allowed to access ModulePass analysis information from an
> FunctionPass?

BasicBlockPlacement (a FunctionPass) also accesses the profile
information and I assumed it worked (but haven't independently
verified this).

> Can you try to manually override the PI value in the
> MyCodeGenPass::runOnMachineFunction() to the value seen in llc and then
> access the ProfileInfo?

Good suggestion.  Unfortunately the end result is that for some blocks
instead of seeing the sentinel value of "-1" I see other bogus
execution counts instead.  For example, llvm-prof prints out the
following as the most frequently executed basic block:

 ##      %% 	Frequency
  1. 4.80749% 18002906/3.74476e+08	inflate_stored() - bb20

but in my pass the frequency I see from PI->getExecutionCount
(bb.getBasicBlock()) for the exact same BasicBlock (bb20 from function
inflate_stored()) is 7.47821e-316.  I verified that PI is indeed
pointing to the same object created in llc.cpp with the following gdb
trace:

Breakpoint 1, main (argc=11, argv=0xbfffd394) at <path to llvm>/tools/
llc/llc.cpp:293
293	      Passes.add(tmp);
(gdb) p tmp
$1 = (class llvm::Pass *) 0x8feeaf0
(gdb) c
Continuing.

Breakpoint 2, MyCodeGenPass::runOnMachineFunction (this=0x90be200,
MF=@0x90ca280) at <path to llvm>/lib/Target/X86/MyCodeGenPass.cpp:100
100	      <random line of code after executing PI = (ProfileInfo*)
0x8feeaf0>
(gdb) p PI
$2 = (class llvm::ProfileInfo *) 0x8feeaf0
(gdb) clear
Deleted breakpoint 2
(gdb) c
Continuing.

I will go back through my files and make sure I didn't do anything
silly when I merged the latest ProfileInfo* code with my LLVM-2.5
codebase.



More information about the llvm-dev mailing list