[PATCH] D103300: [Debug-Info] handle DW_CC_pass_by_value/DW_CC_pass_by_reference under strict DWARF.

EsmeYi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 27 22:12:46 PDT 2021


Esme created this revision.
Esme added reviewers: dblaikie, aprantl, probinson, shchenz, jsji, PowerPC.
Herald added a subscriber: hiraditya.
Esme requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When -strict-dwarf=true is specified, the calling convention info `DW_CC_pass_by_value` or `DW_CC_pass_by_reference`  can only be generated at DWARF5.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103300

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/Generic/pass-by-value.ll


Index: llvm/test/DebugInfo/Generic/pass-by-value.ll
===================================================================
--- llvm/test/DebugInfo/Generic/pass-by-value.ll
+++ llvm/test/DebugInfo/Generic/pass-by-value.ll
@@ -1,4 +1,6 @@
 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: %llc_dwarf -O0 -filetype=obj < %s -strict-dwarf=true | llvm-dwarfdump -debug-info - \
+; RUN:   | FileCheck %s -check-prefix=STRICT
 ;
 ; // S is not trivially copyable.
 ; struct S {
@@ -20,6 +22,14 @@
 ; CHECK: DW_TAG_structure_type
 ; CHECK-NEXT: DW_AT_calling_convention	(DW_CC_pass_by_value)
 ; CHECK-NEXT: DW_AT_name	("T")
+;
+; STRICT: DW_TAG_structure_type
+; STRICT-NOT: DW_AT_calling_convention	(DW_CC_pass_by_reference)
+; STRICT-NEXT: DW_AT_name	("S")
+;
+; STRICT: DW_TAG_structure_type
+; STRICT-NOT: DW_AT_calling_convention	(DW_CC_pass_by_value)
+; STRICT-NEXT: DW_AT_name	("T")
 
 %struct.S = type { i8 }
 %struct.T = type { i8 }
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -939,14 +939,17 @@
       addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
 
     // Add the type's non-standard calling convention.
-    uint8_t CC = 0;
-    if (CTy->isTypePassByValue())
-      CC = dwarf::DW_CC_pass_by_value;
-    else if (CTy->isTypePassByReference())
-      CC = dwarf::DW_CC_pass_by_reference;
-    if (CC)
-      addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
-              CC);
+    // DW_CC_pass_by_value/DW_CC_pass_by_reference are introduced in DWARF 5.
+    if (!Asm->TM.Options.DebugStrictDwarf || DD->getDwarfVersion() >= 5) {
+      uint8_t CC = 0;
+      if (CTy->isTypePassByValue())
+        CC = dwarf::DW_CC_pass_by_value;
+      else if (CTy->isTypePassByReference())
+        CC = dwarf::DW_CC_pass_by_reference;
+      if (CC)
+        addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
+                CC);
+    }
     break;
   }
   default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103300.348440.patch
Type: text/x-patch
Size: 2126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210528/84029de0/attachment.bin>


More information about the llvm-commits mailing list