Example: llvm/hello.ll adapted from: llvm.org/docs/LangRef.html#module-structure but without double newline.
To execute it as mentioned at github.com/dfellis/llvm-hello-world we can either use their crazy assembly interpreter, tested on Ubuntu 22.10:This seems to use
sudo apt install llvm-runtime
lli hello.llputs from the C standard library.Or we can Lower it to assembly of the local machine:which produces:and then we can assemble link and run with gcc:or with clang:
sudo apt install llvm
llc hello.llhello.sgcc -o hello.out hello.s -no-pie
./hello.outclang -o hello.out hello.s -no-pie
./hello.outhello.s uses the GNU GAS format, which clang is highly compatible with, so both should work in general.
Ciro Santilli