From owner-svn-src-all@FreeBSD.ORG Sat May 16 23:00:07 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3DEB8729; Sat, 16 May 2015 23:00:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2A2EB1EC8; Sat, 16 May 2015 23:00:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4GN07UF057765; Sat, 16 May 2015 23:00:07 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4GN04OD057735; Sat, 16 May 2015 23:00:04 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201505162300.t4GN04OD057735@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 16 May 2015 23:00:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r283019 - in stable/9/contrib/llvm: include/llvm lib/CodeGen/AsmPrinter lib/Target/ARM tools/clang/include/clang/Driver tools/clang/include/clang/Frontend tools/clang/lib/CodeGen tools/... X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2015 23:00:07 -0000 Author: dim Date: Sat May 16 23:00:03 2015 New Revision: 283019 URL: https://svnweb.freebsd.org/changeset/base/283019 Log: Bring clang 3.4.1 in stable/9 in sync with the version in stable/10. MFC r252503 (by andrew): Work around an ARM EABI issue where clang would sometimes incorrectly align the stack in a leaf function that uses TLS. The issue is, when using TLS, the function is no longer a leaf as it calls __aeabi_read_tp. With statically linked programs this is not an issue as it doesn't make use of the stack, however with dynamically linked applications we enter rtld which does use the stack and makes assumptions about it's alignment. This is only a temporary fix until a better patch can be made and submitted upstream. MFC r264826 (by emaste): Merge LLVM r202188: Debug info: Support variadic functions. Variadic functions have an unspecified parameter tag after the last argument. In IR this is represented as an unspecified parameter in the subroutine type. Paired commit with CFE r202185. rdar://problem/13690847 This re-applies r202184 + a bugfix in DwarfDebug's argument handling. This merge includes a change to use the LLVM 3.4 API in lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp: DwarfUnit -> CompileUnit Sponsored by: DARPA, AFRL MFC r264827 (by emaste): Merge Clang r202185: Debug info: Generate debug info for variadic functions. Paired commit with LLVM. rdar://problem/13690847 This merege includes changes to use the Clang 3.4 API (revisions 199686 and 200082) in lib/CodeGen/CGDebugInfo.cpp: getParamType -> getArgType getNumParams -> getNumArgs getReturnType -> getResultType Sponsored by: DARPA, AFRL MFC r265477 (by emaste): Merge -fstandalone-debug from Clang r198655: Implement a new -fstandalone-debug option. rdar://problem/15685848 It controls everything that -flimit-debug-info used to, plus the vtable type optimization. The old -fno-limit-debug-info option is now an alias to -fstandalone-debug and vice versa. Standalone is the default on Darwin until dtrace is updated to work with non-standalone debug info (rdar://problem/15758808). Note: I kept the LimitedDebugInfo name in CodeGenOptions::DebugInfoKind because NoStandaloneDebugInfo sounded even more confusing. MFC r269387 (by andrew): Update the ARMv6 core clang targets to be an arm1176jzf-s. This brings us in line with gcc in base as this makes llvm generate code for the armv6k variant of the instruction set. Modified: stable/9/contrib/llvm/include/llvm/DIBuilder.h stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp stable/9/contrib/llvm/lib/Target/ARM/ARMFrameLowering.h stable/9/contrib/llvm/tools/clang/include/clang/Driver/Options.td stable/9/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h stable/9/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp stable/9/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp stable/9/contrib/llvm/tools/clang/lib/Driver/Tools.cpp stable/9/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp Directory Properties: stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/llvm/ (props changed) stable/9/contrib/llvm/tools/clang/ (props changed) Modified: stable/9/contrib/llvm/include/llvm/DIBuilder.h ============================================================================== --- stable/9/contrib/llvm/include/llvm/DIBuilder.h Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/include/llvm/DIBuilder.h Sat May 16 23:00:03 2015 (r283019) @@ -439,7 +439,7 @@ namespace llvm { /// through debug info anchors. void retainType(DIType T); - /// createUnspecifiedParameter - Create unspeicified type descriptor + /// createUnspecifiedParameter - Create unspecified type descriptor /// for a subroutine type. DIDescriptor createUnspecifiedParameter(); Modified: stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp ============================================================================== --- stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Sat May 16 23:00:03 2015 (r283019) @@ -1116,6 +1116,22 @@ void CompileUnit::constructTypeDIE(DIE & addSourceLine(&Buffer, DTy); } +/// constructSubprogramArguments - Construct function argument DIEs. +void CompileUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) { + for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { + DIDescriptor Ty = Args.getElement(i); + if (Ty.isUnspecifiedParameter()) { + assert(i == N-1 && "ellipsis must be the last argument"); + createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer); + } else { + DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer); + addType(Arg, DIType(Ty)); + if (DIType(Ty).isArtificial()) + addFlag(Arg, dwarf::DW_AT_artificial); + } + } +} + /// Return true if the type is appropriately scoped to be contained inside /// its own type unit. static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) { @@ -1170,19 +1186,12 @@ void CompileUnit::constructTypeDIE(DIE & addType(&Buffer, RTy); bool isPrototyped = true; - // Add arguments. - for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) { - DIDescriptor Ty = Elements.getElement(i); - if (Ty.isUnspecifiedParameter()) { - createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer); - isPrototyped = false; - } else { - DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer); - addType(Arg, DIType(Ty)); - if (DIType(Ty).isArtificial()) - addFlag(Arg, dwarf::DW_AT_artificial); - } - } + if (Elements.getNumElements() == 2 && + Elements.getElement(1).isUnspecifiedParameter()) + isPrototyped = false; + + constructSubprogramArguments(Buffer, Elements); + // Add prototype flag if we're dealing with a C language and the // function has been prototyped. uint16_t Language = getLanguage(); @@ -1475,13 +1484,7 @@ DIE *CompileUnit::getOrCreateSubprogramD // Add arguments. Do not add arguments for subprogram definition. They will // be handled while processing variables. - for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { - DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie); - DIType ATy(Args.getElement(i)); - addType(Arg, ATy); - if (ATy.isArtificial()) - addFlag(Arg, dwarf::DW_AT_artificial); - } + constructSubprogramArguments(*SPDie, Args); } if (SP.isArtificial()) Modified: stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h ============================================================================== --- stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Sat May 16 23:00:03 2015 (r283019) @@ -342,6 +342,9 @@ public: void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym); private: + /// constructSubprogramArguments - Construct function argument DIEs. + void constructSubprogramArguments(DIE &Buffer, DIArray Args); + /// constructTypeDIE - Construct basic type die from DIBasicType. void constructTypeDIE(DIE &Buffer, DIBasicType BTy); Modified: stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp ============================================================================== --- stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat May 16 23:00:03 2015 (r283019) @@ -404,15 +404,21 @@ DIE *DwarfDebug::updateSubprogramScopeDI DIArray Args = SPTy.getTypeArray(); uint16_t SPTag = SPTy.getTag(); if (SPTag == dwarf::DW_TAG_subroutine_type) + // FIXME: Use DwarfUnit::constructSubprogramArguments() here. for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { - DIE *Arg = - SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie); DIType ATy(Args.getElement(i)); - SPCU->addType(Arg, ATy); - if (ATy.isArtificial()) - SPCU->addFlag(Arg, dwarf::DW_AT_artificial); - if (ATy.isObjectPointer()) - SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg); + if (ATy.isUnspecifiedParameter()) { + assert(i == N-1 && "ellipsis must be the last argument"); + SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie); + } else { + DIE *Arg = + SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie); + SPCU->addType(Arg, ATy); + if (ATy.isArtificial()) + SPCU->addFlag(Arg, dwarf::DW_AT_artificial); + if (ATy.isObjectPointer()) + SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg); + } } DIE *SPDeclDie = SPDie; SPDie = @@ -579,7 +585,7 @@ DIE *DwarfDebug::createScopeChildrenDIE( DIE *ObjectPointer = NULL; // Collect arguments for current function. - if (LScopes.isCurrentFunctionScope(Scope)) + if (LScopes.isCurrentFunctionScope(Scope)) { for (unsigned i = 0, N = CurrentFnArguments.size(); i < N; ++i) if (DbgVariable *ArgDV = CurrentFnArguments[i]) if (DIE *Arg = @@ -588,6 +594,16 @@ DIE *DwarfDebug::createScopeChildrenDIE( if (ArgDV->isObjectPointer()) ObjectPointer = Arg; } + // Create the unspecified parameter that marks a function as variadic. + DISubprogram SP(Scope->getScopeNode()); + assert(SP.Verify()); + DIArray FnArgs = SP.getType().getTypeArray(); + if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) { + DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters); + Children.push_back(Ellipsis); + } + } + // Collect lexical scope children first. const SmallVectorImpl &Variables =ScopeVariables.lookup(Scope); for (unsigned i = 0, N = Variables.size(); i < N; ++i) Modified: stable/9/contrib/llvm/lib/Target/ARM/ARMFrameLowering.h ============================================================================== --- stable/9/contrib/llvm/lib/Target/ARM/ARMFrameLowering.h Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/lib/Target/ARM/ARMFrameLowering.h Sat May 16 23:00:03 2015 (r283019) @@ -27,7 +27,7 @@ protected: public: explicit ARMFrameLowering(const ARMSubtarget &sti) - : TargetFrameLowering(StackGrowsDown, sti.getStackAlignment(), 0, 4), + : TargetFrameLowering(StackGrowsDown, sti.getStackAlignment(), 0, 8), STI(sti) { } Modified: stable/9/contrib/llvm/tools/clang/include/clang/Driver/Options.td ============================================================================== --- stable/9/contrib/llvm/tools/clang/include/clang/Driver/Options.td Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/tools/clang/include/clang/Driver/Options.td Sat May 16 23:00:03 2015 (r283019) @@ -549,8 +549,6 @@ def finstrument_functions : Flag<["-"], def fkeep_inline_functions : Flag<["-"], "fkeep-inline-functions">, Group; def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; -def flimit_debug_info : Flag<["-"], "flimit-debug-info">, Group, Flags<[CC1Option]>, - HelpText<"Limit debug information produced to reduce size of debug binary">; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; def flto : Flag<["-"], "flto">, Group; def fno_lto : Flag<["-"], "fno-lto">, Group; @@ -645,8 +643,6 @@ def fno_inline : Flag<["-"], "fno-inline def fno_keep_inline_functions : Flag<["-"], "fno-keep-inline-functions">, Group; def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group, HelpText<"Disallow implicit conversions between vectors with a different number of elements or different element types">, Flags<[CC1Option]>; -def fno_limit_debug_info : Flag<["-"], "fno-limit-debug-info">, Group, Flags<[CC1Option]>, - HelpText<"Do not limit debug information produced to reduce size of debug binary">; def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, Group, Flags<[CC1Option]>, HelpText<"Disallow merging of constants">; def fno_modules : Flag <["-"], "fno-modules">, Group, @@ -774,6 +770,12 @@ def fno_signed_char : Flag<["-"], "fno-s def fsplit_stack : Flag<["-"], "fsplit-stack">, Group; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group; def fstack_protector : Flag<["-"], "fstack-protector">, Group; +def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, Flags<[CC1Option]>, + HelpText<"Emit full debug info for all types used by the program">; +def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, Group, Flags<[CC1Option]>, + HelpText<"Limit debug information produced to reduce size of debug binary">; +def flimit_debug_info : Flag<["-"], "flimit-debug-info">, Alias; +def fno_limit_debug_info : Flag<["-"], "fno-limit-debug-info">, Alias; def fstrict_aliasing : Flag<["-"], "fstrict-aliasing">, Group; def fstrict_enums : Flag<["-"], "fstrict-enums">, Group, Flags<[CC1Option]>, HelpText<"Enable optimizations based on the strict definition of an enum's " Modified: stable/9/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h ============================================================================== --- stable/9/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h Sat May 16 23:00:03 2015 (r283019) @@ -50,12 +50,20 @@ public: }; enum DebugInfoKind { - NoDebugInfo, // Don't generate debug info. - DebugLineTablesOnly, // Emit only debug info necessary for generating - // line number tables (-gline-tables-only). - LimitedDebugInfo, // Limit generated debug info to reduce size - // (-flimit-debug-info). - FullDebugInfo // Generate complete debug info. + NoDebugInfo, /// Don't generate debug info. + + DebugLineTablesOnly, /// Emit only debug info necessary for generating + /// line number tables (-gline-tables-only). + + LimitedDebugInfo, /// Limit generated debug info to reduce size + /// (-fno-standalone-debug). This emits + /// forward decls for types that could be + /// replaced with forward decls in the source + /// code. For dynamic C++ classes type info + /// is only emitted int the module that + /// contains the classe's vtable. + + FullDebugInfo /// Generate complete debug info. }; enum TLSModel { Modified: stable/9/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp ============================================================================== --- stable/9/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp Sat May 16 23:00:03 2015 (r283019) @@ -37,7 +37,7 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/Path.h" +#include "llvm/Support/Path.h" using namespace clang; using namespace clang::CodeGen; @@ -342,9 +342,9 @@ void CGDebugInfo::CreateCompileUnit() { if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) { MainFileDir = MainFile->getDir()->getName(); if (MainFileDir != ".") { - llvm::SmallString<1024> MainFileDirSS(MainFileDir); - llvm::sys::path::append(MainFileDirSS, MainFileName); - MainFileName = MainFileDirSS.str(); + llvm::SmallString<1024> MainFileDirSS(MainFileDir); + llvm::sys::path::append(MainFileDirSS, MainFileName); + MainFileName = MainFileDirSS.str(); } } @@ -760,6 +760,8 @@ llvm::DIType CGDebugInfo::CreateType(con else if (const FunctionProtoType *FPT = dyn_cast(Ty)) { for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i) EltTys.push_back(getOrCreateType(FPT->getArgType(i), Unit)); + if (FPT->isVariadic()) + EltTys.push_back(DBuilder.createUnspecifiedParameter()); } llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys); @@ -1454,13 +1456,13 @@ llvm::DIType CGDebugInfo::CreateType(con // declaration. The completeType, completeRequiredType, and completeClassData // callbacks will handle promoting the declaration to a definition. if (T || + // Under -flimit-debug-info: (DebugKind <= CodeGenOptions::LimitedDebugInfo && - // Under -flimit-debug-info, emit only a declaration unless the type is - // required to be complete. - !RD->isCompleteDefinitionRequired() && CGM.getLangOpts().CPlusPlus) || - // If the class is dynamic, only emit a declaration. A definition will be - // emitted whenever the vtable is emitted. - (CXXDecl && CXXDecl->hasDefinition() && CXXDecl->isDynamicClass()) || T) { + // Emit only a forward declaration unless the type is required. + ((!RD->isCompleteDefinitionRequired() && CGM.getLangOpts().CPlusPlus) || + // If the class is dynamic, only emit a declaration. A definition will be + // emitted whenever the vtable is emitted. + (CXXDecl && CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())))) { llvm::DIDescriptor FDContext = getContextDescriptor(cast(RD->getDeclContext())); if (!T) @@ -2421,6 +2423,20 @@ llvm::DICompositeType CGDebugInfo::getOr llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts); return DBuilder.createSubroutineType(F, EltTypeArray); } + + // Variadic function. + if (const FunctionDecl *FD = dyn_cast(D)) + if (FD->isVariadic()) { + SmallVector EltTys; + EltTys.push_back(getOrCreateType(FD->getResultType(), F)); + if (const FunctionProtoType *FPT = dyn_cast(FnType)) + for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i) + EltTys.push_back(getOrCreateType(FPT->getArgType(i), F)); + EltTys.push_back(DBuilder.createUnspecifiedParameter()); + llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys); + return DBuilder.createSubroutineType(F, EltTypeArray); + } + return llvm::DICompositeType(getOrCreateType(FnType, F)); } Modified: stable/9/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp ============================================================================== --- stable/9/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp Sat May 16 23:00:03 2015 (r283019) @@ -208,7 +208,8 @@ static const char *getARMTargetCPU(const MArch = Triple.getArchName(); } - if (Triple.getOS() == llvm::Triple::NetBSD) { + if (Triple.getOS() == llvm::Triple::NetBSD || + Triple.getOS() == llvm::Triple::FreeBSD) { if (MArch == "armv6") return "arm1176jzf-s"; } Modified: stable/9/contrib/llvm/tools/clang/lib/Driver/Tools.cpp ============================================================================== --- stable/9/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Sat May 16 23:00:03 2015 (r283019) @@ -499,7 +499,8 @@ static std::string getARMTargetCPU(const MArch = Triple.getArchName(); } - if (Triple.getOS() == llvm::Triple::NetBSD) { + if (Triple.getOS() == llvm::Triple::NetBSD || + Triple.getOS() == llvm::Triple::FreeBSD) { if (MArch == "armv6") return "arm1176jzf-s"; } @@ -2988,8 +2989,8 @@ void Clang::ConstructJob(Compilation &C, Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls); Args.AddLastArg(CmdArgs, options::OPT_fformat_extensions); Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); - Args.AddLastArg(CmdArgs, options::OPT_flimit_debug_info); - Args.AddLastArg(CmdArgs, options::OPT_fno_limit_debug_info); + Args.AddLastArg(CmdArgs, options::OPT_fstandalone_debug); + Args.AddLastArg(CmdArgs, options::OPT_fno_standalone_debug); Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); // AltiVec language extensions aren't relevant for assembling. if (!isa(JA) || Modified: stable/9/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp ============================================================================== --- stable/9/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp Sat May 16 22:53:26 2015 (r283018) +++ stable/9/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp Sat May 16 23:00:03 2015 (r283019) @@ -295,7 +295,8 @@ static void ParseCommentArgs(CommentOpti } static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, - DiagnosticsEngine &Diags) { + DiagnosticsEngine &Diags, + const TargetOptions &TargetOpts) { using namespace options; bool Success = true; @@ -322,10 +323,16 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.setDebugInfo(CodeGenOptions::DebugLineTablesOnly); } else if (Args.hasArg(OPT_g_Flag) || Args.hasArg(OPT_gdwarf_2) || Args.hasArg(OPT_gdwarf_3) || Args.hasArg(OPT_gdwarf_4)) { - if (Args.hasFlag(OPT_flimit_debug_info, OPT_fno_limit_debug_info, true)) - Opts.setDebugInfo(CodeGenOptions::LimitedDebugInfo); - else + bool Default = false; + // Until dtrace (via CTF) can deal with distributed debug info, + // Darwin defaults to standalone/full debug info. + if (llvm::Triple(TargetOpts.Triple).isOSDarwin()) + Default = true; + + if (Args.hasFlag(OPT_fstandalone_debug, OPT_fno_standalone_debug, Default)) Opts.setDebugInfo(CodeGenOptions::FullDebugInfo); + else + Opts.setDebugInfo(CodeGenOptions::LimitedDebugInfo); } Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); @@ -1657,8 +1664,9 @@ bool CompilerInvocation::CreateFromArgs( ParseFileSystemArgs(Res.getFileSystemOpts(), *Args); // FIXME: We shouldn't have to pass the DashX option around here InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), *Args, Diags); - Success = ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, DashX, Diags) - && Success; + ParseTargetArgs(Res.getTargetOpts(), *Args); + Success = ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, DashX, Diags, + Res.getTargetOpts()) && Success; ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), *Args); if (DashX != IK_AST && DashX != IK_LLVM_IR) { ParseLangArgs(*Res.getLangOpts(), *Args, DashX, Diags); @@ -1673,8 +1681,6 @@ bool CompilerInvocation::CreateFromArgs( ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args, FileMgr, Diags); ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args, Res.getFrontendOpts().ProgramAction); - ParseTargetArgs(Res.getTargetOpts(), *Args); - return Success; }