Skip to content

Commit 2a03d42

Browse files
committedJun 29, 2018
[DEBUG_INFO, NVPTX] Do not emit .debug_loc section.
Summary: .debug_loc section is not supported for NVPTX target. If there is an object whose location can change during its lifetime, we do not generate debug location info for this variable. Reviewers: echristo Subscribers: jholewinski, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D48730 llvm-svn: 335976
1 parent ce3a668 commit 2a03d42

File tree

3 files changed

+24
-53
lines changed

3 files changed

+24
-53
lines changed
 

‎llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
317317
else
318318
UseInlineStrings = DwarfInlinedStrings == Enable;
319319

320+
UseLocSection = !TT.isNVPTX();
321+
320322
HasAppleExtensionAttributes = tuneForLLDB();
321323

322324
// Handle split DWARF.
@@ -1196,6 +1198,9 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
11961198
RegVar->initializeDbgValue(MInsn);
11971199
continue;
11981200
}
1201+
// Do not emit location lists if .debug_loc secton is disabled.
1202+
if (!useLocSection())
1203+
continue;
11991204

12001205
// Handle multiple DBG_VALUE instructions describing one variable.
12011206
DebugLocStream::ListBuilder List(DebugLocs, TheCU, *Asm, *RegVar, *MInsn);

‎llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ class DwarfDebug : public DebugHandlerBase {
276276
/// temp symbols inside DWARF sections.
277277
bool UseSectionsAsReferences = false;
278278

279+
///Allow emission of the .debug_loc section.
280+
bool UseLocSection = true;
281+
279282
/// DWARF5 Experimental Options
280283
/// @{
281284
AccelTableKind TheAccelTableKind;
@@ -526,7 +529,7 @@ class DwarfDebug : public DebugHandlerBase {
526529
/// Returns whether to use inline strings.
527530
bool useInlineStrings() const { return UseInlineStrings; }
528531

529-
/// Returns whether GNU oub sections should be emitted.
532+
/// Returns whether GNU pub sections should be emitted.
530533
bool usePubSections() const { return UsePubSections; }
531534

532535
/// Returns whether ranges section should be emitted.
@@ -537,6 +540,9 @@ class DwarfDebug : public DebugHandlerBase {
537540
return UseSectionsAsReferences;
538541
}
539542

543+
/// Returns whether .debug_loc section should be emitted.
544+
bool useLocSection() const { return UseLocSection; }
545+
540546
// Experimental DWARF5 features.
541547

542548
/// Returns what kind (if any) of accelerator tables to emit.

‎llvm/test/DebugInfo/NVPTX/debug-loc-offset.ll

+12-52
Original file line numberDiff line numberDiff line change
@@ -127,40 +127,6 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
127127
!33 = !DILocation(line: 11, scope: !32)
128128
!34 = !DILocation(line: 12, scope: !14)
129129

130-
131-
; CHECK: // .section .debug_loc
132-
; CHECK: // {
133-
; CHECK: Ldebug_loc0:
134-
; CHECK: // .b64 Lfunc_begin0-Lfunc_begin0
135-
; CHECK: // .b64 Ltmp0-Lfunc_begin0
136-
; CHECK: // .b8 2 // Loc expr size
137-
; CHECK: // .b8 0
138-
; CHECK: // .b8 17 // DW_OP_consts
139-
; CHECK: // .b8 0 // 0
140-
; CHECK: // .b64 Ltmp0-Lfunc_begin0
141-
; CHECK: // .b64 Lfunc_end0-Lfunc_begin0
142-
; CHECK: // .b8 2 // Loc expr size
143-
; CHECK: // .b8 0
144-
; CHECK: // .b8 17 // DW_OP_consts
145-
; CHECK: // .b8 1 // 1
146-
; CHECK: // .b64 0
147-
; CHECK: // .b64 0
148-
; CHECK: Ldebug_loc1:
149-
; CHECK: // .b64 Ltmp2-Lfunc_begin1
150-
; CHECK: // .b64 Ltmp2-Lfunc_begin1
151-
; CHECK: // .b8 2 // Loc expr size
152-
; CHECK: // .b8 0
153-
; CHECK: // .b8 17 // DW_OP_consts
154-
; CHECK: // .b8 2 // 2
155-
; CHECK: // .b64 Ltmp2-Lfunc_begin1
156-
; CHECK: // .b64 Lfunc_end1-Lfunc_begin1
157-
; CHECK: // .b8 2 // Loc expr size
158-
; CHECK: // .b8 0
159-
; CHECK: // .b8 17 // DW_OP_consts
160-
; CHECK: // .b8 3 // 3
161-
; CHECK: // .b64 0
162-
; CHECK: // .b64 0
163-
; CHECK: // }
164130
; CHECK: // .section .debug_abbrev
165131
; CHECK: // {
166132
; CHECK: // .b8 1 // Abbreviation Code
@@ -214,8 +180,6 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
214180
; CHECK: // .b8 4 // Abbreviation Code
215181
; CHECK: // .b8 52 // DW_TAG_variable
216182
; CHECK: // .b8 0 // DW_CHILDREN_no
217-
; CHECK: // .b8 2 // DW_AT_location
218-
; CHECK: // .b8 6 // DW_FORM_data4
219183
; CHECK: // .b8 3 // DW_AT_name
220184
; CHECK: // .b8 8 // DW_FORM_string
221185
; CHECK: // .b8 58 // DW_AT_decl_file
@@ -251,8 +215,6 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
251215
; CHECK: // .b8 6 // Abbreviation Code
252216
; CHECK: // .b8 5 // DW_TAG_formal_parameter
253217
; CHECK: // .b8 0 // DW_CHILDREN_no
254-
; CHECK: // .b8 2 // DW_AT_location
255-
; CHECK: // .b8 6 // DW_FORM_data4
256218
; CHECK: // .b8 3 // DW_AT_name
257219
; CHECK: // .b8 8 // DW_FORM_string
258220
; CHECK: // .b8 58 // DW_AT_decl_file
@@ -278,12 +240,12 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
278240
; CHECK: // }
279241
; CHECK: // .section .debug_info
280242
; CHECK: // {
281-
; CHECK: // .b32 152 // Length of Unit
243+
; CHECK: // .b32 148 // Length of Unit
282244
; CHECK: // .b8 2 // DWARF version number
283245
; CHECK: // .b8 0
284246
; CHECK: // .b32 .debug_abbrev // Offset Into Abbrev. Section
285247
; CHECK: // .b8 8 // Address Size (in bytes)
286-
; CHECK: // .b8 1 // Abbrev [1] 0xb:0x91 DW_TAG_compile_unit
248+
; CHECK: // .b8 1 // Abbrev [1] 0xb:0x8d DW_TAG_compile_unit
287249
; CHECK: // .b8 99 // DW_AT_producer
288250
; CHECK: // .b8 108
289251
; CHECK: // .b8 97
@@ -359,7 +321,7 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
359321
; CHECK: // .b8 65 // DW_AT_name
360322
; CHECK: // .b8 0
361323
; CHECK: // .b8 1 // DW_AT_declaration
362-
; CHECK: // .b8 3 // Abbrev [3] 0x68:0x33 DW_TAG_subprogram
324+
; CHECK: // .b8 3 // Abbrev [3] 0x68:0x2f DW_TAG_subprogram
363325
; CHECK: // .b64 Lfunc_begin1 // DW_AT_low_pc
364326
; CHECK: // .b64 Lfunc_end1 // DW_AT_high_pc
365327
; CHECK: // .b8 95 // DW_AT_MIPS_linkage_name
@@ -378,21 +340,20 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
378340
; CHECK: // .b8 2 // DW_AT_decl_file
379341
; CHECK: // .b8 6 // DW_AT_decl_line
380342
; CHECK: // .b8 1 // DW_AT_external
381-
; CHECK: // .b8 4 // Abbrev [4] 0x89:0x11 DW_TAG_variable
382-
; CHECK: // .b32 Ldebug_loc1 // DW_AT_location
343+
; CHECK: // .b8 4 // Abbrev [4] 0x89:0xd DW_TAG_variable
383344
; CHECK: // .b8 122 // DW_AT_name
384345
; CHECK: // .b8 0
385346
; CHECK: // .b8 2 // DW_AT_decl_file
386347
; CHECK: // .b8 7 // DW_AT_decl_line
387-
; CHECK: // .b64 .debug_info+306 // DW_AT_type
348+
; CHECK: // .b64 .debug_info+298 // DW_AT_type
388349
; CHECK: // .b8 0 // End Of Children Mark
389350
; CHECK: // .b8 0 // End Of Children Mark
390-
; CHECK: // .b32 154 // Length of Unit
351+
; CHECK: // .b32 150 // Length of Unit
391352
; CHECK: // .b8 2 // DWARF version number
392353
; CHECK: // .b8 0
393354
; CHECK: // .b32 .debug_abbrev // Offset Into Abbrev. Section
394355
; CHECK: // .b8 8 // Address Size (in bytes)
395-
; CHECK: // .b8 1 // Abbrev [1] 0xb:0x93 DW_TAG_compile_unit
356+
; CHECK: // .b8 1 // Abbrev [1] 0xb:0x8f DW_TAG_compile_unit
396357
; CHECK: // .b8 99 // DW_AT_producer
397358
; CHECK: // .b8 108
398359
; CHECK: // .b8 97
@@ -464,7 +425,7 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
464425
; CHECK: // .b8 0
465426
; CHECK: // .b64 Lfunc_begin0 // DW_AT_low_pc
466427
; CHECK: // .b64 Lfunc_end0 // DW_AT_high_pc
467-
; CHECK: // .b8 5 // Abbrev [5] 0x64:0x32 DW_TAG_subprogram
428+
; CHECK: // .b8 5 // Abbrev [5] 0x64:0x2e DW_TAG_subprogram
468429
; CHECK: // .b64 Lfunc_begin0 // DW_AT_low_pc
469430
; CHECK: // .b64 Lfunc_end0 // DW_AT_high_pc
470431
; CHECK: // .b8 95 // DW_AT_MIPS_linkage_name
@@ -481,17 +442,16 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
481442
; CHECK: // .b8 0
482443
; CHECK: // .b8 1 // DW_AT_decl_file
483444
; CHECK: // .b8 1 // DW_AT_decl_line
484-
; CHECK: // .b32 150 // DW_AT_type
445+
; CHECK: // .b32 146 // DW_AT_type
485446
; CHECK: // .b8 1 // DW_AT_external
486-
; CHECK: // .b8 6 // Abbrev [6] 0x88:0xd DW_TAG_formal_parameter
487-
; CHECK: // .b32 Ldebug_loc0 // DW_AT_location
447+
; CHECK: // .b8 6 // Abbrev [6] 0x88:0x9 DW_TAG_formal_parameter
488448
; CHECK: // .b8 98 // DW_AT_name
489449
; CHECK: // .b8 0
490450
; CHECK: // .b8 1 // DW_AT_decl_file
491451
; CHECK: // .b8 1 // DW_AT_decl_line
492-
; CHECK: // .b32 150 // DW_AT_type
452+
; CHECK: // .b32 146 // DW_AT_type
493453
; CHECK: // .b8 0 // End Of Children Mark
494-
; CHECK: // .b8 7 // Abbrev [7] 0x96:0x7 DW_TAG_base_type
454+
; CHECK: // .b8 7 // Abbrev [7] 0x92:0x7 DW_TAG_base_type
495455
; CHECK: // .b8 105 // DW_AT_name
496456
; CHECK: // .b8 110
497457
; CHECK: // .b8 116

0 commit comments

Comments
 (0)
Please sign in to comment.