summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-02-22 20:12:52 +0000
committerEric Christopher <echristo@gmail.com>2013-02-22 20:12:52 +0000
commitd380400b1787d7eab9ec991e053cef562198ad48 (patch)
treeff505179ea6c5195d7c84cb9c488b8c6facc3b60 /clang/lib
parentc358da2f4bda5faf1a9fa72706a485acaa04551d (diff)
downloadbcm5719-llvm-d380400b1787d7eab9ec991e053cef562198ad48.tar.gz
bcm5719-llvm-d380400b1787d7eab9ec991e053cef562198ad48.zip
Split out the command handling for split debug info, we're going
to want to propagate some information through the module into the back end and so need to pass it through to codegen. Also make the methods file static so we can use them in other places. llvm-svn: 175916
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Tools.cpp67
-rw-r--r--clang/lib/Driver/Tools.h4
2 files changed, 39 insertions, 32 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 6ba77c20b04..445ae5358be 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -1705,11 +1705,27 @@ static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
}
}
-void Clang::SplitDebugInfo(Compilation &C, const JobAction &JA,
- const ArgList &Args,
- const InputInfoList &Inputs,
- const InputInfo &Output,
- const char *LinkingOutput) const {
+static const char *SplitDebugName(const ArgList &Args,
+ const InputInfoList &Inputs) {
+ Arg *FinalOutput = Args.getLastArg(options::OPT_o);
+ if (FinalOutput && Args.hasArg(options::OPT_c)) {
+ SmallString<128> T(FinalOutput->getValue());
+ llvm::sys::path::replace_extension(T, "dwo");
+ return Args.MakeArgString(T);
+ } else {
+ // Use the compilation dir.
+ SmallString<128> T(Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
+ SmallString<128> F(llvm::sys::path::stem(Inputs[0].getBaseInput()));
+ llvm::sys::path::replace_extension(F, "dwo");
+ T += F;
+ return Args.MakeArgString(F);
+ }
+}
+
+static void SplitDebugInfo(const ToolChain &TC, Compilation &C,
+ const Tool &T, const JobAction &JA,
+ const ArgList &Args, const InputInfo &Output,
+ const char *OutFile) {
ArgStringList ExtractArgs;
ExtractArgs.push_back("--extract-dwo");
@@ -1719,31 +1735,16 @@ void Clang::SplitDebugInfo(Compilation &C, const JobAction &JA,
// Grabbing the output of the earlier compile step.
StripArgs.push_back(Output.getFilename());
ExtractArgs.push_back(Output.getFilename());
-
- // Add an output for the extract.
- Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o);
- const char *OutFile;
- if (FinalOutput && C.getArgs().hasArg(options::OPT_c)) {
- SmallString<128> T(FinalOutput->getValue());
- llvm::sys::path::replace_extension(T, "dwo");
- OutFile = Args.MakeArgString(T);
- } else {
- // Use the compilation dir.
- SmallString<128> T(Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
- T += llvm::sys::path::stem(Inputs[0].getBaseInput());
- llvm::sys::path::replace_extension(T, "dwo");
- OutFile = Args.MakeArgString(T);
- }
ExtractArgs.push_back(OutFile);
const char *Exec =
- Args.MakeArgString(getToolChain().GetProgramPath("objcopy"));
+ Args.MakeArgString(TC.GetProgramPath("objcopy"));
// First extract the dwo sections.
- C.addCommand(new Command(JA, *this, Exec, ExtractArgs));
+ C.addCommand(new Command(JA, T, Exec, ExtractArgs));
// Then remove them from the original .o file.
- C.addCommand(new Command(JA, *this, Exec, StripArgs));
+ C.addCommand(new Command(JA, T, Exec, StripArgs));
}
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
@@ -3264,15 +3265,25 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(Flags.str()));
}
- // Finally add the command to the compilation.
+ // Add the split debug info name to the command lines here so we
+ // can propagate it to the backend.
+ bool SplitDwarf = Args.hasArg(options::OPT_gsplit_dwarf) &&
+ (getToolChain().getTriple().getOS() == llvm::Triple::Linux) &&
+ isa<AssembleJobAction>(JA);
+ const char *SplitDwarfOut;
+ if (SplitDwarf) {
+ CmdArgs.push_back("-split-dwarf-file");
+ SplitDwarfOut = SplitDebugName(Args, Inputs);
+ CmdArgs.push_back(SplitDwarfOut);
+ }
+
+ // 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.
// TODO: Currently only works on linux with newer objcopy.
- if (Args.hasArg(options::OPT_gsplit_dwarf) &&
- getToolChain().getTriple().getOS() == llvm::Triple::Linux &&
- isa<AssembleJobAction>(JA))
- SplitDebugInfo(C, JA, Args, Inputs, Output, LinkingOutput);
+ if (SplitDwarf)
+ SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDwarfOut);
if (Arg *A = Args.getLastArg(options::OPT_pg))
if (Args.hasArg(options::OPT_fomit_frame_pointer))
diff --git a/clang/lib/Driver/Tools.h b/clang/lib/Driver/Tools.h
index 2d7f8b09626..f4aebd8bd25 100644
--- a/clang/lib/Driver/Tools.h
+++ b/clang/lib/Driver/Tools.h
@@ -54,10 +54,6 @@ namespace tools {
void AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddHexagonTargetArgs (const ArgList &Args, ArgStringList &CmdArgs) const;
- void SplitDebugInfo(Compilation &C, const JobAction &JA,
- const ArgList &Args, const InputInfoList &Inputs,
- const InputInfo &Output,
- const char *LinkingOutput) const;
enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
OpenPOWER on IntegriCloud