Hi,
I have trouble making my ProfileInfo-Analysis available in the backend, I have
changed llc so it loads the ProfileInfo if requested, the PassManger gives this
output:
> 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 Information
> Loop Pass Manager
> Canonicalize natural loops
> Scalar Evolution Analysis
> Loop Pass Manager
> Induction Variable Users
> Canonicalize natural loops
> Induction Variable Users
> Loop Strength Reduction
> Dominance Frontier Construction
> Exception handling preparation
> Lower Garbage Collection Instructions
> Remove unreachable blocks from the CFG
> Optimize for code generation
> Insert stack protectors
> Machine Function Analysis
> X86 DAG->DAG Instruction Selection
> X86 FP_REG_KILL inserter
...
Okay, so the ProfileInfoLoader is working, but when I examine the executions
more closely I see that the ProfileInfo generated by the ProfileInfoLoader is
immediately discarded, when the SelectionDAGISel kicks in the "No Profile
Info"-Implementation is used:
> 0x1c1a740 Executing Pass 'Profiling information loader' on
Module 'main.c-O0.ll.bc'...
> -*- 'Profiling information loader' is the last user of following
pass instances. Free these instances
> 0x1c1a740 Freeing Pass 'Profiling information loader' on Module
'main.c-O0.ll.bc'...
> 0x1c1a740 Executing Pass 'Function Pass Manager' on Module
'main.c-O0.ll.bc'...
> 0x1c301a0 Executing Pass 'Preliminary module verification' on
Function 'main'...
> 0x1c301a0 Executing Pass 'Dominator Tree Construction' on
Function 'main'...
> 0x1c301a0 Executing Pass 'Module Verifier' on Function
'main'...
> 0x1c1ae50 Required Analyses: Preliminary module verification,
Dominator Tree Construction
> -*- 'Module Verifier' is the last user of following pass
instances. Free these instances
> 0x1c301a0 Freeing Pass 'Module Verifier' on Function
'main'...
> 0x1c301a0 Freeing Pass 'Preliminary module verification' on
Function 'main'...
> 0x1c301a0 Executing Pass 'Natural Loop Information' on
Function 'main'...
> 0x1c33000 Required Analyses: Dominator Tree Construction
> 0x1c301a0 Executing Pass 'Loop Pass Manager' on Function
'main'...
> 0x1c33460 Required Analyses: Natural Loop Information
> 0x1c301a0 Executing Pass 'Scalar Evolution Analysis' on
Function 'main'...
> 0x1c33cb0 Required Analyses: Natural Loop Information
> 0x1c301a0 Executing Pass 'Loop Pass Manager' on Function
'main'...
> 0x1c359b0 Required Analyses: Natural Loop Information
> -*- 'Loop Pass Manager' is the last user of following pass
instances. Free these instances
> 0x1c301a0 Freeing Pass 'Scalar Evolution Analysis' on
Function 'main'...
> 0x1c301a0 Freeing Pass 'Natural Loop Information' on Function
'main'...
> 0x1c301a0 Executing Pass 'Dominance Frontier Construction' on
Function 'main'...
> 0x1c370b0 Required Analyses: Dominator Tree Construction
> 0x1c301a0 Executing Pass 'Exception handling preparation' on
Function 'main'...
> 0x1c36c70 Required Analyses: Dominator Tree Construction, Dominance
Frontier Construction
> 0x1c36c70 Preserved Analyses: Dominator Tree Construction, Dominance
Frontier Construction, Load profile information from llvmprof.out
> -*- 'Exception handling preparation' is the last user of
following pass instances. Free these instances
> 0x1c301a0 Freeing Pass 'Exception handling preparation' on
Function 'main'...
> 0x1c301a0 Freeing Pass 'Dominance Frontier Construction' on
Function 'main'...
> 0x1c301a0 Freeing Pass 'Dominator Tree Construction' on
Function 'main'...
> 0x1c301a0 Executing Pass 'Lower Garbage Collection
Instructions' on Function 'main'...
> 0x1c1cec0 Required Analyses: Create Garbage Collector Module
Metadata
> 0x1c1cec0 Preserved Analyses: Load profile information from
llvmprof.out
> -*- 'Lower Garbage Collection Instructions' is the last user of
following pass instances. Free these instances
> 0x1c301a0 Freeing Pass 'Lower Garbage Collection
Instructions' on Function 'main'...
> 0x1c301a0 Executing Pass 'Remove unreachable blocks from the
CFG' on Function 'main'...
> 0x1c36c00 Preserved Analyses: Load profile information from
llvmprof.out
> -*- 'Remove unreachable blocks from the CFG' is the last user of
following pass instances. Free these instances
> 0x1c301a0 Freeing Pass 'Remove unreachable blocks from the
CFG' on Function 'main'...
> 0x1c301a0 Executing Pass 'Optimize for code generation' on
Function 'main'...
> 0x1c38430 Preserved Analyses: Load profile information from
llvmprof.out
> -*- 'Optimize for code generation' is the last user of following
pass instances. Free these instances
> 0x1c301a0 Freeing Pass 'Optimize for code generation' on
Function 'main'...
> 0x1c301a0 Executing Pass 'Insert stack protectors' on Function
'main'...
> 0x1c325a0 Preserved Analyses: Load profile information from
llvmprof.out
> -*- 'Insert stack protectors' is the last user of following pass
instances. Free these instances
> 0x1c301a0 Freeing Pass 'Insert stack protectors' on Function
'main'...
> 0x1c301a0 Executing Pass 'Machine Function Analysis' on
Function 'main'...
> 0x1c301a0 Executing Pass 'X86 DAG->DAG Instruction
Selection' on Function 'main'...
> 0x1c390d0 Required Analyses: No Alias Analysis (always returns
'may' alias), Create Garbage Collector Module Metadata, DWARF
Information Writer, Load profile information from llvmprof.out, Machine Function
Analysis
...
I was under the impression that it is possible to use the results form an
Module-wide analysis in the following FunctionPasses, but in this case this is
not working.
Also, I have modified all passes that run between the ProfileInfoLoader and the
SelectionDAGISel to preserve the ProfileInfo, each pass reports this properly.
What really puzzles me is that the SelectionDAGISel reports the
ProfileInfoLoader as required analysis (last line), so why is the PassManager
assuming that the ProfileInfoLoader analysis is not used anymore?
I have tried to make the ProfileInfoLoader the default implementation (instead
of "No ProfileInfo") but this gives an assertion while creating the
passes:
> llc:.../include/llvm/PassSupport.h:111: llvm::Pass*
llvm::PassInfo::createPass() const: Assertion `NormalCtor &&
"Cannot call createPass on PassInfo without default ctor!"'
failed.
Can someone enlighten me please?
Andi