Clang 최적화 수준
GCC에서 매뉴얼이 무엇인지 설명하고 -O3
, -Os
등 특정 최적화 인수의 관점에서로 번역 ( -funswitch-loops
, -fcompare-elim
, 등)
clang에 대한 동일한 정보를 찾고 있습니다.
내가 검토 한 온라인 및에 man clang
있는 전용 (일반 정보를 제공합니다 -O2
개를 최적화를 -O1
, -Os
속도 최적화, ...) 또한 스택 오버플로 여기에보고 발견 이 ,하지만 난 인용 된 소스 파일의 관련 아무것도 발견하지 않았습니다.
편집 : 답을 찾았지만 모든 최적화 패스와에서 선택한 패스를 문서화하는 사용자 설명서에 대한 링크가있는 사람이 있다면 여전히 관심 이 있습니다. 현재 난 그냥 발견 이 최적화 레벨을 뚫고 목록,하지만 아무것도.-Ox
이 관련 질문을 찾았습니다 .
요약하면 컴파일러 최적화 단계에 대해 알아 보려면 다음을 수행하십시오.
llvm-as < /dev/null | opt -O3 -disable-output -debug-pass=Arguments
Geoff Nixon 의 답변 (+1) 에서 지적했듯이 clang
추가로 몇 가지 더 높은 수준의 최적화를 실행하며 다음을 사용하여 검색 할 수 있습니다.
echo 'int;' | clang -xc -O3 - -o /dev/null -\#\#\#
으로 버전 6.0 출입증은 다음과 같습니다 :
기준선 (
-O0
) :opt
세트 : -tti -verify -ee-instrument -targetlibinfo -assumption-cache-tracker -profile-summary-info -forceattrs -basiccg -always-inline -barrierclang
추가 : -mdisable-fp-elim -mrelax-all
-O1
기반-O0
opt
추가:-targetlibinfo -tti -tbaa -scoped-noalias -assumption-cache-tracker -profile-summary-info -forceattrs -inferattrs -ipsccp-called-value-propagation -globalopt -domtree -mem2reg -deadargelim -basicaa -aa -loops -lazy -branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -simplifycfg -basiccg -globals-aa -prune-eh -always-inline -functionattrs -sroa -memoryssa -early-cse-memssa-예측 실행 -lazy-value-info -jump-threading -correlated-propagation -libcalls-shrinkwrap -branch-prob -block-freq -pgo-memop-opt -tailcallelim -reassociate -loop-simplify -lcssa-verification -lcssa -scalar-evolution -loop-rotate -licm -loop-unswitch -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -memcpyopt -sccp -demanded-bits -bdce -dse -postdomtree -adce -barrier -rpo-functionattrs -globaldce -float2int -loop-accesses -loop-distribute-loop-vectorize -loop-load-elim-가정에서 정렬 -strip-dead-prototypes -loop-sink -instsimplify -div-rem-pairs -verify -ee-instrument -early-cse -lower-expectclang
추가 : -momit-leaf-frame-pointerclang
상품 : -mdisable-fp-elim -mrelax-all
-O2
기반-O1
opt
추가 : -inline -mldst-motion -gvn -elim-avail-extern -slp-vectorizer -constmergeopt
상품 :-항상 인라인clang
추가 : -vectorize-loops -vectorize-slp
-O3
기반-O2
opt
추가 : -callsite-splitting -argpromotion
-Ofast
을 (를) 기반으로-O3
하고 유효clang
하지만 유효 하지는 않습니다.opt
clang
추가 : -fno-signed-zeros -freciprocal-math -ffp-contract = fast -menable-unsafe-fp-math -menable-no-nans -menable-no-infs -mreassociate -fno-trapping-math -ffast-math -ffinite-math-only
-Os
비슷하다-O2
opt
drops : -libcalls-shrinkwrap 및 -pgo-memopt-opt
-Oz
기반-Os
opt
방울 : -slp-vectorizer
With version 3.8 the passes are as follow:
baseline (
-O0
):opt
sets : -targetlibinfo -tti -verifyclang
adds : -mdisable-fp-elim -mrelax-all
-O1
is based on-O0
opt
adds: -globalopt -demanded-bits -branch-prob -inferattrs -ipsccp -dse -loop-simplify -scoped-noalias -barrier -adce -deadargelim -memdep -licm -globals-aa -rpo-functionattrs -basiccg -loop-idiom -forceattrs -mem2reg -simplifycfg -early-cse -instcombine -sccp -loop-unswitch -loop-vectorize -tailcallelim -functionattrs -loop-accesses -memcpyopt -loop-deletion -reassociate -strip-dead-prototypes -loops -basicaa -correlated-propagation -lcssa -domtree -always-inline -aa -block-freq -float2int -lower-expect -sroa -loop-unroll -alignment-from-assumptions -lazy-value-info -prune-eh -jump-threading -loop-rotate -indvars -bdce -scalar-evolution -tbaa -assumption-cache-trackerclang
adds : -momit-leaf-frame-pointerclang
drops : -mdisable-fp-elim -mrelax-all
-O2
is based on-O1
opt
adds: -elim-avail-extern -mldst-motion -slp-vectorizer -gvn -inline -globaldce -constmergeopt
drops: -always-inlineclang
adds: -vectorize-loops -vectorize-slp
-O3
is based on-O2
opt
adds: -argpromotion
-Ofast
is based on-O3
, valid inclang
but not inopt
clang
adds: -fno-signed-zeros -freciprocal-math -ffp-contract=fast -menable-unsafe-fp-math -menable-no-nans -menable-no-infs
-Os
is the same as-O2
-Oz
is based on-Os
opt
drops: -slp-vectorizerclang
drops: -vectorize-loops
With version 3.7 the passes are as follow (parsed output of the command above):
default (-O0): -targetlibinfo -verify -tti
-O1 is based on -O0
- adds: -sccp -loop-simplify -float2int -lazy-value-info -correlated-propagation -bdce -lcssa -deadargelim -loop-unroll -loop-vectorize -barrier -memcpyopt -loop-accesses -assumption-cache-tracker -reassociate -loop-deletion -branch-prob -jump-threading -domtree -dse -loop-rotate -ipsccp -instcombine -scoped-noalias -licm -prune-eh -loop-unswitch -alignment-from-assumptions -early-cse -inline-cost -simplifycfg -strip-dead-prototypes -tbaa -sroa -no-aa -adce -functionattrs -lower-expect -basiccg -loops -loop-idiom -tailcallelim -basicaa -indvars -globalopt -block-freq -scalar-evolution -memdep -always-inline
-O2 is based on -01
- adds: -elim-avail-extern -globaldce -inline -constmerge -mldst-motion -gvn -slp-vectorizer
- removes: -always-inline
-O3 is based on -O2
- adds: -argpromotion -verif
-Os is identical to -O2
-Oz is based on -Os
- removes: -slp-vectorizer
For version 3.6 the passes are as documented in GYUNGMIN KIM's post.
With version 3.5 the passes are as follow (parsed output of the command above):
default (-O0): -targetlibinfo -verify -verify-di
-O1 is based on -O0
- adds: -correlated-propagation -basiccg -simplifycfg -no-aa -jump-threading -sroa -loop-unswitch -ipsccp -instcombine -memdep -memcpyopt -barrier -block-freq -loop-simplify -loop-vectorize -inline-cost -branch-prob -early-cse -lazy-value-info -loop-rotate -strip-dead-prototypes -loop-deletion -tbaa -prune-eh -indvars -loop-unroll -reassociate -loops -sccp -always-inline -basicaa -dse -globalopt -tailcallelim -functionattrs -deadargelim -notti -scalar-evolution -lower-expect -licm -loop-idiom -adce -domtree -lcssa
-O2 is based on -01
- adds: -gvn -constmerge -globaldce -slp-vectorizer -mldst-motion -inline
- removes: -always-inline
-O3 is based on -O2
- adds: -argpromotion
-Os is identical to -O2
-Oz is based on -Os
- removes: -slp-vectorizer
With version 3.4 the passes are as follow (parsed output of the command above):
-O0: -targetlibinfo -preverify -domtree -verify
-O1 is based on -O0
- adds: -adce -always-inline -basicaa -basiccg -correlated-propagation -deadargelim -dse -early-cse -functionattrs -globalopt -indvars -inline-cost -instcombine -ipsccp -jump-threading -lazy-value-info -lcssa -licm -loop-deletion -loop-idiom -loop-rotate -loop-simplify -loop-unroll -loop-unswitch -loops -lower-expect -memcpyopt -memdep -no-aa -notti -prune-eh -reassociate -scalar-evolution -sccp -simplifycfg -sroa -strip-dead-prototypes -tailcallelim -tbaa
-O2 is based on -01
- adds: -barrier -constmerge -domtree -globaldce -gvn -inline -loop-vectorize -preverify -slp-vectorizer -targetlibinfo -verify
- removes: -always-inline
-O3 is based on -O2
- adds: -argpromotion
-Os is identical to -O2
-Oz is based on -O2
- removes: -barrier -loop-vectorize -slp-vectorizer
With version 3.2 the passes are as follow (parsed output of the command above):
-O0: -targetlibinfo -preverify -domtree -verify
-O1 is based on -O0
- adds: -sroa -early-cse -lower-expect -no-aa -tbaa -basicaa -globalopt -ipsccp -deadargelim -instcombine -simplifycfg -basiccg -prune-eh -always-inline -functionattrs -simplify-libcalls -lazy-value-info -jump-threading -correlated-propagation -tailcallelim -reassociate -loops -loop-simplify -lcssa -loop-rotate -licm -loop-unswitch -scalar-evolution -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -memcpyopt -sccp -dse -adce -strip-dead-prototypes
-O2 is based on -01
- adds: -inline -globaldce -constmerge
- removes: -always-inline
-O3 is based on -O2
- adds: -argpromotion
-Os is identical to -O2
-Oz is identical to -Os
Edit [march 2014] removed duplicates from lists.
Edit [april 2014] added documentation link + options for 3.4
Edit [september 2014] added options for 3.5
Edit [december 2015] added options for 3.7 and mention existing answer for 3.6
Edit [may 2016] added options for 3.8, for both opt and clang and mention existing answer for clang (versus opt)
Edit [nov 2018] add options for 6.0
@Antoine's answer (and the other question linked) accurately describe the LLVM optimizations that are enabled, but there are a few other Clang-specific options (i.e., those that affect lowering to the AST) that affected by the -O[0|1|2|3|fast]
flags.
You can take a look at these with:
echo 'int;' | clang -xc -O0 - -o /dev/null -\#\#\#
echo 'int;' | clang -xc -O1 - -o /dev/null -\#\#\#
echo 'int;' | clang -xc -O2 - -o /dev/null -\#\#\#
echo 'int;' | clang -xc -O3 - -o /dev/null -\#\#\#
echo 'int;' | clang -xc -Ofast - -o /dev/null -\#\#\#
For example, -O0
enables -mrelax-all
, -O1
enables -vectorize-loops
and -vectorize-slp
, and -Ofast
enables -menable-no-infs
, -menable-no-nans
, -menable-unsafe-fp-math
, -ffp-contract=fast
and -ffast-math
.
@Techogrebo:
Yes, no don't necessarily need the other LLVM tools. Try:
echo 'int;' | clang -xc - -o /dev/null -mllvm -print-all-options
Also, there are a lot more detailed options you can examine/modify with Clang alone... you just need to know how to get to them!
Try a few of:
clang -help
clang -cc1 -help
clang -cc1 -mllvm -help
clang -cc1 -mllvm -help-list-hidden
clang -cc1as -help
LLVM 3.6 -O1
Pass Arguments: -targetlibinfo -no-aa -tbaa -scoped-noalias -assumption-cache-tracker -basicaa -notti -verify-di -ipsccp -globalopt -deadargelim -domtree -instcombine -simplifycfg -basiccg -prune-eh -inline-cost -always-inline -functionattrs -sroa -domtree -early-cse -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -domtree -instcombine -tailcallelim -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom -loop-deletion -function_tti -loop-unroll -memdep -memcpyopt -sccp -domtree -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -adce -simplifycfg -domtree -instcombine -barrier -domtree -loops -loop-simplify -lcssa -branch-prob -block-freq -scalar-evolution -loop-vectorize -instcombine -simplifycfg -domtree -instcombine -loops -loop-simplify -lcssa -scalar-evolution -function_tti -loop-unroll -alignment-from-assumptions -strip-dead-prototypes -verify -verify-di
-O2 base on -O1
add : -inline -mldst-motion -domtree -memdep -gvn -memdep -scalar-evolution -slp-vectorizer -globaldce -constmerge
and removes: -always-inline
-O3 based on -O2
add: -argpromotion
참고URL : https://stackoverflow.com/questions/15548023/clang-optimization-levels
'program tip' 카테고리의 다른 글
주어진 위치에서 목록의 특정 요소를 얻는 방법은 무엇입니까? (0) | 2020.09.14 |
---|---|
읽기 라인 루프 동안 쉘 스크립트가 첫 번째 라인 이후에 중지 (0) | 2020.09.14 |
XPath를 사용하여 깊이의 자식 요소를 어떻게 선택합니까? (0) | 2020.09.14 |
Base64 데이터를 구문 분석하거나 유효성을 검사하는 RegEx (0) | 2020.09.14 |
Sqlite의 앱 내 데이터베이스 마이그레이션 모범 사례 (0) | 2020.09.14 |