-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NVPTX] add address class for variables with a single register location #110030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-backend-nvptx @llvm/pr-subscribers-debuginfo Author: William G Hatch (willghatch) ChangesThis is the final piece to enable register debugging for variables in registers that have single locations that last throughout their enclosing scope. The next step after this for supporting register debugging for NVPTX is to support the .debug_loc section. Stacked on top of: #109495 Patch is 357.48 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/110030.diff 4 Files Affected:
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 0a1ff189bedbc4..a52699e4fe38e2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -779,6 +779,14 @@ DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV, bool Abstract) {
void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
const Loc::Single &Single, const DbgVariable &DV, DIE &VariableDie) {
const DbgValueLoc *DVal = &Single.getValueLoc();
+ if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB() &&
+ !Single.getExpr()) {
+
+ // Lack of expression means it is a register. Registers for PTX need to
+ // be marked with DW_AT_address_class = 2. See
+ // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
+ addUInt(VariableDie, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1, 2);
+ }
if (!DVal->isVariadic()) {
const DbgValueLocEntry *Entry = DVal->getLocEntries().begin();
if (Entry->isLocation()) {
diff --git a/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll b/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
index 6acc1ba2512711..2d927b18d976d9 100644
--- a/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
+++ b/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
@@ -120,6 +120,8 @@ entry:
; CHECK-NEXT: .b8 3 // Abbreviation Code
; CHECK-NEXT: .b8 5 // DW_TAG_formal_parameter
; CHECK-NEXT: .b8 0 // DW_CHILDREN_no
+; CHECK-NEXT: .b8 51 // DW_AT_address_class
+; CHECK-NEXT: .b8 11 // DW_FORM_data1
; CHECK-NEXT: .b8 2 // DW_AT_location
; CHECK-NEXT: .b8 10 // DW_FORM_block1
; CHECK-NEXT: .b8 3 // DW_AT_name
@@ -147,12 +149,12 @@ entry:
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_info
; CHECK-NEXT: {
-; CHECK-NEXT: .b32 195 // Length of Unit
+; CHECK-NEXT: .b32 197 // Length of Unit
; CHECK-NEXT: .b8 2 // DWARF version number
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK-NEXT: .b8 8 // Address Size (in bytes)
-; CHECK-NEXT: .b8 1 // Abbrev [1] 0xb:0xbc DW_TAG_compile_unit
+; CHECK-NEXT: .b8 1 // Abbrev [1] 0xb:0xbe DW_TAG_compile_unit
; CHECK-NEXT: .b8 99 // DW_AT_producer
; CHECK-NEXT: .b8 108
; CHECK-NEXT: .b8 97
@@ -225,7 +227,7 @@ entry:
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b64 $L__func_begin0 // DW_AT_low_pc
; CHECK-NEXT: .b64 $L__func_end2 // DW_AT_high_pc
-; CHECK-NEXT: .b8 2 // Abbrev [2] 0x65:0x2d DW_TAG_subprogram
+; CHECK-NEXT: .b8 2 // Abbrev [2] 0x65:0x2e DW_TAG_subprogram
; CHECK-NEXT: .b64 $L__func_begin0 // DW_AT_low_pc
; CHECK-NEXT: .b64 $L__func_end0 // DW_AT_high_pc
; CHECK-NEXT: .b8 1 // DW_AT_frame_base
@@ -235,9 +237,10 @@ entry:
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
; CHECK-NEXT: .b8 1 // DW_AT_decl_line
; CHECK-NEXT: .b8 1 // DW_AT_prototyped
-; CHECK-NEXT: .b32 191 // DW_AT_type
+; CHECK-NEXT: .b32 193 // DW_AT_type
; CHECK-NEXT: .b8 1 // DW_AT_external
-; CHECK-NEXT: .b8 3 // Abbrev [3] 0x82:0xf DW_TAG_formal_parameter
+; CHECK-NEXT: .b8 3 // Abbrev [3] 0x82:0x10 DW_TAG_formal_parameter
+; CHECK-NEXT: .b8 2 // DW_AT_address_class
; CHECK-NEXT: .b8 5 // DW_AT_location
; CHECK-NEXT: .b8 144
; CHECK-NEXT: .b8 177
@@ -248,9 +251,9 @@ entry:
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
; CHECK-NEXT: .b8 1 // DW_AT_decl_line
-; CHECK-NEXT: .b32 191 // DW_AT_type
+; CHECK-NEXT: .b32 193 // DW_AT_type
; CHECK-NEXT: .b8 0 // End Of Children Mark
-; CHECK-NEXT: .b8 2 // Abbrev [2] 0x92:0x2d DW_TAG_subprogram
+; CHECK-NEXT: .b8 2 // Abbrev [2] 0x93:0x2e DW_TAG_subprogram
; CHECK-NEXT: .b64 $L__func_begin2 // DW_AT_low_pc
; CHECK-NEXT: .b64 $L__func_end2 // DW_AT_high_pc
; CHECK-NEXT: .b8 1 // DW_AT_frame_base
@@ -260,9 +263,10 @@ entry:
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
; CHECK-NEXT: .b8 3 // DW_AT_decl_line
; CHECK-NEXT: .b8 1 // DW_AT_prototyped
-; CHECK-NEXT: .b32 191 // DW_AT_type
+; CHECK-NEXT: .b32 193 // DW_AT_type
; CHECK-NEXT: .b8 1 // DW_AT_external
-; CHECK-NEXT: .b8 3 // Abbrev [3] 0xaf:0xf DW_TAG_formal_parameter
+; CHECK-NEXT: .b8 3 // Abbrev [3] 0xb0:0x10 DW_TAG_formal_parameter
+; CHECK-NEXT: .b8 2 // DW_AT_address_class
; CHECK-NEXT: .b8 5 // DW_AT_location
; CHECK-NEXT: .b8 144
; CHECK-NEXT: .b8 177
@@ -273,9 +277,9 @@ entry:
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
; CHECK-NEXT: .b8 3 // DW_AT_decl_line
-; CHECK-NEXT: .b32 191 // DW_AT_type
+; CHECK-NEXT: .b32 193 // DW_AT_type
; CHECK-NEXT: .b8 0 // End Of Children Mark
-; CHECK-NEXT: .b8 4 // Abbrev [4] 0xbf:0x7 DW_TAG_base_type
+; CHECK-NEXT: .b8 4 // Abbrev [4] 0xc1:0x7 DW_TAG_base_type
; CHECK-NEXT: .b8 105 // DW_AT_name
; CHECK-NEXT: .b8 110
; CHECK-NEXT: .b8 116
diff --git a/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll b/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll
index 03a120cd52fabc..3585095151181d 100644
--- a/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll
+++ b/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll
@@ -160,6 +160,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 5 // Abbreviation Code
; CHECK-NEXT:.b8 5 // DW_TAG_formal_parameter
; CHECK-NEXT:.b8 0 // DW_CHILDREN_no
+; CHECK-NEXT:.b8 51 // DW_AT_address_class
+; CHECK-NEXT:.b8 11 // DW_FORM_data1
; CHECK-NEXT:.b8 2 // DW_AT_location
; CHECK-NEXT:.b8 10 // DW_FORM_block1
; CHECK-NEXT:.b8 3 // DW_AT_name
@@ -193,15 +195,15 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 0 // EOM(1)
; CHECK-NEXT:.b8 0 // EOM(2)
; CHECK-NEXT:.b8 0 // EOM(3)
-; CHECK-NEXT: }
-; CHECK-NEXT: .section .debug_info
-; CHECK-NEXT: {
-; CHECK-NEXT:.b32 252 // Length of Unit
+; CHECK-NEXT: }
+; CHECK-NEXT: .section .debug_info
+; CHECK-NEXT: {
+; CHECK-NEXT:.b32 254 // Length of Unit
; CHECK-NEXT:.b8 2 // DWARF version number
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK-NEXT:.b8 8 // Address Size (in bytes)
-; CHECK-NEXT:.b8 1 // Abbrev [1] 0xb:0xf5 DW_TAG_compile_unit
+; CHECK-NEXT:.b8 1 // Abbrev [1] 0xb:0xf7 DW_TAG_compile_unit
; CHECK-NEXT:.b8 99 // DW_AT_producer
; CHECK-NEXT:.b8 108
; CHECK-NEXT:.b8 97
@@ -313,7 +315,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 9 // DW_AT_location
; CHECK-NEXT:.b8 3
; CHECK-NEXT:.b64 SHARED
-; CHECK-NEXT:.b8 4 // Abbrev [4] 0xa0:0x51 DW_TAG_subprogram
+; CHECK-NEXT:.b8 4 // Abbrev [4] 0xa0:0x53 DW_TAG_subprogram
; CHECK-NEXT:.b64 $L__func_begin0 // DW_AT_low_pc
; CHECK-NEXT:.b64 $L__func_end0 // DW_AT_high_pc
; CHECK-NEXT:.b8 1 // DW_AT_frame_base
@@ -331,7 +333,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 1 // DW_AT_decl_file
; CHECK-NEXT:.b8 6 // DW_AT_decl_line
; CHECK-NEXT:.b8 1 // DW_AT_external
-; CHECK-NEXT:.b8 5 // Abbrev [5] 0xc0:0xf DW_TAG_formal_parameter
+; CHECK-NEXT:.b8 5 // Abbrev [5] 0xc0:0x10 DW_TAG_formal_parameter
+; CHECK-NEXT:.b8 2 // DW_AT_address_class
; CHECK-NEXT:.b8 5 // DW_AT_location
; CHECK-NEXT:.b8 144
; CHECK-NEXT:.b8 177
@@ -342,20 +345,21 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b8 1 // DW_AT_decl_file
; CHECK-NEXT:.b8 6 // DW_AT_decl_line
-; CHECK-NEXT:.b32 241 // DW_AT_type
-; CHECK-NEXT:.b8 6 // Abbrev [6] 0xcf:0x9 DW_TAG_formal_parameter
+; CHECK-NEXT:.b32 243 // DW_AT_type
+; CHECK-NEXT:.b8 6 // Abbrev [6] 0xd0:0x9 DW_TAG_formal_parameter
; CHECK-NEXT:.b8 120 // DW_AT_name
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b8 1 // DW_AT_decl_file
; CHECK-NEXT:.b8 6 // DW_AT_decl_line
-; CHECK-NEXT:.b32 250 // DW_AT_type
-; CHECK-NEXT:.b8 6 // Abbrev [6] 0xd8:0x9 DW_TAG_formal_parameter
+; CHECK-NEXT:.b32 252 // DW_AT_type
+; CHECK-NEXT:.b8 6 // Abbrev [6] 0xd9:0x9 DW_TAG_formal_parameter
; CHECK-NEXT:.b8 121 // DW_AT_name
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b8 1 // DW_AT_decl_file
; CHECK-NEXT:.b8 6 // DW_AT_decl_line
-; CHECK-NEXT:.b32 250 // DW_AT_type
-; CHECK-NEXT:.b8 5 // Abbrev [5] 0xe1:0xf DW_TAG_formal_parameter
+; CHECK-NEXT:.b32 252 // DW_AT_type
+; CHECK-NEXT:.b8 5 // Abbrev [5] 0xe2:0x10 DW_TAG_formal_parameter
+; CHECK-NEXT:.b8 2 // DW_AT_address_class
; CHECK-NEXT:.b8 5 // DW_AT_location
; CHECK-NEXT:.b8 144
; CHECK-NEXT:.b8 177
@@ -368,7 +372,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 6 // DW_AT_decl_line
; CHECK-NEXT:.b32 127 // DW_AT_type
; CHECK-NEXT:.b8 0 // End Of Children Mark
-; CHECK-NEXT:.b8 3 // Abbrev [3] 0xf1:0x9 DW_TAG_base_type
+; CHECK-NEXT:.b8 3 // Abbrev [3] 0xf3:0x9 DW_TAG_base_type
; CHECK-NEXT:.b8 102 // DW_AT_name
; CHECK-NEXT:.b8 108
; CHECK-NEXT:.b8 111
@@ -377,8 +381,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b8 4 // DW_AT_encoding
; CHECK-NEXT:.b8 4 // DW_AT_byte_size
-; CHECK-NEXT:.b8 7 // Abbrev [7] 0xfa:0x5 DW_TAG_pointer_type
-; CHECK-NEXT:.b32 241 // DW_AT_type
+; CHECK-NEXT:.b8 7 // Abbrev [7] 0xfc:0x5 DW_TAG_pointer_type
+; CHECK-NEXT:.b32 243 // DW_AT_type
; CHECK-NEXT:.b8 0 // End Of Children Mark
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_loc { }
diff --git a/llvm/test/DebugInfo/NVPTX/debug-info.ll b/llvm/test/DebugInfo/NVPTX/debug-info.ll
index 5c5fb53edd7cb6..643ed6484ae9f3 100644
--- a/llvm/test/DebugInfo/NVPTX/debug-info.ll
+++ b/llvm/test/DebugInfo/NVPTX/debug-info.ll
@@ -490,6 +490,8 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT:.b8 27 // Abbreviation Code
; CHECK-NEXT:.b8 5 // DW_TAG_formal_parameter
; CHECK-NEXT:.b8 0 // DW_CHILDREN_no
+; CHECK-NEXT:.b8 51 // DW_AT_address_class
+; CHECK-NEXT:.b8 11 // DW_FORM_data1
; CHECK-NEXT:.b8 2 // DW_AT_location
; CHECK-NEXT:.b8 10 // DW_FORM_block1
; CHECK-NEXT:.b8 49 // DW_AT_abstract_origin
@@ -705,12 +707,12 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_info
; CHECK-NEXT: {
-; CHECK-NEXT:.b32 10035 // Length of Unit
+; CHECK-NEXT:.b32 10036 // Length of Unit
; CHECK-NEXT:.b8 2 // DWARF version number
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK-NEXT:.b8 8 // Address Size (in bytes)
-; CHECK-NEXT:.b8 1 // Abbrev [1] 0xb:0x272c DW_TAG_compile_unit
+; CHECK-NEXT:.b8 1 // Abbrev [1] 0xb:0x272d DW_TAG_compile_unit
; CHECK-NEXT:.b8 0 // DW_AT_producer
; CHECK-NEXT:.b8 4 // DW_AT_language
; CHECK-NEXT:.b8 0
@@ -2602,7 +2604,7 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT:.b8 4 // DW_AT_byte_size
; CHECK-NEXT:.b8 12 // Abbrev [12] 0x84d:0x5 DW_TAG_pointer_type
; CHECK-NEXT:.b32 2116 // DW_AT_type
-; CHECK-NEXT:.b8 23 // Abbrev [23] 0x852:0xc5 DW_TAG_subprogram
+; CHECK-NEXT:.b8 23 // Abbrev [23] 0x852:0xc6 DW_TAG_subprogram
; CHECK-NEXT:.b64 $L__func_begin0 // DW_AT_low_pc
; CHECK-NEXT:.b64 $L__func_end0 // DW_AT_high_pc
; CHECK-NEXT:.b8 1 // DW_AT_frame_base
@@ -2636,7 +2638,7 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b8 1 // DW_AT_decl_file
; CHECK-NEXT:.b8 5 // DW_AT_decl_line
-; CHECK-NEXT:.b32 4585 // DW_AT_type
+; CHECK-NEXT:.b32 4586 // DW_AT_type
; CHECK-NEXT:.b8 22 // Abbrev [22] 0x886:0x9 DW_TAG_formal_parameter
; CHECK-NEXT:.b8 97 // DW_AT_name
; CHECK-NEXT:.b8 0
@@ -2660,7 +2662,7 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b8 1 // DW_AT_decl_file
; CHECK-NEXT:.b8 6 // DW_AT_decl_line
-; CHECK-NEXT:.b32 4585 // DW_AT_type
+; CHECK-NEXT:.b32 4586 // DW_AT_type
; CHECK-NEXT:.b8 25 // Abbrev [25] 0x8aa:0x18 DW_TAG_inlined_subroutine
; CHECK-NEXT:.b32 707 // DW_AT_abstract_origin
; CHECK-NEXT:.b64 $L__tmp0 // DW_AT_low_pc
@@ -2682,14 +2684,15 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT:.b8 1 // DW_AT_call_file
; CHECK-NEXT:.b8 6 // DW_AT_call_line
; CHECK-NEXT:.b8 37 // DW_AT_call_column
-; CHECK-NEXT:.b8 26 // Abbrev [26] 0x8f2:0x24 DW_TAG_inlined_subroutine
+; CHECK-NEXT:.b8 26 // Abbrev [26] 0x8f2:0x25 DW_TAG_inlined_subroutine
; CHECK-NEXT:.b32 2066 // DW_AT_abstract_origin
; CHECK-NEXT:.b64 $L__tmp9 // DW_AT_low_pc
; CHECK-NEXT:.b64 $L__tmp10 // DW_AT_high_pc
; CHECK-NEXT:.b8 1 // DW_AT_call_file
; CHECK-NEXT:.b8 8 // DW_AT_call_line
; CHECK-NEXT:.b8 5 // DW_AT_call_column
-; CHECK-NEXT:.b8 27 // Abbrev [27] 0x90a:0xb DW_TAG_formal_parameter
+; CHECK-NEXT:.b8 27 // Abbrev [27] 0x90a:0xc DW_TAG_formal_parameter
+; CHECK-NEXT:.b8 2 // DW_AT_address_class
; CHECK-NEXT:.b8 5 // DW_AT_location
; CHECK-NEXT:.b8 144
; CHECK-NEXT:.b8 179
@@ -2699,856 +2702,856 @@ if.end: ; preds = %if.then, %entry
; CHECK-NEXT:.b32 2095 // DW_AT_abstract_origin
; CHECK-NEXT:.b8 0 // End Of Children Mark
; CHECK-NEXT:.b8 0 // End Of Children Mark
-; CHECK-NEXT:.b8 28 // Abbrev [28] 0x917:0x588 DW_TAG_namespace
+; CHECK-NEXT:.b8 28 // Abbrev [28] 0x918:0x588 DW_TAG_namespace
; CHECK-NEXT:.b8 115 // DW_AT_name
; CHECK-NEXT:.b8 116
; CHECK-NEXT:.b8 100
; CHECK-NEXT:.b8 0
-; CHECK-NEXT:.b8 29 // Abbrev [29] 0x91c:0x7 DW_TAG_imported_declaration
+; CHECK-NEXT:.b8 29 // Abbrev [29] 0x91d:0x7 DW_TAG_imported_declaration
; CHECK-NEXT:.b8 4 // DW_AT_decl_file
; CHECK-NEXT:.b8 202 // DW_AT_decl_line
-; CHECK-NEXT:.b32 3743 // DW_AT_import
-; CHECK-NEXT:.b8 29 // Abbrev [29] 0x923:0x7 DW_TAG_imported_declaration
+; CHECK-NEXT:.b32 3744 // DW_AT_import
+; CHECK-NEXT:.b8 29 // Abbrev [29] 0x924:0x7 DW_TAG_imported_declaration
; CHECK-NEXT:.b8 4 // DW_AT_decl_file
; CHECK-NEXT:.b8 203 // DW_AT_decl_line
-; CHECK-NEXT:.b32 3787 // DW_AT_import
-; CHECK-NEXT:.b8 29 // Abbrev [29] 0x92a:0x7 DW_TAG_imported_declaration
+; CHECK-NEXT:.b32 3788 // DW_AT_import
+; CHECK-NEXT:.b8 29 // Abbrev [29] 0x92b:0x7 DW_TAG_imported_declaration
; CHECK-NEXT:.b8 4 // DW_AT_decl_file
; CHECK-NEXT:.b8 204 // DW_AT_decl_line
-; CHECK-NEXT:.b32 3816 // DW_AT_im...
[truncated]
|
bd03bbe to
96c944d
Compare
walter-erquinigo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing
f07f4fc to
ea341b9
Compare
This is the final piece to enable register debugging for variables in registers that have single locations that last throughout their enclosing scope. The next step after this for supporting register debugging for NVPTX is to support the .debug_loc section. Stacked on top of: #109495
ea341b9 to
5d41657
Compare
…on (llvm#110030) This is the final piece to enable register debugging for variables in registers that have single locations that last throughout their enclosing scope. The next step after this for supporting register debugging for NVPTX is to support the .debug_loc section. Stacked on top of: llvm#109495
This is the final piece to enable register debugging for variables in registers that have single locations that last throughout their enclosing scope.
The next step after this for supporting register debugging for NVPTX is to support the .debug_loc section.
Stacked on top of: #109495