
老韩Linux系列
GCC帮助手册的第13小节,第5288~6288行,如下。
5288interprocedurallyaspartofindirectinlining(-findirect-inlining)andinterproceduralconstant5289propagation(-fipa-cp).Enabledatlevels-O2,-O3,-,,5293preferablyofsize1,cha,,aggressivedevirtualizati,-O3,-,whichimplicitly,AArch64andx86atlevels-O2,-O3,-++thevalueofanobjectisonlyaffectedbychangeswithinitslifetime:whentheconstructorbegins,5309theobjecthasanindeterminatevalue,andanychanges;ifyourcoderelieson5311thevalueoftheobjectstoragepersistingbeyondthelifetimeoftheobject,()butstilltreattheobjectasdeadafterthedestructor,youcanuse5314-flifetime-dse=1.Thedefaultbehaviorcanbeexplicitlyselectedwith-flifetime-dse=2.-flifetime-dse=05315=algorithm5320Us,whichspecifiesChow'sprioritycoloring,orCB,,butforthosetargetsthatdosupportit,5323=:5327/hitectures,andisenabledbydefaultwhencompiling5332withoptimizationforspeed(-O,-O2,).5333,,nmachineswithlargeregisterfiles(=32registers),5342,stackslot,,LRAtriesto5352rematerialize(recalculate),-O3,-,attempttoreorderinstructionstoexp,-O2,-O3,-Os,,attempttoreorderinstructionsuctionsbyallowingotherinstructionstobeissuedu,-,butrequestsanadditionalpa7,-O3,-basicblocks,whichisnormallyenabledwhenschedulingbefore5371registerallocation,ctions,whichisnormallyenabledwhenschedulingbefore5374registerallocation,nabled,zebypreventingregisterpressureincrease5379abovethenumber,,=n5388Definehowmanyinsns(ifany)canbemovedprematurelyfromthequeueofstalledinsnsintothereadylist5389duringthesecondschedulingpass.-fno-sched-stalled-insnsmeansthatnoinsnsaremovedprematurely,5390-fsched-stalled-insns=0lled-insns=1.5392-fsched-stalled-insns-dep5393-fsched-stalled-insns-dep=n5394Definehowmanyinsngroups(cycles)areexaminedforadepencyonastalledinsnth,andonlyif-fsched-stalled-insnsisused.-fno-sched-stalled-insns-depisequivalentto5397-fsched-stalled-insns-dep=0.-fsched-stalled-insns-depwithoutavalueisequivalentto5398-fsched-stalled-insns-dep=1.5399-fsched2-use-superblocks5400Whenschedulingafterregisterallocation,,,asnotallmachine5402descriptionsusedbyGCCm,,,,,,,,ringselectivescheduling,,likeELF,,thecompilercannotperforminterproceduralpropagation,inliningandother5447optimiza,forexample,torewritememoryallocationfunctionsbyadebuggingimplementation,ition5450happensforfunctionstheoverwritingfunctionwillhavepreciselythesamesemantics(andsideeffects).5451Similarlyifinterpositionhappensforvariables,(whereitisneverallowedforinterpositionto5453changesemantics)unctionthatneedit,ogueandepilogueseparately,,buthasnoeffeeclobberedbyfunctioncalls,byemittinge,,-O3,-(pushesandpops),-O3,-Os,howevertheoptionisdisabledifgeneratedcodewillbeinstrumentedfor5477profiling(-p,or-pg)orifcallee'sregisterusagecannotbeknownexactly(thishappensontargetsthat5478donotexposeprologuesandepiloguesinRTL).5479-,,(PRE)(PRE)(FRE),anchesofanif-then-elseiftheloadsarefromadjacentlocationsin5505thesame,(suchas"cold","noreturn",staticconstructorsordestructors)/(memory5529locationsthataremodifiedorreferenced),-,5538interproceduralconstantpropagationperformsfunctioncloningwh,itmay5540significantlyincreasecodesize(see--paramipa-cp-unit-growth=value).,,-'sICFoptimization,GCCICFworksondifferentlevels5553andthustheoptimizationsarenotsame-thereareequi=level5557ControlGCC''soptimizationusesafunction'sbodyorinformationextractedfromitsbodyto5559optimize/changeanotherfunction,,',a5562callerisimpactedwheninliningafunctionintoitscaller,cloningafunctionandchangingitscallerto5563callthisnewclone,orextractingafunction'spureness/constnessinformationtooptimizeitsdirector5564indirectcallers,,themoreIPAoptimizationsenabled,mputethelistofimpactedfunction,5567:5569inline-clone5570Onlyenableinliningandcloningoptimizations,whichincludesinlining,cloning,int,whenpatchingafunction,allits5572callersanditsclones'callersareimpacted,=inline-clonedisablesthefollowingoptimizationflags:-fwhole-program-fipa-pta5574-fipa-reference-fipa-ra-fipa-icf-fipa-icf-functions-fipa-icf-variables-fipa-bit-cp-fipa-vrp5575-fipa-pure-const-fipa-reference-addressable-fipa-stack-alignment-fipa-modr,whenpatchingastaticfunction,=inline-clonedisables,5580-flive-patching=inline-only-staticdisablesthefollowingadditionaloptimizationflags:-fipa-cp-clone5581-fipa-sra-fpartial-inlining-fipa-cp5582When-flive-patchingisspecifiedwithoutanyvalue,ion(-flto).5585-fisolate-erroneous-paths-dereference5586Detectpathsthattrererroneousorundefinedbehaviorduetoanullvaluebeingusedinawayforbidden5592bya"returns_nonnull"or"nonnull",aultat-O1andhigher,(CCP),,,-(DCE)ation(DCE)forcallstobuilt-infunctionsthatmayset"errno"ffects,++with-std=c++11ups(constant/copypropagation,redundancyelimination,range5632propagationandexpressionsimplification)(toreducejumpstojumps).(DSE),,GCChas5648tobeconfiguredwisl,ieddepSSArepresentation,attempttoreducecopyingbycoalescing5664versionsofdifferentuser-definedvariables,,,r5674loopoptimizations,likeparallelizationorvectorization,,theloop5675DOI=1,N5676A(I)=B(I)+C5677D(I)=E(I)*F5678ENDDO5679istransformedto5680DOI=1,N5681A(I)=B(I)+C5682ENDDO5683DOI=1,N5684D(I)=E(I)*,,theloop5691DOI=1,N5692A(I)=05693B(I)=A(I)+I5694ENDDO5695istransformedto5696DOI=1,N5697A(I)=05698ENDDO5699DOI=1,N5700B(I)=A(I)+I5701ENDDloopoptimizations,likevectorization,,theloop5707for(inti=0;iN;i++)5708for(intj=0;jN;j++)5709for(intk=0;kN;k++)5710c[i][j]=c[i][j]+a[i][k]*b[k][j];5711istransformedto5712for(inti=0;iN;i++)5713for(intk=0;kN;k++)5714for(intj=0;jN;j++)5715c[i][j]=c[i][j]+a[i][k]*b[k][j];5716(functioncalls,operationsthatexpandtonontrivialsequencesofinsns).With-funswitch-loopsit5724alsomovesoperandsofconditionsthatareinvariantoutoftheloop,sotherationsinloopsforwhngtheloopcanbedeterminedusingonlyitsinitialvalueandthenumberofloopiterations,replace5733usesofthefinalvaluebysuchacomputation,(strengthreduction,inductionvariablemergingandinduction5737variableelimination)=n5739Parallelizeloops,,,forloopsthatareCPU-intensive,,,5746,/singledeftemporar,but5758givestheexpa,5769-fprofile-use,,5772-fprofile-use,=,dynamic,blewhilewith5776thedynamicmodelaruntimecheckguardsthevectorizedcode-pathtoenableitonlyforiterationcounts5777thecostprohibitiveforexampleduetorequiredruntimechecks5779f,ifeachiterationofavectorizedloopwouldonlybeabletohandleexactlyfouriterationsof5782thescalarloop,thevery-cheapmodelwouldonlyallowvecto=model5786Alterthecostm,dynamic,,butinsteadof5791values,tionvariablesinlater,,thatisnot5802reliab,thecompilercreatesmultiplecopiesofsomelocalvariableswhenunrollingaloop,,-,-O3,-ation,,reusingcomputations(especiallymemoryloadsandstores)5815,generateinstructionstoprefet;resultnreturnvalueofformattedoutputfunctionssuchas"sprintf",5825"snprintf","vsprintf",and"vsnprintf"(butnot"printf"of"fprintf").ThistransformationallowsGCCto5826optimizeoreveneliminatebranchesbasedontheknownreturnvalueofthesefunctionscalledwith5827argumentsthatareeitherconstant,orwhosevaluesareknown,when-fprintf-return-valueisineffect,boththebranchandthe5829bodyofthe"if"statement(butnotthecallto"snprint")canbeoptimizedawaywhen"i"isa32-bito[9];5832if(snprintf(buf,"%08x",i)=sizeofbuf)58335834The-fprintf-return-valueoptieyareimplementedinthecompiler;sometargetsuseone,someusetheother,-fpeephole2enabledatlevels-O2,-O3,-idedbyprofilingfeedback5846(-fprofile-arcs)."__builtin_expect",thentheheuristicsareusedtoguessbranchprobabilitiesfortherestof5848thecontrolflowgraph,takingthe"__builtin_expect""__builtin_expect"canbecomplex,andinsomecases,itmaybeusefultodisablethe5850heuristicssothattheeffectsof"__builtin_expect"with5852"__builtin_expect_with_probability",-O2,-O3,-,-O2,-O3,-=,whichdoes5860notincreasecodesize(exceptsometimesduetosecondaryeffectslikealignment),orstc,the"software5861tracecache"algorithm,whichtriestoputalloftenexecutedcodetogether,min,-Os,andstcatlevels-O2,-icblocksinthecompiledfunction,inordertoreducenumberoftaken5866branches,part,ptionhandlingorunwindtables(on5869targetsusingsetjump/longjumportargetspecificscheme),forlinkoncesections,forfunctionswitha5870user-definedsect(toavoidlinkererrors),butmaybeenabled5872explicitly(ifusingaworkinglinker).5873Enabledforx86atlevels-O2,-O3,-"."formostfrequentlyexecutedfunctionsand"."'teffectiveunlessyoueitherprovideprofilefeedback(see-fprofile-arcsfordetails)or5880manuallyannotatefunctionswith"hot"or"cold",-O3,-(andC++),,anobjectofone5885typeisassumednevertoresideatthesameaddressasanobjectofadifferenttype,,an"unsignedint"canaliasan"int",butnota"void*"ora"double".:5889uniona_union{5890inti;5891doubled;5892};5893intf(){5894uniona_uniont;5895=3.0;5896;5897}5898Thepracticeofreadingfromadifferentunionmemberthantheonemostrecentlywrittento(called"type-5899punning"),type-punningisallowed,,,thiscodemightnot:5901intf(){5902uniona_uniont;5903int*ip;5904=3.0;5905ip=;5906return*ip;5907}5908Similarly,accessbytakingtheaddress,castingtheresultingpointeranddereferencingtheresulthas5909undefinedbehavior,evenifthecastusesauniontype,:5910intf(){5911doubled=3.0;5912return((uniona_union*)d)-i;5913}5914The-fstrict-aliasingoptionisenabledatlevels-O2,-O3,-=n5917-falign-functions=n:m5918-falign-functions=n:m:n25919-falign-functions=n:m:n2:m25920Alignthestartoffunctionstothenextpower-of-twogreaterthanorequalton,,:-falign-functions=32alignsfunctionstothenext32-byteboundary,-falign-functions=24aligns5925tothenext32-byteboundaryonlyifthiscanbedonebyskipping23bytesorless,-falign-functions=32:75926alignsto:m2valuesallowsyoutospecifyasecondaryalignment:-falign-functions=64:7:32:35928alignstothenext64-byteboundaryifthiscanbedonebyskipping6bytesorless,otherwisealignsto5929,;inthatcase,=1,,-,by-falign-functions,=n5942-falign-labels=n:m5943-falign-labels=n:m:n25944-falign-labels=n:m:n2:ion.-fno-align-labelsand5947-falign-labels=1nthisvalue,,useamachine-depentdefaultwhichisverylikelytobe1,,-=n5955-falign-loops=n:m5956-falign-loops=n:m:n25957-falign-loops=n:m:n2:,,ion.-fno-align-loopsand5962-falign-loops=1,,-=n5968-falign-jumps=n:m5969-falign-jumps=n:m:n25970-falign-jumps=n:m:n2:m25971Alignbranchtargetstoapower-of-twoboundary,,,ion.-fno-align-jumpsand5975-falign-jumps=1,,-++zationsthatmayintroducenewdataracesonstores,withoutproviludehoistingorif-conversionsthatmay5987c,-funit-at-a-timehasnoeffect,while-fno-unit-a,variables,and"asm",,,,butalsostrengthens6005severalotheroptimizationpasses,suchasCSE,,6006however,makedebuggingimpossible,sincevariablesnolongerstayina"homeregister".6007"main"andthosemergedbyattribute"externally_visible"becomestatic6011functionsand[=n]6015,itgeneratesGIMPLE(one6016ofGCC'sinternalrepresentations),allthefunctionbodiesarereadfromtheseELFsection,-fltoandoptimizatio:6022,mergesthetwofiles6027intoasingleinternalimage,,thiscausesalltheinterproceduralanalysesandopti,forexample,(simpler)waytoenablelink-timeoptimizationis:6032,mergesthemtogetherintoasingl037,,thelinkerplugin(see-fuse-linker-plugin)6042pas,-fwhole-programshouldbeusedtoallowthecompilertomaketheseassumptions,,thegeneratedobjectfileislargerthana6046regularobjectfilebecauseitcontainsGIMPLEbytecodesandtheusualfinalcode(see-ffat-lto-objects).6047ThismeansthatobjectfileswithLTOinformationcanbelinkedasnormalobjectfiles;if-fno-ltois6048passedtothelinker,asterbutyoucannotperformaregular,,GCConlya,youcanmixandmatcho,optionsspecifiedatlinktimeoverridethosespecifiedatcompiletime,althoughinsomecases6055GCCattemptst,thenGCCuseloptiononlyatlinktimeandnotatcompiletime,,compiling6059withoutoptimizationsuppressescompilerpassesth,someearlyoptimibytecodes,,thefollowingoptionsandtheirsettingsaretakenfromthefirstobject6064filethatexplicitlyspecifiesthem:-fcommon,-fexceptions,-fnon-call-exceptions,-,-fpic,-fpieand-fPIEarecombinedbasedonthefollowingscheme:6067B-fPIC+B-fpic=B-fpic6068B-fPIC+B-fno-pic=B-fno-pic6069B-fpic/-fPIC+(nooption)=(nooption)6070B-fPIC+B-fPIE=B-fPIE6071B-fpic+B-fPIE=B-fpie6072B-fPIC/-fpic+B-fpie=B-fpie6073CertainABI-changingflagsarerequiredtomatchinallcompilationunits,andt-,-fno-strict-overflow,-fwrapv,-fno-trapvor-fno-strict-aliasingare6077passedthroughtoth,-fwrapvand-fno-trapvtakeprecedence;andforexample-ffp-contract=offtakes6079precedenceover-ffp-contract=othelinkstageandthed6083ordkesuretoeithercompilesuch6085translationunitswith-fno-l
版权声明:文章来源网络聚合,如有问题请联系删除。





