From: Eric Christopher Date: Fri, 22 Feb 2013 23:50:16 +0000 (+0000) Subject: Propagate the split dwarf file information through into the backend X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1545838d7127563b161cfe63d27145c6fe5e982;p=platform%2Fupstream%2Fllvm.git Propagate the split dwarf file information through into the backend and through to the debug info in the module. In order to make the testcase a bit more efficient allow the filename to go through compilation for compile and not assemble jobs and turn off the extract for cases where we don't create an object. llvm-svn: 175935 --- diff --git a/clang/include/clang/Frontend/CodeGenOptions.h b/clang/include/clang/Frontend/CodeGenOptions.h index 7038c39..bda777d 100644 --- a/clang/include/clang/Frontend/CodeGenOptions.h +++ b/clang/include/clang/Frontend/CodeGenOptions.h @@ -102,6 +102,10 @@ public: /// file, for example with -save-temps. std::string MainFileName; + /// The name for the split debug info file that we'll break out. This is used + /// in the backend for setting the name in the skeleton cu. + std::string SplitDwarfFile; + /// The name of the relocation model to use. std::string RelocationModel; diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 235d15f..0dd4d17 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -312,6 +312,12 @@ void CGDebugInfo::CreateCompileUnit() { char *FilenamePtr = DebugInfoNames.Allocate(MainFileName.length()); memcpy(FilenamePtr, MainFileName.c_str(), MainFileName.length()); StringRef Filename(FilenamePtr, MainFileName.length()); + + // Save split dwarf file string. + std::string SplitDwarfFile = CGM.getCodeGenOpts().SplitDwarfFile; + char *SplitDwarfPtr = DebugInfoNames.Allocate(SplitDwarfFile.length()); + memcpy(SplitDwarfPtr, SplitDwarfFile.c_str(), SplitDwarfFile.length()); + StringRef SplitDwarfFilename(SplitDwarfPtr, SplitDwarfFile.length()); unsigned LangTag; const LangOptions &LO = CGM.getLangOpts(); @@ -338,7 +344,8 @@ void CGDebugInfo::CreateCompileUnit() { // Create new compile unit. DBuilder.createCompileUnit(LangTag, Filename, getCurrentDirname(), Producer, LO.Optimize, - CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers); + CGM.getCodeGenOpts().DwarfDebugFlags, + RuntimeVers, SplitDwarfFilename); // FIXME - Eliminate TheCU. TheCU = llvm::DICompileUnit(DBuilder.getCU()); } diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 12833a8..ce005d0 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -3269,7 +3269,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // can propagate it to the backend. bool SplitDwarf = Args.hasArg(options::OPT_gsplit_dwarf) && (getToolChain().getTriple().getOS() == llvm::Triple::Linux) && - isa(JA); + (isa(JA) || isa(JA)); const char *SplitDwarfOut; if (SplitDwarf) { CmdArgs.push_back("-split-dwarf-file"); @@ -3280,9 +3280,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Finally add the compile command to the compilation. C.addCommand(new Command(JA, *this, Exec, CmdArgs)); - // Handle the debug info splitting at object creation time. + // Handle the debug info splitting at object creation time if we're + // creating an object. // TODO: Currently only works on linux with newer objcopy. - if (SplitDwarf) + if (SplitDwarf && !isa(JA)) SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDwarfOut); if (Arg *A = Args.getLastArg(options::OPT_pg)) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 21188c3..d856c31 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -315,6 +315,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.setDebugInfo(CodeGenOptions::FullDebugInfo); } Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); + Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); Opts.ModulesAutolink = Args.hasArg(OPT_fmodules_autolink); Opts.DisableLLVMOpts = Args.hasArg(OPT_disable_llvm_optzns);