[PATCH] D150181: [XCOFF][DWARF] XCOFF64 should be able to select the dwarf version under intergrated-as mode.
Esme Yi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 9 01:06:35 PDT 2023
Esme created this revision.
Esme added reviewers: shchenz, lkail, PowerPC, DiggerLin.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Esme requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.
DWARF32 is not supported for XCOFF64 under non integrated-as mode, because system assembler will fill the debug section lengths according to DWARF64 format.
While in intergrated-as mode, XCOFF64 should be able to select the DWARF version.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150181
Files:
clang/lib/Driver/ToolChains/Clang.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/XCOFF/dwarf-format.ll
Index: llvm/test/DebugInfo/XCOFF/dwarf-format.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/XCOFF/dwarf-format.ll
@@ -0,0 +1,33 @@
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj %s -o - \
+; RUN: | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefixes=CHECK
+
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj -dwarf64 %s -o - \
+; RUN: | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefixes=CHECK64
+
+; CHECK: file format aix5coff64-rs6000
+; CHECK: format: DWARF32
+
+; CHECK64: file format aix5coff64-rs6000
+; CHECK64: format: DWARF64
+
+source_filename = "1.c"
+target datalayout = "E-m:a-p:32:32-Fi32-i64:64-n32"
+
+ at foo = global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!6, !7, !8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "1.c", directory: "llvm-project")
+!4 = !{!0}
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 7, !"Dwarf Version", i32 3}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{i32 1, !"wchar_size", i32 2}
+!9 = !{i32 8, !"PIC Level", i32 2}
+!10 = !{i32 7, !"frame-pointer", i32 2}
+!11 = !{!"clang version 17.0.0"}
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -389,6 +389,7 @@
DwarfVersion =
TT.isNVPTX() ? 2 : (DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION);
+ bool UseIntegratedAs = Asm->OutStreamer->isIntegratedAssemblerRequired();
bool Dwarf64 = DwarfVersion >= 3 && // DWARF64 was introduced in DWARFv3.
TT.isArch64Bit(); // DWARF64 requires 64-bit relocations.
@@ -396,15 +397,18 @@
// 1: For ELF when requested.
// 2: For XCOFF64: the AIX assembler will fill in debug section lengths
// according to the DWARF64 format for 64-bit assembly, so we must use
- // DWARF64 in the compiler too for 64-bit mode.
+ // DWARF64 in the compiler for 64-bit mode on non-integrated-as mode.
Dwarf64 &=
- ((Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64()) &&
- TT.isOSBinFormatELF()) ||
- TT.isOSBinFormatXCOFF();
-
- if (!Dwarf64 && TT.isArch64Bit() && TT.isOSBinFormatXCOFF())
- report_fatal_error("XCOFF requires DWARF64 for 64-bit mode!");
-
+ ((TT.isOSBinFormatELF() ||
+ (TT.isOSBinFormatXCOFF() && UseIntegratedAs)) &&
+ (Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64())) ||
+ (TT.isOSBinFormatXCOFF() && !UseIntegratedAs);
+
+ if (!Dwarf64 && TT.isArch64Bit() && TT.isOSBinFormatXCOFF() &&
+ !UseIntegratedAs)
+ report_fatal_error(
+ "XCOFF requires DWARF64 for 64-bit mode on non-integrated-as mode!");
+
UseRangesSection = !NoDwarfRangesSection && !TT.isNVPTX();
// Use sections as references. Force for NVPTX.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4131,9 +4131,9 @@
else if (!T.isArch64Bit())
D.Diag(diag::err_drv_argument_only_allowed_with)
<< DwarfFormatArg->getAsString(Args) << "64 bit architecture";
- else if (!T.isOSBinFormatELF())
+ else if (!(T.isOSBinFormatELF() || T.isOSBinFormatXCOFF()))
D.Diag(diag::err_drv_argument_only_allowed_with)
- << DwarfFormatArg->getAsString(Args) << "ELF platforms";
+ << DwarfFormatArg->getAsString(Args) << "ELF/XCOFF platforms";
}
DwarfFormatArg->render(Args, CmdArgs);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150181.520618.patch
Type: text/x-patch
Size: 4110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230509/cda0bcd7/attachment-0001.bin>
More information about the cfe-commits
mailing list