LinkTimeOptimization - GCC Wiki
文章推薦指數: 80 %
Link Time Optimization (LTO) gives GCC the capability of dumping its internal representation (GIMPLE) to disk, so that all the different compilation units ...
GCCWiki
Search:
Login
Self
LinkTimeOptimization
HomePageRecentChangesFindPageHelpContentsLinkTimeOptimization
ImmutablePageCommentsInfoAttachments
MoreActions:
RawText
PrintView
RenderasDocbook
DeleteCache
------------------------
CheckSpelling
LikePages
LocalSiteMap
------------------------
RenamePage
DeletePage
------------------------
SubscribeUser
------------------------
RemoveSpam
Reverttothisrevision
PackagePages
------------------------
Load
Save
SlideShow
Lastupdated:03-Oct-2009Contents
Status
Background
Requirements
Design
UsingLTO
Buildingthebranch
UsingLTO
Issueslefttoaddress(TODOlist)
Status
Thebranchhasbeenmergedtotrunkandisnowclosed.Finalmergeannouncement:http://gcc.gnu.org/ml/gcc/2009-10/msg00060.html
Background
LinkTimeOptimization(LTO)givesGCCthecapabilityofdumpingitsinternalrepresentation(GIMPLE)todisk,sothatallthedifferentcompilationunitsthatmakeupasingleexecutablecanbeoptimizedasasinglemodule.Thisexpandsthescopeofinter-proceduraloptimizationstoencompassthewholeprogram(or,rather,everythingthatisvisibleatlinktime).Thispagecontainsinformationforthisproject,includingdesign,implementationplan,statusandTODOitems.Ifyouareinterestedincollaborating,pleaseseethelistofTODOitemsattheendofthispage.TheprojectisbeingimplementedintheltoSVNbranch.Togetthelatestversion:$ svn co svn://gcc.gnu.org/svn/gcc/branches/ltoTheusualrulesforcontributingtobranchesapplytothisbranch:Messagesandpatchestothelistsshouldhavetheirsubjectprefixedwith[lto].ChangeLogentriesshouldbewrittentoChangeLog.lto.
Requirements
ThefundamentalmechanismusedbythecompilertodelayoptimizationuntillinktimeistowritetheGIMPLErepresentationoftheprogramonspecialsectionsintheoutputfile.Fortheinitialimplementationonthebranch,ELFwaschosenasthecontainerformatforthesesections,butinGCC-4.6supporthasbeenaddedonthetrunkforPE-COFFandMach-O.InordertouseLTOthetargetmustsupportoneofthesebinaryformats.ForPE-COFFandMach-Oaminimalbinaryreader/writerisimplementedinGCCitself.ForELF,weareusinglibelfv0.8.12,butanyrelativelyrecentlibelfimplementationshouldwork.NotethatELFisonlyrequiredasthecontainerformatforGIMPLE,thisdoesnotmeanthatELFmustbeusedasthefinalexecutableformat.Despitethe"linktime"name,LTOdoesnotneedtouseanyspeciallinkerfeatures.ThebasicmechanismneededisthedetectionofGIMPLEsectionsinsideobjectfiles.Thisiscurrentlyimplementedincollect2.Therefore,LTOwillworkonanylinkeralreadysupportedbyGCC.Asanaddedfeature,LTOwilltakeadvantageofthepluginfeatureingold.Thisallowsthecompilertopickupobjectfilesthatmayhavebeenstoredinlibraryarchives.Tousethisfeature,youmustbeusinggoldasthelinkerandenabletheuseofthepluginbycompilingwithgcc -fuse-linker-plugin.Thiswillshifttheresponsibilityofdrivingthefinalstagesofcompilationfromcollect2togoldviathelinkerplugin.
Design
Thefollowingaresomeofthedesigndocumentsanddiscussionsforthebasicfunctionalityandcleanups:InitialdesignLTOdesign.LTODriverStreamerInternalrepresentationchangesDesigndiscussion.ScalableLTOBoFatGCCSummit2007.ScalableWholeProgramoptimizer(WHOPR)WHOPRdesign.Designdiscussion.Designproposalforthewhoprdriverandlinkerplugin.DesignproposalforWPA.WHOPRBoFatGCCSummit2008.DesignproposalfordebugsupportforLTOandsubsequentdiscussion.Cleanupplanforlink-timeanddynamicoptimization
UsingLTO
Buildingthebranch
Tobuildthebranch,makesurethatyouhavelibelfv0.8.12installed.$svncosvn://gcc.gnu.org/svn/gcc/branches/lto
$mkdirbld&&cdbld
$../lto/configure--enable-lto&&makeIfyouhavelibelfinstalledinanon-systemdirectory,youalsoneedtoadd--with-libelf=
延伸文章資訊
- 1Interprocedural optimization - Wikipedia
WPO and LTO
- 2LinkTimeOptimization - GCC Wiki
Link Time Optimization (LTO) gives GCC the capability of dumping its internal representation (GIM...
- 3Enabling Link-Time Optimization - Keil
You must enable Link-Time Optimization (LTO) in both armclang and armlink . To enable LTO: At com...
- 4Optimizing across modules with Link-Time Optimization - Arm ...
When Link-Time Optimization (LTO) is enabled, the compiler translates source code into an interme...
- 5What is Link Time Optimization (LTO) - Arm C/C++ Compiler ...
Link Time Optimization is a form of interprocedural optimization that is performed at the time of...