Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
LLVM IR is the intermediate representation at the center of the LLVM compiler infrastructure — the typed, low-level language that front ends such as Clang, Rust, and Swift generate and that LLVM then optimizes and lowers to machine code. It sits between source and assembly: more structured, portable, and strongly typed than assembly, but far lower level than any source language. Its defining features are static single assignment (SSA) form, in which each value is written exactly once; an unlimited supply of virtual registers named like `%1` or `%x`; and a type attached to every value and instruction. You do not usually hand-write it day to day, but reading and writing `.ll` files is one of the clearest ways to see how a compiler models your program and why particular optimizations are possible. It grew out of Chris Lattner's LLVM project at the University of Illinois in the early 2000s and now underlies a large share of modern toolchains. On XCODX your `.ll` is compiled and executed, with the LLVM version shown in the badge above the editor.
; LLVM IR: human-readable typed SSA, compiled and run in the sandbox
@.msg = private unnamed_addr constant [21 x i8] c"Hello from LLVM IR!\0A\00"
declare i32 @printf(ptr, ...)
define i32 @main() {
entry:
%r = call i32 (ptr, ...) @printf(ptr @.msg)
ret i32 0
}
LLVM IR is meant to be produced by compilers and consumed by LLVM's optimizer and backends, so its real users are compiler and tooling authors, plus anyone studying how high-level code becomes machine code. On XCODX you write a `.ll` file and it is compiled and run, which lets you experiment first-hand with SSA form, types, `getelementptr`, control flow, and calls into libc functions like `printf` without setting up a toolchain. It is not a general-purpose application language: there is no module or package system to import from, and every construct is intentionally explicit and verbose. Use it as a learning and inspection tool — hand-write small snippets, or paste the output of `clang -S -emit-llvm` and watch it run to connect source constructs to the IR they lower to.
No, although it looks similar. LLVM IR is target-independent, strongly typed, and uses an unlimited set of SSA virtual registers, whereas assembly is tied to one CPU's fixed real registers and instruction set. IR is a level above assembly that LLVM's backend later lowers into actual machine code for a specific target.
With Clang, run `clang -S -emit-llvm file.c` to emit a human-readable `.ll`; for Rust, `rustc --emit=llvm-ir` does the same. You can paste that output here to run or study it, within the roughly 50 KB source limit. Comparing the IR against your source is one of the best ways to learn how constructs lower.
Static single assignment means each virtual register is assigned exactly once, which makes data flow explicit and many optimizations straightforward. Names such as `%0`, `%1`, or `%x` are those virtual registers — an effectively unlimited pool, unlike a CPU's fixed set — and a new one holds the result of each instruction. Where a value must differ across incoming branches, a `phi` node selects it.
You can `declare` external libc functions such as `scanf`, `getchar`, or `fgets` and call them, and text typed into the Stdin Box will reach them, but hand-written IR rarely does I/O beyond a `printf`. There is no module or package system and no network, so the only functions available are the ones the runtime already provides — mainly libc — plus whatever you `define` in the file.
Yes. Modern LLVM uses opaque pointers written simply as `ptr`, and the textual IR format shifts between releases. The badge shows which LLVM version the sandbox runs, so match that; IR that parsed cleanly on an older version (for example with typed pointers like `i8*`) may need small edits here.
Mostly to learn and to inspect. Seeing types, SSA, and control flow written out teaches how compilers represent programs and why certain optimizations are legal, which is invaluable when writing a language front end or debugging code generation. For ordinary programming you would use a source language and let the compiler produce the IR for you.
main.llplain text — no highlighter ships for this language@getchar / @scanf@.str = private unnamed_addr constant [15 x i8] c"Hello, World!\0A\00"
declare i32 @printf(i8*, ...)
define i32 @main() {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0))
ret i32 0
}