[PATCH] D94735: CGDebugInfo: Drop unneeded line number for FlagFwdDecl declarations

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 19:11:10 PST 2021


MaskRay added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3338-3339
   // Get overall information about the record type for the debug info.
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  const unsigned Line =
-      getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
+  const unsigned Line = getLineNumber(RD->getLocation());
   StringRef RDName = getClassName(RD);
----------------
dblaikie wrote:
> Perhaps we can delete these two lines (using null/0 later on/where these values are referenced)? Since they aren't used for forward declarations anyway: https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/AsmPrinter/DwarfUnit.cpp#L814
Making `Line` always-0 will change .debug_info size quite a bit. It seems that there may be degraded debug info.

```
 0x00000048:     DW_TAG_class_type
                   DW_AT_calling_convention     (DW_CC_pass_by_value)
                   DW_AT_name   ("StringRef")
                   DW_AT_byte_size      (0x10)
-                  DW_AT_decl_file      ("/home/maskray/llvm/llvm/include/llvm/ADT/StringRef.h")
-                  DW_AT_decl_line      (57)
 
-0x00000051:       DW_TAG_member
+0x0000004f:       DW_TAG_member
                     DW_AT_name ("npos")
-                    DW_AT_type (0x0000eceb "const size_t")
+                    DW_AT_type (0x0000eac6 "const size_t")
                     DW_AT_decl_file    ("/home/maskray/llvm/llvm/include/llvm/ADT/StringRef.h")
                     DW_AT_decl_line    (59)
                     DW_AT_external     (true)
                     DW_AT_declaration  (true)
                     DW_AT_accessibility        (DW_ACCESS_public)
                     DW_AT_const_value  (18446744073709551615)
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94735/new/

https://reviews.llvm.org/D94735



More information about the cfe-commits mailing list