Possible improvements include:
LLVM has support for debug information. If you want to generate debug information, have a look at Adding Debug Information.
LLVM generates DWARF code.
Start by emitting the locations of your nodes first, then go further with scopes and variables.
As you noticed at TC-5, you can’t have global variables.
LLVM has support for global variables, using the