Two-stage compilation for optimizing and deploying programs in general purpose languages
Abstract
We describe the approach for two-stage compilation of C/C++ programs using the LLVM compiler infrastructure that allows optimizing programs taking into account the user profile and his/her target machine features, as well as deploying programs in a cloud storage while transparently optimizing and checking for defects. The notable features of the approach are its applicability to programs written using general-purpose languages and utilizing the common compiler infrastructure on all optimization and deployment stages.
On the first stage (host machine) the build process is transparently captured and the LLVM bitcode files are generated with the proper support for archive/library files. LTO optimizations are also performed at this time, and the program dependencies and installation structure (e.g. libraries, installed resource or documentation files) are also captured. On the second stage (target machine) the final code generation and installation is performed with the transparent path translation. Either static code generation or dynamic JIT-based compilation is supported.
As mentioned, a cloud-based deployment strategy can also be used allowing for additional features like defect and vulnerability checking while the cloud store has access to the deployed programs in the LLVM bitcode form.
While optimizing LLVM toolchain for working on ARM embedded devices we have achieved the memory consumption reduction of up to 10% and 10-20% compile time decrease.References
1. A. Belevantsev, D. Zhurikhin, D. Melnik. Kompilyatsiya programm dlya sovremennykh arkhitektur. [Program compilation for modern architectures] Trudy ISP RАN [The Proceedings of ISP RAS], volume 16, p. 31-50, 2009. (In Russian)
2. Chris Lattner. LLVM: An Infrastructure for Multi-Stage Optimization.— Master’s thesis, Computer Science Dept., University of Illinois at Urbana-Champaign, Urbana, IL.
3. LLVM Compiler infrastructure, http://llvm.org/
4. Portable Native Client Introduction, http://www.chromium.org/nativeclient/pnacl/introduction-to-portable-native-client
5. A.I. Avetisyan, K.U. Dolgorukova; Sh.F. Kurmangaleev. Dinamicheskoe profilirovanie programmy dlya sistemy LLVM [Dynamic profile collection for LLVM]. Trudy ISP RАN [The Proceedings of ISP RAS], 2011, vol. 21, pp. 71-82 (in Russian)
6. The .NET infrastructure, http://msdn.microsoft.com/en-us/netframework/aa496123
7. The NGEN Compiler, http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx
8. Stanley B. Lippman. Pure C++: Hello, C++/CLI. MSDN Magazine, Visual Studio 2005 Guided Tour, 2006, http://msdn.microsoft.com/en-us/magazine/cc163681.aspx
9. A. Avetisyan, A. Belevantsev, A. Borodin, V. Nesov. Ispol'zovanie staticheskogo analiza dlya poiska uyazvimostej i kriticheskikh oshibok v iskhodnom kode programm. [Using static analysis for finding security vulnerabilities and critical errors in source code]. Trudy ISP RАN [The Proceedings of ISP RAS], 2011, vol. 21, pp. 23-38 (in Russian).
Review
For citations:
Avetisyan A. Two-stage compilation for optimizing and deploying programs in general purpose languages. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2012;22. (In Russ.)