From: Esme-Yi Date: Fri, 4 Jun 2021 08:14:47 +0000 (+0000) Subject: [Debug-Info] handle DW_CC_pass_by_value/DW_CC_pass_by_reference under strict DWARF. X-Git-Tag: llvmorg-14-init~4885 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbfd717197671769e92b1c00b08391a7cac62fed;p=platform%2Fupstream%2Fllvm.git [Debug-Info] handle DW_CC_pass_by_value/DW_CC_pass_by_reference under strict DWARF. Summary: 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. Reviewed By: shchenz, dblaikie Differential Revision: https://reviews.llvm.org/D103300 --- diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index a28dbb3..82dbb8a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -939,14 +939,17 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) { 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: diff --git a/llvm/test/DebugInfo/Generic/pass-by-value.ll b/llvm/test/DebugInfo/Generic/pass-by-value.ll index ce8647e..6faf5f2 100644 --- a/llvm/test/DebugInfo/Generic/pass-by-value.ll +++ b/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 --implicit-check-not DW_AT_calling_convention ; ; // S is not trivially copyable. ; struct S { @@ -20,6 +22,12 @@ ; 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-NEXT: DW_AT_name ("S") +; +; STRICT: DW_TAG_structure_type +; STRICT-NEXT: DW_AT_name ("T") %struct.S = type { i8 } %struct.T = type { i8 }