# Understanding LLVM IR and Its Role in Compilation

DevFeed: [Understanding LLVM IR and Its Role in Compilation](<https://devfeed.tech/articles/ir-is-better-than-assembly-38927.md>)

Original publisher: [Read original article](<https://idea.popcount.org/2013-07-24-ir-is-better-than-assembly>)

Author: Marek

Published: 2013-07-23T22:00:00Z

Content type: tutorial

Language: en

Sources: [Marek Majkowski](<https://devfeed.tech/sources/marek-majkowski.md>)

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [Code](<https://devfeed.tech/topics/code.md>), [Parsing](<https://devfeed.tech/topics/parsing.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [compilation](<https://devfeed.tech/tags/compilation.md>), [ir](<https://devfeed.tech/tags/ir.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [toolchain](<https://devfeed.tech/tags/toolchain.md>)

## AI overview

This tutorial explains LLVM's three-stage compilation pipeline: a frontend produces intermediate representation (IR), an optimizer transforms it, and a backend generates machine code for a specific CPU. It also introduces LLVM IR's typed design and demonstrates compiling C to IR, optimizing it, and producing machine code.

## Source excerpt

IR is better than assembly In the LLVM the compilation takes three stages (image from the AOSA book): The stages are: - The frontend, parsing original language and spiting out LLVM Intermediate Representation (IR) code1. - The optimiser, mangling one IR into optimised equivalent IR. This stage does all the usual optimisations like constant propagation, dead code removal and so on. - The backend, taking IR and producing machine code optimised for a specific CPU. The crucial part is IR.