| Not LLVM expert, but I don't agree with some of your arguments. > My side of the code generator had to recognize when a variable had already been defined and keep track of its pointer For human, it's natural to write code text that reference each variable by its name. However, for a compiler, it's really error prone (and inefficient) to reference a variable by its string name (for example, think about shadowing). The natural way to reference an entity is by its object pointer, which is what LLVM does. This is especially true considering LLVM is designed to perform various complex transformations. > There is a pass called mem2reg that will convert to SSA, but it needs you to allocate and store variables in memory (instead of in registers). The purpose of mem2reg is to make your job easier. It's weird to say that it "needs" you to allocate allocas for your variables: that's what it allows you to do (for your own convenience). If you prefer to generate PHI nodes directly, you can just do so. > LLVM IR has opinions about variable scope Not sure what you are referencing to. LLVM only has 'alloca', which knows nothing about "scope". It must be defined before being referenced -- but this is true for everything in SSA. |