[PATCH] D90507: Adding DWARF64 clang flag: -gdwarf64
Alexander Yermolovich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 19 10:48:04 PST 2020
ayermolo updated this revision to Diff 306477.
ayermolo marked 3 inline comments as done.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90507/new/
https://reviews.llvm.org/D90507
Files:
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/debug-options.c
Index: clang/test/Driver/debug-options.c
===================================================================
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -375,3 +375,16 @@
// RUN: | FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind={{limited|line-tables-only|standalone}}"
// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+//
+// RUN: %clang -### -gdwarf-5 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-3 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-2 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | FileCheck -check-prefix=GDWARF64_OFF %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target x86_64-linux-gnu -target x86_64-linux-gnu %s 2>&1 \
+// RUN: | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target i386-linux-gnu %s 2>&1 \
+// RUN: | FileCheck -check-prefix=GDWARF64_32ARCH %s
+//
+// GDWARF64_ON: "-gdwarf64"
+// GDWARF64_OFF: error: invalid argument '-gdwarf64' only allowed with 'DWARVv3 or greater'
+// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1005,6 +1005,7 @@
Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
Opts.AsmVerbose = !Args.hasArg(OPT_fno_verbose_asm);
+ Opts.Dwarf64 = Args.hasArg(OPT_gdwarf64);
Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4015,6 +4015,22 @@
if (DebuggerTuning == llvm::DebuggerKind::SCE)
CmdArgs.push_back("-dwarf-explicit-import");
+ if (Args.hasArg(options::OPT_gdwarf64)) {
+ const Arg *A = Args.getLastArg(options::OPT_gdwarf64);
+ const llvm::Triple &RawTriple = TC.getTriple();
+ if (DWARFVersion < 3)
+ D.Diag(diag::err_drv_argument_only_allowed_with)
+ << A->getAsString(Args) << "DWARVv3 or greater";
+ else if (!RawTriple.isArch64Bit())
+ D.Diag(diag::err_drv_argument_only_allowed_with)
+ << A->getAsString(Args) << "64 bit architecture";
+ else if (!RawTriple.isOSBinFormatELF())
+ D.Diag(diag::err_drv_argument_only_allowed_with)
+ << A->getAsString(Args) << "elf output format";
+ else
+ CmdArgs.push_back("-gdwarf64");
+ }
+
RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
}
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -563,6 +563,7 @@
Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
Options.MCOptions.MCNoWarn = CodeGenOpts.NoWarn;
Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+ Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64;
Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
Options.MCOptions.ABIName = TargetOpts.ABI;
for (const auto &Entry : HSOpts.UserEntries)
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2142,6 +2142,8 @@
HelpText<"Generate source-level debug information with dwarf version 4">;
def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 5">;
+def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>, Flags<[CC1Option]>,
+ HelpText<"Enables DWARF64 format for ELF binaries, if debug information emission is enabled.">;
def gcodeview : Flag<["-"], "gcodeview">,
HelpText<"Generate CodeView debug information">,
Index: clang/include/clang/Basic/CodeGenOptions.def
===================================================================
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -32,6 +32,7 @@
llvm::DebugCompressionType::None)
CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(Dwarf64 , 1, 0) ///< -gdwarf64.
CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90507.306477.patch
Type: text/x-patch
Size: 5176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201119/a134b7f9/attachment.bin>
More information about the cfe-commits
mailing list