[PATCH] D61926: Emit global variables as S_CONSTANT records for codeview debug info.

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 11:44:42 PDT 2019


rnk added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h:202
   // Array of non-COMDAT global variables.
   SmallVector<CVGlobalVariable, 1> GlobalVariables;
 
----------------
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`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61926/new/

https://reviews.llvm.org/D61926





More information about the llvm-commits mailing list