Author: probinson Date: Thu Sep 28 11:37:02 2017 New Revision: 314444 URL: http://llvm.org/viewvc/llvm-project?rev=314444&view=rev Log: [DWARF] Allow forward declarations of a class template instantiation to have child entries describing the template parameters. This will be on by default for SCE tuning.
Differential Revision: https://reviews.llvm.org/D14358 Added: cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp Modified: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=314444&r1=314443&r2=314444&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Sep 28 11:37:02 2017 @@ -200,6 +200,9 @@ def arange_sections : Flag<["-"], "arang def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">, HelpText<"Generate debug info with external references to clang modules" " or precompiled headers">; +def debug_forward_template_params : Flag<["-"], "debug-forward-template-params">, + HelpText<"Emit complete descriptions of template parameters in forward" + " declarations">; def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">, HelpText<"Emit an error if a C++ static local initializer would need a guard variable">; def no_implicit_float : Flag<["-"], "no-implicit-float">, Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=314444&r1=314443&r2=314444&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Sep 28 11:37:02 2017 @@ -219,6 +219,10 @@ CODEGENOPT(EnableSplitDwarf, 1, 0) ///< CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the ///< skeleton CU to allow for symbolication ///< of inline stack frames without .dwo files. +CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete + ///< template parameter descriptions in + ///< forward declarations (versus just + ///< including them in the name). CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=314444&r1=314443&r2=314444&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 28 11:37:02 2017 @@ -833,6 +833,10 @@ CGDebugInfo::getOrCreateRecordFwdDecl(co llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType( getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName); + if (CGM.getCodeGenOpts().DebugFwdTemplateParams) + if (auto *TSpecial = dyn_cast<ClassTemplateSpecializationDecl>(RD)) + DBuilder.replaceArrays(RetTy, llvm::DINodeArray(), + CollectCXXTemplateParams(TSpecial, DefUnit)); ReplaceMap.emplace_back( std::piecewise_construct, std::make_tuple(Ty), std::make_tuple(static_cast<llvm::Metadata *>(RetTy))); Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=314444&r1=314443&r2=314444&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep 28 11:37:02 2017 @@ -2969,6 +2969,11 @@ static void RenderDebugOptions(const Too CmdArgs.push_back("-generate-type-units"); } + // Decide how to render forward declarations of template instantiations. + // SCE wants full descriptions, others just get them in the name. + if (DebuggerTuning == llvm::DebuggerKind::SCE) + CmdArgs.push_back("-debug-forward-template-params"); + RenderDebugInfoCompressionArgs(Args, CmdArgs, D); } Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=314444&r1=314443&r2=314444&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Sep 28 11:37:02 2017 @@ -528,6 +528,7 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); Opts.DebugExplicitImport = Triple.isPS4CPU(); + Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params); for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) Opts.DebugPrefixMap.insert(StringRef(Arg).split('=')); Added: cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp?rev=314444&view=auto ============================================================================== --- cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp (added) +++ cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp Thu Sep 28 11:37:02 2017 @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -debug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=CHILD %s +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -emit-llvm -o - | FileCheck --check-prefix=NONE %s +// A DWARF forward declaration of a template instantiation should have template +// parameter children (if we ask for them). + +template<typename T> class A; +A<int> *p; + +// CHILD: !DICompositeType(tag: DW_TAG_class_type, name: "A<int>" +// CHILD-SAME: flags: DIFlagFwdDecl +// CHILD-SAME: templateParams: [[PARAM_LIST:![0-9]*]] +// CHILD: [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]} +// CHILD: [[PARAM]] = !DITemplateTypeParameter(name: "T", +// CHILD-SAME: type: [[BTYPE:![0-9]*]] +// CHILD: [[BTYPE]] = !DIBasicType(name: "int" + +// NONE: !DICompositeType(tag: DW_TAG_class_type, name: "A<int>" +// NONE-SAME: flags: DIFlagFwdDecl +// NONE-NOT: templateParams: +// NONE-SAME: ) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits