[clang] [llvm] [Dwarf] Support heterogeneous DW_{OP,AT}s needed for AMDGPU CFI (PR #153883)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 15 18:02:38 PDT 2025


================
@@ -120,6 +120,46 @@ inline bool isConstantAddressSpace(unsigned AS) {
     return false;
   }
 }
+
+namespace DWARFAS {
+enum : unsigned {
+  GLOBAL = 0,
+  GENERIC = 1,
+  REGION = 2,
+  LOCAL = 3,
+  PRIVATE_LANE = 5,
+  PRIVATE_WAVE = 6,
+  DEFAULT = GLOBAL,
+};
+} // namespace DWARFAS
+
+/// If @p LLVMAddressSpace has a corresponding DWARF encoding,
+/// return it; otherwise return the sentinel value -1 to indicate
+/// no such mapping exists.
+///
+/// This maps private/scratch to the focused lane view.
+///
+/// These mappings must be kept in sync with llvm/docs/AMDGPUUsage.rst
+/// table "AMDGPU DWARF Address Space Mapping".
+///
+/// Note: This could return std::optional<int> but that would require
+/// an extra #include.
+inline int mapToDWARFAddrSpace(unsigned LLVMAddrSpace) {
----------------
arsenm wrote:

```suggestion
constexpr int mapToDWARFAddrSpace(unsigned LLVMAddrSpace) {
```

https://github.com/llvm/llvm-project/pull/153883


More information about the cfe-commits mailing list