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

Shuguang Feng shuguang.feng at gmail.com
Thu Sep 10 07:44:34 PDT 2009


> What does "llc -debug-pass=Structure" say? Is the ProfileLoaderPass
> really the last pass to touch the ProfileInfo before you are using it?

Below is the sequence of passes that I see.  Although the
NoProfileInfo pass is being run, it should be subsequently overridden
by ProfileInfoLoaderPass (LoaderPass) correct?

Target Data Layout
Create Garbage Collector Module Metadata
Basic Alias Analysis (default AA impl)
DWARF Information Writer
No Profile Information
Module Information
  ModulePass Manager
    Profiling information loader
    FunctionPass Manager
      Preliminary module verification
      Dominator Tree Construction
      Module Verifier
      Natural Loop Construction
      Canonicalize natural loops
      Scalar Evolution Analysis
      Loop Pass Manager
        Loop Strength Reduction
      Lower Garbage Collection Instructions
      Remove unreachable blocks from the CFG
      Optimize for code generation
      Insert stack protectors
      X86 DAG->DAG Instruction Selection
      X86 FP_REG_KILL inserter
      X86 Maximal Stack Alignment Calculator
      <MY PASS RUNS HERE>


> Also, does bb.getBasicBlock() for sure always returns a valid block
> refrerence?

Yes. I am printing bb and *bb.getBasicBlock() in order to compare the
contents of the IR in the BasicBlock and the target assembly in the
MachineBasicBlock.

> You are getting the PI by getAnalysis<ProfileInfo>() I presume? Is this
> really the instance created by ProfileLoaderPass?

Yes, I have "PI = &getAnalysis<ProfileInfo>()" in my code (modeled
after BasicBlockPlacement.cpp).  However, when I run gdb the value of
the Pass* pointer returned by createProfileLoaderPass() does not match
the value of PI (of type ProfileInfo*) that I see inside my
MachineFunctionPass.  The abbreviated output of gdb is found below:

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

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

So the address of the ProfileLoaderPass should be 0x8feeaf0 correct?
But I see the following inside my own pass:

Breakpoint 3, MyCodeGenPass::runOnMachineFunction (this=0x90be200,
MF=@0x90ca280) at <path to llvm>/lib/Target/X86/MyCodeGenPass.cpp:108
108	                   <random line of code after PI =
&getAnalysis<ProfileInfo>() executes>
(gdb) p PI
$3 = (class llvm::ProfileInfo *) 0x90be438


> (I guess for the last two questions its best to use gdb, are you
> familiar with it?)

I have a working knowledge :) but haven't used any bells and whistles.

Thanks for your help.



More information about the llvm-dev mailing list