From 23c4c62511ff7846af251d2a7ac0cd8c6a558f6b Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Wed, 16 Dec 2015 19:58:30 +0000 Subject: [PATCH] Set debugger tuning from TargetOptions (NFC) Differential Revision: http://reviews.llvm.org/D15427 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255810 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/CommandFlags.h | 12 +++++++++++ include/llvm/Target/TargetOptions.h | 30 ++++++++++++++++++++++++++- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 17 +++------------ lib/CodeGen/AsmPrinter/DwarfDebug.h | 25 +--------------------- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/include/llvm/CodeGen/CommandFlags.h b/include/llvm/CodeGen/CommandFlags.h index bc70a447af2..0d37dc00422 100644 --- a/include/llvm/CodeGen/CommandFlags.h +++ b/include/llvm/CodeGen/CommandFlags.h @@ -256,6 +256,17 @@ cl::opt EABIVersion( clEnumValN(EABI::EABI5, "5", "EABI version 5"), clEnumValN(EABI::GNU, "gnu", "EABI GNU"), clEnumValEnd)); +cl::opt +DebuggerTuningOpt("debugger-tune", + cl::desc("Tune debug info for a particular debugger"), + cl::init(DebuggerKind::Default), + cl::values( + clEnumValN(DebuggerKind::GDB, "gdb", "gdb"), + clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"), + clEnumValN(DebuggerKind::SCE, "sce", + "SCE targets (e.g. PS4)"), + clEnumValEnd)); + // Common utility function tightly tied to the options listed here. Initializes // a TargetOptions object with CodeGen flags and returns it. static inline TargetOptions InitTargetOptionsFromCodeGenFlags() { @@ -285,6 +296,7 @@ static inline TargetOptions InitTargetOptionsFromCodeGenFlags() { Options.ThreadModel = TMModel; Options.EABIVersion = EABIVersion; + Options.DebuggerTuning = DebuggerTuningOpt; return Options; } diff --git a/include/llvm/Target/TargetOptions.h b/include/llvm/Target/TargetOptions.h index af5a45a856c..d98d0fa0ed5 100644 --- a/include/llvm/Target/TargetOptions.h +++ b/include/llvm/Target/TargetOptions.h @@ -66,6 +66,30 @@ namespace llvm { GNU }; + /// Identify a debugger for "tuning" the debug info. + /// + /// The "debugger tuning" concept allows us to present a more intuitive + /// interface that unpacks into different sets of defaults for the various + /// individual feature-flag settings, that suit the preferences of the + /// various debuggers. However, it's worth remembering that debuggers are + /// not the only consumers of debug info, and some variations in DWARF might + /// better be treated as target/platform issues. Fundamentally, + /// o if the feature is useful (or not) to a particular debugger, regardless + /// of the target, that's a tuning decision; + /// o if the feature is useful (or not) on a particular platform, regardless + /// of the debugger, that's a target decision. + /// It's not impossible to see both factors in some specific case. + /// + /// The "tuning" should be used to set defaults for individual feature flags + /// in DwarfDebug; if a given feature has a more specific command-line option, + /// that option should take precedence over the tuning. + enum class DebuggerKind { + Default, // No specific tuning requested. + GDB, // Tune debug info for gdb. + LLDB, // Tune debug info for lldb. + SCE // Tune debug info for SCE targets (e.g. PS4). + }; + class TargetOptions { public: TargetOptions() @@ -80,7 +104,7 @@ namespace llvm { EmulatedTLS(false), FloatABIType(FloatABI::Default), AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()), JTType(JumpTable::Single), ThreadModel(ThreadModel::POSIX), - EABIVersion(EABI::Default) {} + EABIVersion(EABI::Default), DebuggerTuning(DebuggerKind::Default) {} /// PrintMachineCode - This flag is enabled when the -print-machineinstrs /// option is specified on the command line, and should enable debugging @@ -221,6 +245,9 @@ namespace llvm { /// EABIVersion - This flag specifies the EABI version EABI EABIVersion; + /// Which debugger to tune for. + DebuggerKind DebuggerTuning; + /// Machine level options. MCTargetOptions MCOptions; }; @@ -250,6 +277,7 @@ inline bool operator==(const TargetOptions &LHS, ARE_EQUAL(JTType) && ARE_EQUAL(ThreadModel) && ARE_EQUAL(EABIVersion) && + ARE_EQUAL(DebuggerTuning) && ARE_EQUAL(MCOptions); #undef ARE_EQUAL } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 477ebe1d638..3466f3469f1 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -77,17 +77,6 @@ static cl::opt GenerateARangeSection("generate-arange-section", cl::desc("Generate dwarf aranges"), cl::init(false)); -static cl::opt -DebuggerTuningOpt("debugger-tune", - cl::desc("Tune debug info for a particular debugger"), - cl::init(DebuggerKind::Default), - cl::values( - clEnumValN(DebuggerKind::GDB, "gdb", "gdb"), - clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"), - clEnumValN(DebuggerKind::SCE, "sce", - "SCE targets (e.g. PS4)"), - clEnumValEnd)); - namespace { enum DefaultOnOff { Default, Enable, Disable }; } @@ -228,10 +217,10 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) CurMI = nullptr; Triple TT(Asm->getTargetTriple()); - // Make sure we know our "debugger tuning." The command-line option takes + // Make sure we know our "debugger tuning." The target option takes // precedence; fall back to triple-based defaults. - if (DebuggerTuningOpt != DebuggerKind::Default) - DebuggerTuning = DebuggerTuningOpt; + if (Asm->TM.Options.DebuggerTuning != DebuggerKind::Default) + DebuggerTuning = Asm->TM.Options.DebuggerTuning; else if (IsDarwin || TT.isOSFreeBSD()) DebuggerTuning = DebuggerKind::LLDB; else if (TT.isPS4CPU()) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index a0c60efd993..4c613a90545 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -33,6 +33,7 @@ #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MachineLocation.h" #include "llvm/Support/Allocator.h" +#include "llvm/Target/TargetOptions.h" #include namespace llvm { @@ -186,30 +187,6 @@ struct SymbolCU { DwarfCompileUnit *CU; }; -/// Identify a debugger for "tuning" the debug info. -/// -/// The "debugger tuning" concept allows us to present a more intuitive -/// interface that unpacks into different sets of defaults for the various -/// individual feature-flag settings, that suit the preferences of the -/// various debuggers. However, it's worth remembering that debuggers are -/// not the only consumers of debug info, and some variations in DWARF might -/// better be treated as target/platform issues. Fundamentally, -/// o if the feature is useful (or not) to a particular debugger, regardless -/// of the target, that's a tuning decision; -/// o if the feature is useful (or not) on a particular platform, regardless -/// of the debugger, that's a target decision. -/// It's not impossible to see both factors in some specific case. -/// -/// The "tuning" should be used to set defaults for individual feature flags -/// in DwarfDebug; if a given feature has a more specific command-line option, -/// that option should take precedence over the tuning. -enum class DebuggerKind { - Default, // No specific tuning requested. - GDB, // Tune debug info for gdb. - LLDB, // Tune debug info for lldb. - SCE // Tune debug info for SCE targets (e.g. PS4). -}; - /// Collects and handles dwarf debug information. class DwarfDebug : public AsmPrinterHandler { /// Target of Dwarf emission. -- 2.34.1