[PATCH] D67563: Debug Info: Add support for named constants

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 14:40:22 PDT 2019


aprantl added a comment.

Before creating this patch I had considered 4 options:

1. Use DW_TAG_constant + DW_AT_location
  - Con: DWARF spec doesn't actually explicitly allow combining these two.
  - Con: There is no way to apply this to a DW_TAG_formal_parameter or DW_TAG_member
2. Use DW_TAG_variable + DW_AT_const_value
  - Big con: The DWARF spec doesn't allow DWARF exprs or loclists in DW_AT_const_value
3. Use DW_TAG_const_type or DW_TAG_immutable_type
  - We do use a DW_AT_type to point to a stub type that holds the mangled name, so this would work.
  - Con: Semantically odd since the constness is a property of the variable not of the type.
  - Pro: also works with DW_TAG_formal_parameter and member types.
4. We can invent our own DW_AT_LLVM_let_binding (true)
  - Con: Seems fairly Swift-specific (for example Rust has `let mut` which is like Swift's `var`).
  - Pro: also works with DW_TAG_formal_parameter and member types.
  - Pro: since most bindings are let, this would be more space-efficient.

Note that the parameter issue isn't quite such a bug deal since all parameters in Swift are constant unless they are specifically marked as inout, in which case the inout does become part of the type.
I'm starting to think we really should do either (3) or (4). Are there any concerns about approach (4), perhaps with a more generic name of DW_AT_LLVM_immutable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67563





More information about the llvm-commits mailing list