I originally did do it a similar way, but that was before many of the more modern LLVM Machine structures existed.
You can see how I eventually did it here:
http://llvm.org/svn/llvm-project/llvm/branches/AMDILBackend/lib/Target/AMDIL/AMDILModuleInfo.cpp
You don’t need to put the information in a global variable as you can store it in the MachineModuleInfo and then query/modify it where needed from the various locations.
Micah