[英]What are the alternative ways to customize LLVM opt pipeline?
There is no way from command line to safely disable a specific pass in the O1/O2/O3 opt pipeline. 从命令行无法安全地禁用O1 / O2 / O3 opt管道中的特定传递。 What are the alternate ways to customize or tailor the opt pipeline of LLVM passes? 自定义或定制LLVM通道的选择管道有哪些替代方法?
I am writing a pass to outline specific regions of code and I need to reduce the number of inputs & outputs to the outlined function. 我正在写通行证以概述代码的特定区域,我需要减少概述函数的输入和输出的数量。 In some cases, the opt tool raises some (invariant) GEP instructions (for example, from a loop body). 在某些情况下,opt工具会引发一些(不变的)GEP指令(例如,从循环体内)。 This happens with O1/O2/O3 flags. O1 / O2 / O3标志会发生这种情况。 I do not want this since it creates more number of inputs/outputs to my outlined function. 我不希望这样做,因为它为我概述的功能创建了更多的输入/输出。 I prefer to have the GEP done in the outlined function. 我更喜欢在概述的功能中完成GEP。
Pass Arguments: -targetlibinfo -tti -targetpassconfig -tbaa -scoped-noalias
-assumption-cache-tracker -profile-summary-info -forceattrs -inferattrs
-ipsccp -called-value-propagation -globalopt -domtree -mem2reg -deadargelim
-domtree -basicaa -aa -loops -lazy-branch-prob -lazy-block-freq
-opt-remark-emitter -instcombine -simplifycfg -basiccg -globals-aa -prune-eh
-always-inline -functionattrs -domtree -sroa -basicaa -aa -memoryssa -early-cse-memssa
-speculative-execution -basicaa -aa -lazy-value-info -jump-threading -correlated-propagation
-simplifycfg -domtree -basicaa -aa -loops -lazy-branch-prob -lazy-block-freq
-opt-remark-emitter -instcombine -libcalls-shrinkwrap -loops -branch-prob -block-freq
-lazy-branch-prob -lazy-block-freq -opt-remark-emitter -pgo-memop-opt -basicaa -aa
-loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -tailcallelim -simplifycfg
-reassociate -domtree -loops -loop-simplify -lcssa-verification -lcssa -basicaa -aa
-scalar-evolution -loop-rotate -licm -loop-unswitch -simplifycfg -domtree -basicaa -aa -loops
-lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -loop-simplify -lcssa-verification -lcssa -scalar-evolution -indvars
-loop-idiom -loop-deletion -loop-unroll -phi-values -memdep -memcpyopt -sccp -demanded-bits -bdce -basicaa -aa -lazy-branch-prob
-lazy-block-freq -opt-remark-emitter -instcombine -lazy-value-info -jump-threading -correlated-propagation -basicaa -aa -phi-values
-memdep -dse -loops -loop-simplify -lcssa-verification -lcssa -basicaa -aa -scalar-evolution -licm -postdomtree -adce -simplifycfg
-domtree -basicaa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -barrier -basiccg -rpo-functionattrs
-globalopt -globaldce -basiccg -globals-aa -float2int -domtree -loops -loop-simplify -lcssa-verification -lcssa -basicaa -aa -scalar-evolution
-loop-rotate -loop-accesses -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -loop-distribute -branch-prob -block-freq -scalar-evolution
-basicaa -aa -loop-accesses -demanded-bits -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -loop-vectorize -loop-simplify -scalar-evolution
-aa -loop-accesses -loop-load-elim -basicaa -aa -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -simplifycfg -domtree
-basicaa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -loop-simplify -lcssa-verification -lcssa
-scalar-evolution -loop-unroll -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -loop-simplify -lcssa-verification
-lcssa -scalar-evolution -licm -alignment-from-assumptions -strip-dead-prototypes -domtree -loops -branch-prob -block-freq -loop-simplify
-lcssa-verification -lcssa -basicaa -aa -scalar-evolution -branch-prob -block-freq -loop-sink -lazy-branch-prob -lazy-block-freq
-opt-remark-emitter -instsimplify -div-rem-pairs -simplifycfg -domtree -sroa -verify -print-module
I think what I need is 我认为我需要的是
Can I add only the required passes (subset of the O1 pipeline) as AddRequired in getAnalysisUsage() in my pass definition and make opt run my pass with O0 flag enabled? 我可以在通行证定义中仅将所需的通行证(O1管道的子集)添加为getAnalysisUsage()中的AddRequired,并使opt在启用O0标志的情况下运行我的通行证吗? Will this work? 这样行吗? I can try this out. 我可以尝试一下。
According to this thread from summer 2018, there is no general way to disable a specific pass from clang: 根据2018年夏季以来的这一主题,没有通用的方法可以禁用来自clang的特定通行证:
Some passes have supported options to disable them, eg -fno-vectorize and -fno-unroll-loops, but there is no general option. 某些过程支持禁用它们的选项,例如-fno-vectorize和-fno-unroll-loops,但是没有通用选项。 Since it's not useful in general to disable arbitrary options, some handywork is required. 由于禁用任意选项通常没有用,因此需要一些手动操作。
The original poster in the thread seemed to be working on a patch to enable this behavior, but as far as I can tell it never landed. 该线程中的原始发布者似乎正在开发补丁来启用此行为,但据我所知它从未降落。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.