Index: llvm/trunk/include/llvm/CodeGen/CommandFlags.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/CommandFlags.h +++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h @@ -256,6 +256,17 @@ 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 @@ Options.ThreadModel = TMModel; Options.EABIVersion = EABIVersion; + Options.DebuggerTuning = DebuggerTuningOpt; return Options; } Index: llvm/trunk/include/llvm/Target/TargetOptions.h =================================================================== --- llvm/trunk/include/llvm/Target/TargetOptions.h +++ llvm/trunk/include/llvm/Target/TargetOptions.h @@ -66,6 +66,30 @@ 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 @@ 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 @@ /// 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 @@ ARE_EQUAL(JTType) && ARE_EQUAL(ThreadModel) && ARE_EQUAL(EABIVersion) && + ARE_EQUAL(DebuggerTuning) && ARE_EQUAL(MCOptions); #undef ARE_EQUAL } Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ llvm/trunk/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 @@ 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. Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -77,17 +77,6 @@ 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 @@ 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())