[DEBUG_INFO, NVPTX] Do not emit .debug_loc section.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 29 Jun 2018 14:23:28 +0000 (14:23 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 29 Jun 2018 14:23:28 +0000 (14:23 +0000)
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

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/test/DebugInfo/NVPTX/debug-loc-offset.ll

index c768814..a33bda3 100644 (file)
@@ -317,6 +317,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
   else
     UseInlineStrings = DwarfInlinedStrings == Enable;
 
+  UseLocSection = !TT.isNVPTX();
+
   HasAppleExtensionAttributes = tuneForLLDB();
 
   // Handle split DWARF.
@@ -1196,6 +1198,9 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
       RegVar->initializeDbgValue(MInsn);
       continue;
     }
+    // Do not emit location lists if .debug_loc secton is disabled.
+    if (!useLocSection())
+      continue;
 
     // Handle multiple DBG_VALUE instructions describing one variable.
     DebugLocStream::ListBuilder List(DebugLocs, TheCU, *Asm, *RegVar, *MInsn);
index f01d680..54f0e5b 100644 (file)
@@ -276,6 +276,9 @@ class DwarfDebug : public DebugHandlerBase {
   /// temp symbols inside DWARF sections.
   bool UseSectionsAsReferences = false;
 
+  ///Allow emission of the .debug_loc section.
+  bool UseLocSection = true;
+
   /// DWARF5 Experimental Options
   /// @{
   AccelTableKind TheAccelTableKind;
@@ -526,7 +529,7 @@ public:
   /// Returns whether to use inline strings.
   bool useInlineStrings() const { return UseInlineStrings; }
 
-  /// Returns whether GNU oub sections should be emitted.
+  /// Returns whether GNU pub sections should be emitted.
   bool usePubSections() const { return UsePubSections; }
 
   /// Returns whether ranges section should be emitted.
@@ -537,6 +540,9 @@ public:
     return UseSectionsAsReferences;
   }
 
+  /// Returns whether .debug_loc section should be emitted.
+  bool useLocSection() const { return UseLocSection; }
+
   // Experimental DWARF5 features.
 
   /// Returns what kind (if any) of accelerator tables to emit.
index 2368e1d..7cf4ab3 100644 (file)
@@ -127,40 +127,6 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 !33 = !DILocation(line: 11, scope: !32)
 !34 = !DILocation(line: 12, scope: !14)
 
-
-; CHECK: // .section .debug_loc
-; CHECK: // {
-; CHECK: Ldebug_loc0:
-; CHECK: // .b64 Lfunc_begin0-Lfunc_begin0
-; CHECK: // .b64 Ltmp0-Lfunc_begin0
-; CHECK: // .b8 2                                // Loc expr size
-; CHECK: // .b8 0
-; CHECK: // .b8 17                               // DW_OP_consts
-; CHECK: // .b8 0                                // 0
-; CHECK: // .b64 Ltmp0-Lfunc_begin0
-; CHECK: // .b64 Lfunc_end0-Lfunc_begin0
-; CHECK: // .b8 2                                // Loc expr size
-; CHECK: // .b8 0
-; CHECK: // .b8 17                               // DW_OP_consts
-; CHECK: // .b8 1                                // 1
-; CHECK: // .b64 0
-; CHECK: // .b64 0
-; CHECK: Ldebug_loc1:
-; CHECK: // .b64 Ltmp2-Lfunc_begin1
-; CHECK: // .b64 Ltmp2-Lfunc_begin1
-; CHECK: // .b8 2                                // Loc expr size
-; CHECK: // .b8 0
-; CHECK: // .b8 17                               // DW_OP_consts
-; CHECK: // .b8 2                                // 2
-; CHECK: // .b64 Ltmp2-Lfunc_begin1
-; CHECK: // .b64 Lfunc_end1-Lfunc_begin1
-; CHECK: // .b8 2                                // Loc expr size
-; CHECK: // .b8 0
-; CHECK: // .b8 17                               // DW_OP_consts
-; CHECK: // .b8 3                                // 3
-; CHECK: // .b64 0
-; CHECK: // .b64 0
-; CHECK: // }
 ; CHECK: // .section .debug_abbrev
 ; CHECK: // {
 ; CHECK: // .b8 1                                // Abbreviation Code
@@ -214,8 +180,6 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // .b8 4                                // Abbreviation Code
 ; CHECK: // .b8 52                               // DW_TAG_variable
 ; CHECK: // .b8 0                                // DW_CHILDREN_no
-; CHECK: // .b8 2                                // DW_AT_location
-; CHECK: // .b8 6                                // DW_FORM_data4
 ; CHECK: // .b8 3                                // DW_AT_name
 ; CHECK: // .b8 8                                // DW_FORM_string
 ; CHECK: // .b8 58                               // DW_AT_decl_file
@@ -251,8 +215,6 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // .b8 6                                // Abbreviation Code
 ; CHECK: // .b8 5                                // DW_TAG_formal_parameter
 ; CHECK: // .b8 0                                // DW_CHILDREN_no
-; CHECK: // .b8 2                                // DW_AT_location
-; CHECK: // .b8 6                                // DW_FORM_data4
 ; CHECK: // .b8 3                                // DW_AT_name
 ; CHECK: // .b8 8                                // DW_FORM_string
 ; CHECK: // .b8 58                               // DW_AT_decl_file
@@ -278,12 +240,12 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // }
 ; CHECK: // .section .debug_info
 ; CHECK: // {
-; CHECK: // .b32 152                             // Length of Unit
+; CHECK: // .b32 148                             // Length of Unit
 ; CHECK: // .b8 2                                // DWARF version number
 ; CHECK: // .b8 0
 ; CHECK: // .b32 .debug_abbrev                   // Offset Into Abbrev. Section
 ; CHECK: // .b8 8                                // Address Size (in bytes)
-; CHECK: // .b8 1                                // Abbrev [1] 0xb:0x91 DW_TAG_compile_unit
+; CHECK: // .b8 1                                // Abbrev [1] 0xb:0x8d DW_TAG_compile_unit
 ; CHECK: // .b8 99                               // DW_AT_producer
 ; CHECK: // .b8 108
 ; CHECK: // .b8 97
@@ -359,7 +321,7 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // .b8 65                               // DW_AT_name
 ; CHECK: // .b8 0
 ; CHECK: // .b8 1                                // DW_AT_declaration
-; CHECK: // .b8 3                                // Abbrev [3] 0x68:0x33 DW_TAG_subprogram
+; CHECK: // .b8 3                                // Abbrev [3] 0x68:0x2f DW_TAG_subprogram
 ; CHECK: // .b64 Lfunc_begin1                    // DW_AT_low_pc
 ; CHECK: // .b64 Lfunc_end1                      // DW_AT_high_pc
 ; CHECK: // .b8 95                               // DW_AT_MIPS_linkage_name
@@ -378,21 +340,20 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // .b8 2                                // DW_AT_decl_file
 ; CHECK: // .b8 6                                // DW_AT_decl_line
 ; CHECK: // .b8 1                                // DW_AT_external
-; CHECK: // .b8 4                                // Abbrev [4] 0x89:0x11 DW_TAG_variable
-; CHECK: // .b32 Ldebug_loc1                     // DW_AT_location
+; CHECK: // .b8 4                                // Abbrev [4] 0x89:0xd DW_TAG_variable
 ; CHECK: // .b8 122                              // DW_AT_name
 ; CHECK: // .b8 0
 ; CHECK: // .b8 2                                // DW_AT_decl_file
 ; CHECK: // .b8 7                                // DW_AT_decl_line
-; CHECK: // .b64 .debug_info+306                 // DW_AT_type
+; CHECK: // .b64 .debug_info+298                 // DW_AT_type
 ; CHECK: // .b8 0                                // End Of Children Mark
 ; CHECK: // .b8 0                                // End Of Children Mark
-; CHECK: // .b32 154                             // Length of Unit
+; CHECK: // .b32 150                             // Length of Unit
 ; CHECK: // .b8 2                                // DWARF version number
 ; CHECK: // .b8 0
 ; CHECK: // .b32 .debug_abbrev                   // Offset Into Abbrev. Section
 ; CHECK: // .b8 8                                // Address Size (in bytes)
-; CHECK: // .b8 1                                // Abbrev [1] 0xb:0x93 DW_TAG_compile_unit
+; CHECK: // .b8 1                                // Abbrev [1] 0xb:0x8f DW_TAG_compile_unit
 ; CHECK: // .b8 99                               // DW_AT_producer
 ; CHECK: // .b8 108
 ; CHECK: // .b8 97
@@ -464,7 +425,7 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // .b8 0
 ; CHECK: // .b64 Lfunc_begin0                    // DW_AT_low_pc
 ; CHECK: // .b64 Lfunc_end0                      // DW_AT_high_pc
-; CHECK: // .b8 5                                // Abbrev [5] 0x64:0x32 DW_TAG_subprogram
+; CHECK: // .b8 5                                // Abbrev [5] 0x64:0x2e DW_TAG_subprogram
 ; CHECK: // .b64 Lfunc_begin0                    // DW_AT_low_pc
 ; CHECK: // .b64 Lfunc_end0                      // DW_AT_high_pc
 ; CHECK: // .b8 95                               // DW_AT_MIPS_linkage_name
@@ -481,17 +442,16 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
 ; CHECK: // .b8 0
 ; CHECK: // .b8 1                                // DW_AT_decl_file
 ; CHECK: // .b8 1                                // DW_AT_decl_line
-; CHECK: // .b32 150                             // DW_AT_type
+; CHECK: // .b32 146                             // DW_AT_type
 ; CHECK: // .b8 1                                // DW_AT_external
-; CHECK: // .b8 6                                // Abbrev [6] 0x88:0xd DW_TAG_formal_parameter
-; CHECK: // .b32 Ldebug_loc0                     // DW_AT_location
+; CHECK: // .b8 6                                // Abbrev [6] 0x88:0x9 DW_TAG_formal_parameter
 ; CHECK: // .b8 98                               // DW_AT_name
 ; CHECK: // .b8 0
 ; CHECK: // .b8 1                                // DW_AT_decl_file
 ; CHECK: // .b8 1                                // DW_AT_decl_line
-; CHECK: // .b32 150                             // DW_AT_type
+; CHECK: // .b32 146                             // DW_AT_type
 ; CHECK: // .b8 0                                // End Of Children Mark
-; CHECK: // .b8 7                                // Abbrev [7] 0x96:0x7 DW_TAG_base_type
+; CHECK: // .b8 7                                // Abbrev [7] 0x92:0x7 DW_TAG_base_type
 ; CHECK: // .b8 105                              // DW_AT_name
 ; CHECK: // .b8 110
 ; CHECK: // .b8 116