The target independence of IR


Can anyone help me understand that LLVM IR has “target independence” ?

  1. When we talk about “target”, we mean something like Instruction Set Architecture ?

  2. The front-end may generate IR code such as x86_fp80, so the IR is actually not fully target-independent? It contains information about the target, and the front-end should also be aware of this?

Thank you!


Hi Hao,

You are right, the IR is not “target independent” in the strict sense.

There’s a fairly old post that explains this (amongst other things) in detail:

x86_fp80 is just one example of this.

It is kind-of-possible to restrict LLVM IR to be sort-of-target-independent (look up Portable Native Client and SPIR for details), but an arbitrary IR file generated by a front-end that had target X in mind is not guaranteed to work as you’d expect if you use backend Y.


You may want to read this discussion:

And look at how PNaCl declares its own target.

There are a few more references here: