This emits S_CONSTANT records for global variables.
Currently this emits records for the global variables already being tracked in the
LLVM IR metadata, which are just constant global variables; we'll also want S_CONSTANTs
for static data members and enums.
Related to https://bugs.llvm.org/show_bug.cgi?id=41615
I think we might want to try to generalize this CVGlobalVariable type to handle constants by leaving the GV member null. Then we won't need a second vector. I think there may be some cases where we should emit the S_CONSTANT inside a function, something like:
int f(int x) { static const int CppIsAwesome = 42; // Is this an S_CONSTANT or an S_LOCAL? enum { CppIsAwesome = 42 }; // If its written this way, is this an S_CONSTANT? Where does it come out? return x + CppIsAwesome; }I guess eventually CVGlobalVariable may become a bad fit for enumerator values, but I could see generalizing it.
To carry the DIExpression which contains the constant value in CVGlobalVariable, you can use a PointerIntUnion to store either a DIExpression* for constants or GlobalVariable* for true globals. Then the global emission code can check which is active and emit S_CONSTANT or S_[GL]DATA32