Compilers

Which describes the basic structure of LLVM?

  1. AA C-only compiler that cannot be used for other languages
  2. BAn assembler and linker combination targeting only a specific CPU
  3. CFront and back ends combined around a common IR
Show answer and explanation

Answer: C. Front and back ends combined around a common IR

LLVM is a compiler infrastructure centered on a common intermediate representation, LLVM IR. Front ends for many languages, starting with Clang for C/C++, translate source into LLVM IR, which passes through shared optimization passes before back ends for many targets, including x86, Arm, RISC-V and GPUs, generate machine code. Supporting a new language or CPU requires building only one side. It is neither C-only nor tied to a specific CPU.

  • A. It has front ends for many languages and is not C-only.
  • B. It has back ends for many CPUs and is not tied to one.
  • C. Correct. Front and back ends combine around a common IR.
Practice this topic Back to topic

More Compilers questions

  1. When is the no-optimization setting of a compiler (such as -O0) commonly used?
  2. Which describes profile-guided optimization (PGO)?
  3. Which optimization does link-time optimization (LTO) make possible?
  4. In C, signed integer overflow is undefined behavior. Under this rule, which code might an optimizing compiler generate for the function above?
  5. Which program error can be detected at compile time?