[cfe-dev] PassManagerBuilder vs. TargetPassConfig
Yaron Keren
yaron.keren at gmail.com
Wed Sep 10 07:24:24 PDT 2014
Hi,
Turns out that EmitAssemblyHelper adds the TargetPassConfig passes *on
top* of other passes coming from PMBuilder.
That seems to lead to strange results. For instance,
TM->addAnalysisPasses(PM) is called twice for the same PassManager, first
from EmitAssemblyHelper::AddEmitPasses() then from addPassesToGenerateCode.
SROA is done twice, once
from PassManagerBuilder::populateModulePassManager() and then
from PassManagerBuilder::populateFunctionPassManager().
There are other duplications between the three pass collections which may
be slowing down optimization.
OTOH MCJIT does not use the second set of optimizations coming form
PMBuilder and not TargetPassConfig.
Below is the full structure output from clang++ -mllvm
-debug-pass=Structure -O2
The passes following ###### are coming from TargetPassConfig and identical
to what you get for MCJIT.
Does this pass structure makes sense?
Yaron
Pass Arguments: -datalayout -notti -basictti -x86tti -targetlibinfo -no-aa
-tbaa -scoped-noalias -basicaa -verify -add-discriminators -simplifycfg
-domtree -sroa -early-cse -lower-expect
Data Layout
No target information
Target independent code generator's TTI
X86 Target Transform Info
Target Library Information
No Alias Analysis (always returns 'may' alias)
Type-Based Alias Analysis
Scoped NoAlias Alias Analysis
Basic Alias Analysis (stateless AA impl)
FunctionPass Manager
Module Verifier
Add DWARF path discriminators
Simplify the CFG
Dominator Tree Construction
SROA
Early CSE
Lower 'expect' Intrinsics
Pass Arguments: -datalayout -notti -basictti -x86tti -targetlibinfo -no-aa
-tbaa -scoped-noalias -basicaa -verify-di -ipsccp -globalopt -deadargelim
-instcombine -simplifycfg -basiccg -prune-eh -inline-cost -inline
-functionattrs -sroa -domtree -early-cse -lazy-value-info -jump-threading
-correlated-propagation -simplifycfg -instcombine -tailcallelim
-simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa
-loop-rotate -licm -loop-unswitch -instcombine -scalar-evolution -lcssa
-indvars -loop-idiom -loop-deletion -loop-unroll -memdep -mldst-motion
-domtree -memdep -gvn -memdep -memcpyopt -sccp -instcombine
-lazy-value-info -jump-threading -correlated-propagation -domtree -memdep
-dse -loops -scalar-evolution -slp-vectorizer -adce -simplifycfg
-instcombine -barrier -domtree -loops -loop-simplify -lcssa -branch-prob
-block-freq -scalar-evolution -loop-vectorize -instcombine -simplifycfg
-domtree -loops -loop-simplify -lcssa -scalar-evolution -loop-unroll
-strip-dead-prototypes -globaldce -constmerge
Data Layout
No target information
Target independent code generator's TTI
X86 Target Transform Info
Target Library Information
No Alias Analysis (always returns 'may' alias)
Type-Based Alias Analysis
Scoped NoAlias Alias Analysis
Basic Alias Analysis (stateless AA impl)
ModulePass Manager
Debug Info Verifier
Interprocedural Sparse Conditional Constant Propagation
Global Variable Optimizer
Dead Argument Elimination
FunctionPass Manager
Combine redundant instructions
Simplify the CFG
CallGraph Construction
Call Graph SCC Pass Manager
Remove unused exception handling info
Inline Cost Analysis
Function Integration/Inlining
Deduce function attributes
FunctionPass Manager
SROA
Dominator Tree Construction
Early CSE
Lazy Value Information Analysis
Jump Threading
Value Propagation
Simplify the CFG
Combine redundant instructions
Tail Call Elimination
Simplify the CFG
Reassociate expressions
Dominator Tree Construction
Natural Loop Information
Canonicalize natural loops
Loop-Closed SSA Form Pass
Loop Pass Manager
Rotate Loops
Loop Invariant Code Motion
Unswitch loops
Combine redundant instructions
Scalar Evolution Analysis
Loop-Closed SSA Form Pass
Loop Pass Manager
Induction Variable Simplification
Recognize loop idioms
Delete dead loops
Unroll loops
Memory Dependence Analysis
MergedLoadStoreMotion
Dominator Tree Construction
Memory Dependence Analysis
Global Value Numbering
Memory Dependence Analysis
MemCpy Optimization
Sparse Conditional Constant Propagation
Combine redundant instructions
Lazy Value Information Analysis
Jump Threading
Value Propagation
Dominator Tree Construction
Memory Dependence Analysis
Dead Store Elimination
Natural Loop Information
Scalar Evolution Analysis
SLP Vectorizer
Aggressive Dead Code Elimination
Simplify the CFG
Combine redundant instructions
A No-Op Barrier Pass
FunctionPass Manager
Dominator Tree Construction
Natural Loop Information
Canonicalize natural loops
Loop-Closed SSA Form Pass
Branch Probability Analysis
Block Frequency Analysis
Scalar Evolution Analysis
Loop Vectorization
Combine redundant instructions
Simplify the CFG
Dominator Tree Construction
Natural Loop Information
Canonicalize natural loops
Loop-Closed SSA Form Pass
Scalar Evolution Analysis
Loop Pass Manager
Unroll loops
Strip Unused Function Prototypes
Dead Global Elimination
Merge Duplicate Global Constants
########################
Pass Arguments: -datalayout -notti -basictti -x86tti -targetlibinfo
-jump-instr-table-info -targetpassconfig -no-aa -tbaa -scoped-noalias
-basicaa -collector-metadata -machinemoduleinfo -machine-branch-prob
-jump-instr-tables -verify -verify-di -domtree -loops -loop-simplify
-scalar-evolution -iv-users -loop-reduce -gc-lowering -unreachableblockelim
-consthoist -partially-inline-libcalls -codegenprepare -verify-di
-stack-protector -verify -domtree -loops -branch-prob -expand-isel-pseudos
-tailduplication -opt-phis -machinedomtree -slotindexes -stack-coloring
-localstackalloc -dead-mi-elimination -machinedomtree -machine-loops
-machine-trace-metrics -early-ifcvt -machinelicm -machine-cse -machine-sink
-peephole-opts -processimpdefs -unreachable-mbb-elimination -livevars
-phi-node-elimination -twoaddressinstruction -slotindexes -liveintervals
-simple-register-coalescing -misched -machine-block-freq -livedebugvars
-livestacks -virtregmap -liveregmatrix -edge-bundles -spill-code-placement
-virtregrewriter -stack-slot-coloring -machinelicm -edge-bundles
-prologepilog -machine-block-freq -branch-folder -tailduplication
-machine-cp -postrapseudos -machinedomtree -machine-loops -post-RA-sched
-gc-analysis -machine-block-freq -block-placement2 -stackmap-liveness
Data Layout
No target information
Target independent code generator's TTI
X86 Target Transform Info
Target Library Information
Jump-Instruction Table Info
Target Pass Configuration
No Alias Analysis (always returns 'may' alias)
Type-Based Alias Analysis
Scoped NoAlias Alias Analysis
Basic Alias Analysis (stateless AA impl)
Create Garbage Collector Module Metadata
Machine Module Information
Machine Branch Probability Analysis
ModulePass Manager
Jump-Instruction Tables
FunctionPass Manager
Unnamed pass: implement Pass::getPassName()
Module Verifier
Debug Info Verifier
FunctionPass Manager
Dominator Tree Construction
Natural Loop Information
Canonicalize natural loops
Scalar Evolution Analysis
Loop Pass Manager
Induction Variable Users
Loop Strength Reduction
Lower Garbage Collection Instructions
Remove unreachable blocks from the CFG
Constant Hoisting
Partially inline calls to library functions
CodeGen Prepare
Exception handling preparation
Debug Info Verifier
FunctionPass Manager
Insert stack protectors
Module Verifier
Machine Function Analysis
Dominator Tree Construction
Natural Loop Information
Branch Probability Analysis
X86 DAG->DAG Instruction Selection
X86 PIC Global Base Reg Initialization
Expand ISel Pseudo-instructions
Tail Duplication
Optimize machine instruction PHIs
MachineDominator Tree Construction
Slot index numbering
Merge disjoint stack slots
Local Stack Slot Allocation
Remove dead machine instructions
MachineDominator Tree Construction
Machine Natural Loop Construction
Machine Trace Metrics
Early If-Conversion
Machine Loop Invariant Code Motion
Machine Common Subexpression Elimination
Machine code sinking
Peephole Optimizations
Process Implicit Definitions
Remove unreachable machine basic blocks
Live Variable Analysis
Eliminate PHI nodes for register allocation
Two-Address instruction pass
Slot index numbering
Live Interval Analysis
Simple Register Coalescing
Machine Instruction Scheduler
Machine Block Frequency Analysis
Debug Variable Analysis
Live Stack Slot Analysis
Virtual Register Map
Live Register Matrix
Bundle Machine CFG Edges
Spill Code Placement Analysis
Greedy Register Allocator
Virtual Register Rewriter
Stack Slot Coloring
Machine Loop Invariant Code Motion
Bundle Machine CFG Edges
X86 FP Stackifier
Prologue/Epilogue Insertion & Frame Finalization
Machine Block Frequency Analysis
Control Flow Optimizer
Tail Duplication
Machine Copy Propagation Pass
Post-RA pseudo instruction expansion pass
MachineDominator Tree Construction
Machine Natural Loop Construction
Post RA top-down list latency scheduler
Analyze Machine Code For Garbage Collection
Machine Block Frequency Analysis
Branch Probability Basic Block Placement
Execution dependency fix
X86 vzeroupper inserter
X86 Atom pad short functions
X86 LEA Fixup
StackMap Liveness Analysis
X86 Assembly / Object Emitter
2014-09-10 6:07 GMT+03:00 Philip Reames <listmail at philipreames.com>:
> On 09/09/2014 07:14 AM, Yaron Keren wrote:
>
>> Hi,
>>
>> clang uses PassManagerBuilder via EmitAssemblyHelper::CreatePasses() to
>> create a collection of passes.
>>
>> llvm (MCJIT) uses TargetPassConfig via addPassesToGenerateCode for the
>> same purpose.
>>
>> There seems to some duplication and many differences between
>> PassManagerBuilder and TargetPassConfig, some aren't clear at all.
>>
>> Two small examples:
>>
>> 1) PassManagerBuilder adds createScalarReplAggregatesPass but
>> TargetPassConfig does not.
>>
>> 2) TargetPassConfig adds createLoopStrengthReducePass right after the
>> initial analysis but TargetPassConfig does not.
>>
>> I would expect that the optimization passes would be identical based on
>> optimization level only but they are quite different between
>> PassManagerBuilder and TargetPassConfig.
>>
> I'm not aware of any reason these two should differ. I suspect this is
> simply a case of copied code which has devolved over time.
>
> Philip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140910/0f293bfe/attachment.html>
More information about the cfe-dev
mailing list