[Lldb-commits] [clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

David Blaikie via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 13 09:48:20 PST 2024


================
@@ -5401,6 +5409,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const {
             // feasible some day.
             return TA.getAsIntegral().getBitWidth() <= 64 &&
                    IsReconstitutableType(TA.getIntegralType());
+          case TemplateArgument::StructuralValue:
+            return false;
----------------
dwblaikie wrote:

I did finally take a look at this - I think the Clang side of things is fine - if anything improvements could be made to LLVM to be able to lower constants to DWARF for a wider variety of values.
eg: For the `float` example, the IR is:
```
!8 = !DITemplateValueParameter(name: "F", type: !9, value: float 1.000000e+00)
```
But the DWARF backend can't handle the float constant - the handling is in `DwarfUnit::constructTemplateValueParameterDIE` (in llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp) and currently only handles ConstantInt (for basic stuff - bools, ints, etc) and GlobalValue (for pointer non-type template parameters).

So for these new floats and such, the DWARF doesn't include the value, only the type.

GCC uses this encoding, for instance:
```
0x0000002b:     DW_TAG_template_value_parameter [3]   (0x0000001e)
                  DW_AT_name [DW_FORM_string]   ("F")
                  DW_AT_type [DW_FORM_ref4]     (cu + 0x004d => {0x0000004d} "float")
                  DW_AT_const_value [DW_FORM_block1]    (<0x04> 00 00 80 3f )
```

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


More information about the lldb-commits mailing list