www.cnblogs.com/saintlas/p/…

LLVM is a framework system of architecture compilers, written in C++, used to optimize compile-time, link-time, run-time, and idle-time of programs written in any programming language. Keep it open to developers and compatible with existing scripts. The LLVM project was initiated in 2000 by Chris Lattner of the University of Illinois at Urbana-Champaign. Chris Lattner joined Apple Inc. in 2006. And committed to the application of LLVM in Apple development system. Apple is also a major funder of the LLVM program [quoted from Baidu Baike].

LLVM can be thought of either as a complete compiler architecture or as a compiler – and interpreter-related library for development.

**** When we understand LLVM, we can think of it as including a narrow LLVM and a broad LLVM. LLVM in its broad sense actually refers to the entire LLVM compiler architecture, including the front end, back end, optimizer, numerous library functions and many modules. LLVM in a narrow sense is a set of modules and libraries that focus on compiler back-end functionality (code generation, code optimization, JIT, and so on).

**** Next, a brief introduction to Clang.

Clang is a C/C++/Objective-C/Objective-C++ compiler written in C++, based on LLVM and published under the LLVM BSD license. So why develop Clang when you already have GCC? What are the advantages of Clang over GCC?

In fact, this is what Clang had in mind when designing and developing. Clang is a lightweight compiler that is highly modularized. It compiles quickly, consumes little memory, and is very convenient for secondary development.

Finally, let’s talk briefly about the relationship between LLVM and Clang. We’ll map them to several separate parts of a traditional compiler to make it easier to express them clearly and vividly.

In fact, if we look at this diagram, we can figure out exactly how they correspond. Clang actually corresponds to the front end of the compiler roughly, and mainly handles some machine-independent language-specific analysis operations. The optimizer part and the back end part of the compiler are actually the LLVM back end we talked about earlier (LLVM in a narrow sense); The overall Compiler architecture is the LLVM architecture.