Probably a stupid question, but is LLVM better at optimising its IR than C compilers are at optimising C? Asked another way, why not use C as an IR, if it's compatible with your language semantics?
LLVM is essentially what you get when you say "I want to use C as an IR", and then try and do it for a bit and say "hmm, okay I'd like to put some restrictions on this IR... and maybe some customization hooks... and maybe this feature..."
C is a really bad IR for a lot of reasons. it has incrediby opinionated semantics (e.g. the huge amount of UB and platform specific behavior). LLVM is a lot more verbose, but allows you to actually pick the semantics you want.
reply