https://blog.csdn.net/qq_23599965/article/details/88344459
https://github.com/zy445566/llvm-guide-zh
万花筒:用LLVM实现语言(备注:万花筒(Kaleidoscope)是LLVM实现的语言名称)
在LLVM中构建JIT
-aa-eval
: Exhaustive Alias Analysis Precision Evaluator-basicaa
: Basic Alias Analysis (stateless AA impl)-basiccg
: Basic CallGraph Construction-count-aa
: Count Alias Analysis Query Responses-da
: Dependence Analysis-debug-aa
: AA use debugger-domfrontier
: Dominance Frontier Construction-domtree
: Dominator Tree Construction-dot-callgraph
: Print Call Graph to “dot” file-dot-cfg
: Print CFG of function to “dot” file-dot-cfg-only
: Print CFG of function to “dot” file (with no function bodies)-dot-dom
: Print dominance tree of function to “dot” file-dot-dom-only
: Print dominance tree of function to “dot” file (with no function bodies)-dot-postdom
: Print postdominance tree of function to “dot” file-dot-postdom-only
: Print postdominance tree of function to “dot” file (with no function bodies)-globalsmodref-aa
: Simple mod/ref analysis for globals-instcount
: Counts the various types of Instruction
s-intervals
: Interval Partition Construction-iv-users
: Induction Variable Users-lazy-value-info
: Lazy Value Information Analysis-libcall-aa
: LibCall Alias Analysis-lint
: Statically lint-checks LLVM IR-loops
: Natural Loop Information-memdep
: Memory Dependence Analysis-module-debuginfo
: Decodes module-level debug info-postdomfrontier
: Post-Dominance Frontier Construction-postdomtree
: Post-Dominator Tree Construction-print-alias-sets
: Alias Set Printer-print-callgraph
: Print a call graph-print-callgraph-sccs
: Print SCCs of the Call Graph-print-cfg-sccs
: Print SCCs of each function CFG-print-dom-info
: Dominator Info Printer-print-externalfnconstants
: Print external fn callsites passed constants-print-function
: Print function to stderr-print-module
: Print module to stderr-print-used-types
: Find Used Types-regions
: Detect single entry single exit regions-scalar-evolution
: Scalar Evolution Analysis-scev-aa
: ScalarEvolution-based Alias Analysis-stack-safety
: Stack Safety Analysis-targetdata
: Target Data Layout-adce
: Aggressive Dead Code Elimination-always-inline
: Inliner for always_inline
functions-argpromotion
: Promote ‘by reference’ arguments to scalars-bb-vectorize
: Basic-Block Vectorization-block-placement
: Profile Guided Basic Block Placement-break-crit-edges
: Break critical edges in CFG-codegenprepare
: Optimize for code generation-constmerge
: Merge Duplicate Global Constants-constprop
: Simple constant propagation-dce
: Dead Code Elimination-deadargelim
: Dead Argument Elimination-deadtypeelim
: Dead Type Elimination-die
: Dead Instruction Elimination-dse
: Dead Store Elimination-functionattrs
: Deduce function attributes-globaldce
: Dead Global Elimination-globalopt
: Global Variable Optimizer-gvn
: Global Value Numbering-indvars
: Canonicalize Induction Variables-inline
: Function Integration/Inlining-instcombine
: Combine redundant instructions-aggressive-instcombine
: Combine expression patterns-internalize
: Internalize Global Symbols-ipconstprop
: Interprocedural constant propagation-ipsccp
: Interprocedural Sparse Conditional Constant Propagation-jump-threading
: Jump Threading-lcssa
: Loop-Closed SSA Form Pass-licm
: Loop Invariant Code Motion-loop-deletion
: Delete dead loops-loop-extract
: Extract loops into new functions-loop-extract-single
: Extract at most one loop into a new function-loop-reduce
: Loop Strength Reduction-loop-rotate
: Rotate Loops-loop-simplify
: Canonicalize natural loops-loop-unroll
: Unroll loops-loop-unroll-and-jam
: Unroll and Jam loops-loop-unswitch
: Unswitch loops-loweratomic
: Lower atomic intrinsics to non-atomic form-lowerinvoke
: Lower invokes to calls, for unwindless code generators-lowerswitch
: Lower SwitchInst
s to branches-mem2reg
: Promote Memory to Register-memcpyopt
: MemCpy Optimization-mergefunc
: Merge Functions-mergereturn
: Unify function exit nodes-partial-inliner
: Partial Inliner-prune-eh
: Remove unused exception handling info-reassociate
: Reassociate expressions-reg2mem
: Demote all values to stack slots-sroa
: Scalar Replacement of Aggregates-sccp
: Sparse Conditional Constant Propagation-simplifycfg
: Simplify the CFG-sink
: Code sinking-strip
: Strip all symbols from a module-strip-dead-debug-info
: Strip debug info for unused symbols-strip-dead-prototypes
: Strip Unused Function Prototypes-strip-debug-declare
: Strip all llvm.dbg.declare
intrinsics-strip-nondebug
: Strip all symbols, except dbg symbols, from a module-tailcallelim
: Tail Call Elimination-deadarghaX0r
: Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)-extract-blocks
: Extract Basic Blocks From Module (for bugpoint use)-instnamer
: Assign names to anonymous instructions-verify
: Module Verifier-view-cfg
: View CFG of function-view-cfg-only
: View CFG of function (with no function bodies)-view-dom
: View dominance tree of function-view-dom-only
: View dominance tree of function (with no function bodies)-view-postdom
: View postdominance tree of function-view-postdom-only
: View postdominance tree of function (with no function bodies)-transform-warning
: Report missed forced transformations其他的优化选项还有
adce
: Aggressive Dead Code Eliminationbb-vectorize
: Basic-Block Vectorizationconstprop
: Simple constant propagationdce
: Dead Code Eliminationdeadargelim
: Dead Argument Eliminationglobaldce
: Dead Global Eliminationglobalopt
: Global Variable Optimizergvn
: Global Value Numberinginline
: Function Integration/Inlininginstcombine
: Combine redundant instructionslicm
: Loop Invariant Code Motionloop
: unswitch: Unswithch Looploweratomic
: Lower atomic intrinsics to non-atomic formlowerinvoke
: Lower invokes to calls, for unwindless code generatorslowerswitch
: Lower SwithcInsts to branchesmem2reg
: Promote Memory to Registrymemcpyopt
: MemCpy Optimizationsimplifycfg
: Simplify the CFGsink
: Code sinkingtailcallelim
: Tail Call Elimination可以在源码目录 test/Transforms/
下找到测试代码。
作者:peteyuan
链接:https://www.jianshu.com/p/b0d8431cbab1
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
ADCE(Aggressive Dead Code Elimination).
https://dongaxis.github.io/2016/05/31/LLVM-optimization-ADCE/
迭代标记有哪些其他的指令使用了会被使用的指令
简单的描述一下算法:
3.4 -bb-vectorize:基本块向量化
此pass将基本块中的指令组合成向量指令。它遍历每个基本块,试图对兼容的指令进行配对,重复这个过程,直到没有为向量化选择额外的配对。当某对相容指令的输出被另一对相容指令用作输入时,这些对就是潜在向量化链的一部分。只有当指令对是长度超过某个阈值的链的一部分时,才会融合到向量指令中。此外,pass尝试为每对兼容指令找到可能的最佳链。这些启发式方法旨在防止向量化在不会提高结果代码性能的情况下发生。
---------------------
3.18 -gvn:全局值编号
此pass执行全局值编号,以消除全部和部分冗余指令。它还执行冗余负载消除。
3.28 -licm:循环不变的代码移动
此pass执行循环不变的代码移动,尝试从循环体中删除尽可能多的代码。它可以将代码提升到preheader块中,或者如果安全的话,将代码下沉到exit块中。此pass还促进循环中必须别名的内存位置驻留在寄存器中,从而提升和降低“不变”负载和存储。
此pass使用别名分析有两个目的:
如果这些条件为真,我们可以提升指针循环中的加载和存储,以使用临时alloca 'd变量。然后,我们使用mem2reg功能为变量构造适当的SSA表单。