1*9880d681SAndroid Build Coastguard WorkerBy Chris: 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard WorkerLLVM has been designed with two primary goals in mind. First we strive to 4*9880d681SAndroid Build Coastguard Workerenable the best possible division of labor between static and dynamic 5*9880d681SAndroid Build Coastguard Workercompilers, and second, we need a flexible and powerful interface 6*9880d681SAndroid Build Coastguard Workerbetween these two complementary stages of compilation. We feel that 7*9880d681SAndroid Build Coastguard Workerproviding a solution to these two goals will yield an excellent solution 8*9880d681SAndroid Build Coastguard Workerto the performance problem faced by modern architectures and programming 9*9880d681SAndroid Build Coastguard Workerlanguages. 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard WorkerA key insight into current compiler and runtime systems is that a 12*9880d681SAndroid Build Coastguard Workercompiler may fall in anywhere in a "continuum of compilation" to do its 13*9880d681SAndroid Build Coastguard Workerjob. On one side, scripting languages statically compile nothing and 14*9880d681SAndroid Build Coastguard Workerdynamically compile (or equivalently, interpret) everything. On the far 15*9880d681SAndroid Build Coastguard Workerother side, traditional static compilers process everything statically and 16*9880d681SAndroid Build Coastguard Workernothing dynamically. These approaches have typically been seen as a 17*9880d681SAndroid Build Coastguard Workertradeoff between performance and portability. On a deeper level, however, 18*9880d681SAndroid Build Coastguard Workerthere are two reasons that optimal system performance may be obtained by a 19*9880d681SAndroid Build Coastguard Workersystem somewhere in between these two extremes: Dynamic application 20*9880d681SAndroid Build Coastguard Workerbehavior and social constraints. 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard WorkerFrom a technical perspective, pure static compilation cannot ever give 23*9880d681SAndroid Build Coastguard Workeroptimal performance in all cases, because applications have varying dynamic 24*9880d681SAndroid Build Coastguard Workerbehavior that the static compiler cannot take into consideration. Even 25*9880d681SAndroid Build Coastguard Workercompilers that support profile guided optimization generate poor code in 26*9880d681SAndroid Build Coastguard Workerthe real world, because using such optimization tunes that application 27*9880d681SAndroid Build Coastguard Workerto one particular usage pattern, whereas real programs (as opposed to 28*9880d681SAndroid Build Coastguard Workerbenchmarks) often have several different usage patterns. 29*9880d681SAndroid Build Coastguard Worker 30*9880d681SAndroid Build Coastguard WorkerOn a social level, static compilation is a very shortsighted solution to 31*9880d681SAndroid Build Coastguard Workerthe performance problem. Instruction set architectures (ISAs) continuously 32*9880d681SAndroid Build Coastguard Workerevolve, and each implementation of an ISA (a processor) must choose a set 33*9880d681SAndroid Build Coastguard Workerof tradeoffs that make sense in the market context that it is designed for. 34*9880d681SAndroid Build Coastguard WorkerWith every new processor introduced, the vendor faces two fundamental 35*9880d681SAndroid Build Coastguard Workerproblems: First, there is a lag time between when a processor is introduced 36*9880d681SAndroid Build Coastguard Workerto when compilers generate quality code for the architecture. Secondly, 37*9880d681SAndroid Build Coastguard Workereven when compilers catch up to the new architecture there is often a large 38*9880d681SAndroid Build Coastguard Workerbody of legacy code that was compiled for previous generations and will 39*9880d681SAndroid Build Coastguard Workernot or can not be upgraded. Thus a large percentage of code running on a 40*9880d681SAndroid Build Coastguard Workerprocessor may be compiled quite sub-optimally for the current 41*9880d681SAndroid Build Coastguard Workercharacteristics of the dynamic execution environment. 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard WorkerFor these reasons, LLVM has been designed from the beginning as a long-term 44*9880d681SAndroid Build Coastguard Workersolution to these problems. Its design allows the large body of platform 45*9880d681SAndroid Build Coastguard Workerindependent, static, program optimizations currently in compilers to be 46*9880d681SAndroid Build Coastguard Workerreused unchanged in their current form. It also provides important static 47*9880d681SAndroid Build Coastguard Workertype information to enable powerful dynamic and link time optimizations 48*9880d681SAndroid Build Coastguard Workerto be performed quickly and efficiently. This combination enables an 49*9880d681SAndroid Build Coastguard Workerincrease in effective system performance for real world environments. 50