LLVM Link Time Optimization: Design and Implementation
文章推薦指數: 80 %
LLVM features powerful intermodular optimizations which can be used at link time. Link Time Optimization (LTO) is another name for intermodular optimization ...
Navigation
index
next|
previous|
LLVMHome |
Documentation»
UserGuides»
Documentation
GettingStarted/Tutorials
UserGuides
Reference
GettingInvolved
ContributingtoLLVM
SubmittingBugReports
MailingLists
IRC
MeetupsandSocialEvents
AdditionalLinks
FAQ
Glossary
Publications
GithubRepository
ThisPage
ShowSource
Quicksearch
LLVMLinkTimeOptimization:DesignandImplementation¶
Description
DesignPhilosophy
Exampleoflinktimeoptimization
AlternativeApproaches
Multi-phasecommunicationbetweenlibLTOandlinker
Phase1:ReadLLVMBitcodeFiles
Phase2:SymbolResolution
Phase3:OptimizeBitcodeFiles
Phase4:SymbolResolutionafteroptimization
libLTO
lto_module_t
lto_code_gen_t
Description¶
LLVMfeaturespowerfulintermodularoptimizationswhichcanbeusedatlink
time.LinkTimeOptimization(LTO)isanothernameforintermodular
optimizationwhenperformedduringthelinkstage.Thisdocumentdescribesthe
interfaceanddesignbetweentheLTOoptimizerandthelinker.
DesignPhilosophy¶
TheLLVMLinkTimeOptimizerprovidescompletetransparency,whiledoing
intermodularoptimization,inthecompilertoolchain.Itsmaingoalistolet
thedevelopertakeadvantageofintermodularoptimizationswithoutmakingany
significantchangestothedeveloper’smakefilesorbuildsystem.Thisis
achievedthroughtightintegrationwiththelinker.Inthismodel,thelinker
treatsLLVMbitcodefileslikenativeobjectfilesandallowsmixingand
matchingamongthem.ThelinkeruseslibLTO,asharedobject,tohandleLLVM
bitcodefiles.ThistightintegrationbetweenthelinkerandLLVMoptimizer
helpstodooptimizationsthatarenotpossibleinothermodels.Thelinker
inputallowstheoptimizertoavoidrelyingonconservativeescapeanalysis.
Exampleoflinktimeoptimization¶
ThefollowingexampleillustratestheadvantagesofLTO’sintegratedapproach
andcleaninterface.ThisexamplerequiresasystemlinkerwhichsupportsLTO
throughtheinterfacedescribedinthisdocument.Here,clangtransparently
invokessystemlinker.
Inputsourcefilea.ciscompiledintoLLVMbitcodeform.
Inputsourcefilemain.ciscompiledintonativeobjectcode.
---a.h---
externintfoo1(void);
externvoidfoo2(void);
externvoidfoo4(void);
---a.c---
#include"a.h"
staticsignedinti=0;
voidfoo2(void){
i=-1;
}
staticintfoo3(){
foo4();
return10;
}
intfoo1(void){
intdata=0;
if(i<0)
data=foo3();
data=data+42;
returndata;
}
---main.c---
#include
延伸文章資訊
- 1Enabling Link-Time Optimization - Keil
You must enable Link-Time Optimization (LTO) in both armclang and armlink . To enable LTO: At com...
- 2Is there a reason why not to use link-time optimization (LTO)?
Now, with link-time-optimization, the tiny function read from read.c is likely to be inlined wher...
- 3开启Link Time Optimization(LTO)后到底有什么优化? - 简书
LTO就是build settings中的一个编译选项,正如其名一样,Link Time Optimization,就是在链接的时候对程序进行了一些优化。我们具体来看看到底怎么 ...
- 4LLVM Link Time Optimization: Design and Implementation
LLVM features powerful intermodular optimizations which can be used at link time. Link Time Optim...
- 5Optimizing across modules with Link-Time Optimization - Keil
When Link-Time Optimization (LTO) is enabled, the compiler translates source code into an interme...