r175813 - Remove the SplitDebug action and replace with a set of commands

Eric Christopher echristo at gmail.com
Thu Feb 21 14:35:01 PST 2013


Author: echristo
Date: Thu Feb 21 16:35:01 2013
New Revision: 175813

URL: http://llvm.org/viewvc/llvm-project?rev=175813&view=rev
Log:
Remove the SplitDebug action and replace with a set of commands
in the compilation setup. Note that this doesn't currently
work for -no-integrated-as.

Modified:
    cfe/trunk/include/clang/Driver/Action.h
    cfe/trunk/lib/Driver/Action.cpp
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Driver/Tools.h
    cfe/trunk/lib/Driver/WindowsToolChain.cpp
    cfe/trunk/test/Driver/split-debug.c

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Thu Feb 21 16:35:01 2013
@@ -46,10 +46,9 @@ public:
     LipoJobClass,
     DsymutilJobClass,
     VerifyJobClass,
-    SplitDebugJobClass,
 
     JobClassFirst=PreprocessJobClass,
-    JobClassLast=SplitDebugJobClass
+    JobClassLast=VerifyJobClass
   };
 
   static const char *getClassName(ActionClass AC);
@@ -234,15 +233,6 @@ public:
   }
 };
 
-class SplitDebugJobAction : public JobAction {
-  virtual void anchor();
-public:
-  SplitDebugJobAction(ActionList &Inputs, types::ID Type);
-  static bool classof(const Action *A) {
-    return A->getKind() == SplitDebugJobClass;
-  }
-};
-
 } // end namespace driver
 } // end namespace clang
 

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Thu Feb 21 16:35:01 2013
@@ -33,7 +33,6 @@ const char *Action::getClassName(ActionC
   case LipoJobClass: return "lipo";
   case DsymutilJobClass: return "dsymutil";
   case VerifyJobClass: return "verify";
-  case SplitDebugJobClass: return "split-debug";
   }
 
   llvm_unreachable("invalid class");
@@ -120,9 +119,3 @@ void VerifyJobAction::anchor() {}
 VerifyJobAction::VerifyJobAction(ActionList &Inputs, types::ID Type)
   : JobAction(VerifyJobClass, Inputs, Type) {
 }
-
-void SplitDebugJobAction::anchor() {}
-
-SplitDebugJobAction::SplitDebugJobAction(ActionList &Inputs, types::ID Type)
-  : JobAction(SplitDebugJobClass, Inputs, Type) {
-}

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Feb 21 16:35:01 2013
@@ -1107,12 +1107,6 @@ void Driver::BuildActions(const ToolChai
       Current.reset(ConstructPhaseAction(Args, Phase, Current.take()));
       if (Current->getType() == types::TY_Nothing)
         break;
-      else if (Current->getType() == types::TY_Object &&
-               Args.hasArg(options::OPT_gsplit_dwarf)) {
-        ActionList Input;
-        Input.push_back(Current.take());
-        Current.reset(new SplitDebugJobAction(Input, types::TY_Object));
-      }
     }
 
     // If we ended with something, add to the output list.
@@ -1120,16 +1114,6 @@ void Driver::BuildActions(const ToolChai
       Actions.push_back(Current.take());
   }
 
-  if (!SplitInputs.empty()) {
-    for (ActionList::iterator i = SplitInputs.begin(), e = SplitInputs.end();
-         i != e; ++i) {
-      Action *Act = *i;
-      ActionList Inputs;
-      Inputs.push_back(Act);
-      Actions.push_back(new SplitDebugJobAction(Inputs, types::TY_Object));
-    }
-  }
-
   // Add a link action if necessary.
   if (!LinkerInputs.empty())
     Actions.push_back(new LinkJobAction(LinkerInputs, types::TY_Image));
@@ -1410,8 +1394,6 @@ void Driver::BuildJobsForAction(Compilat
   // Determine the place to write output to, if any.
   if (JA->getType() == types::TY_Nothing)
     Result = InputInfo(A->getType(), BaseInput);
-  else if (isa<SplitDebugJobAction>(A))
-    Result = InputInfos[0];
   else
     Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, AtTopLevel),
                        A->getType(), BaseInput);

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Feb 21 16:35:01 2013
@@ -189,7 +189,6 @@ Tool &Darwin::SelectTool(const Compilati
   Tool *&T = Tools[Key];
   if (!T) {
     switch (Key) {
-    case Action::SplitDebugJobClass:
     case Action::InputClass:
     case Action::BindArchClass:
       llvm_unreachable("Invalid tool kind.");
@@ -1389,7 +1388,6 @@ Tool &Generic_GCC::SelectTool(const Comp
   Tool *&T = Tools[Key];
   if (!T) {
     switch (Key) {
-    case Action::SplitDebugJobClass:
     case Action::InputClass:
     case Action::BindArchClass:
       llvm_unreachable("Invalid tool kind.");
@@ -2452,8 +2450,6 @@ Tool &Linux::SelectTool(const Compilatio
       break;
     case Action::LinkJobClass:
       T = new tools::linuxtools::Link(*this); break;
-    case Action::SplitDebugJobClass:
-      T = new tools::linuxtools::SplitDebug(*this); break;
     default:
       T = &Generic_GCC::SelectTool(C, JA, Inputs);
     }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Feb 21 16:35:01 2013
@@ -1705,6 +1705,47 @@ static void addDebugCompDirArg(const Arg
   }
 }
 
+void Clang::SplitDebugInfo(Compilation &C, const JobAction &JA,
+                           const ArgList &Args,
+                           const InputInfoList &Inputs,
+                           const InputInfo &Output,
+                           const char *LinkingOutput) const {
+  ArgStringList ExtractArgs;
+  ExtractArgs.push_back("--extract-dwo");
+
+  ArgStringList StripArgs;
+  StripArgs.push_back("--strip-dwo");
+
+  // 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) {
+    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"));
+
+  // First extract the dwo sections.
+  C.addCommand(new Command(JA, *this, Exec, ExtractArgs));
+
+  // Then remove them from the original .o file.
+  C.addCommand(new Command(JA, *this, Exec, StripArgs));
+}
+
 void Clang::ConstructJob(Compilation &C, const JobAction &JA,
                          const InputInfo &Output,
                          const InputInfoList &Inputs,
@@ -3219,6 +3260,13 @@ void Clang::ConstructJob(Compilation &C,
   // Finally add the 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 (Arg *A = Args.getLastArg(options::OPT_pg))
     if (Args.hasArg(options::OPT_fomit_frame_pointer))
       D.Diag(diag::err_drv_argument_not_allowed_with)
@@ -4002,7 +4050,7 @@ void darwin::Assemble::ConstructJob(Comp
 
   if (getToolChain().getTriple().getArch() != llvm::Triple::x86_64 &&
       (((Args.hasArg(options::OPT_mkernel) ||
-	 Args.hasArg(options::OPT_fapple_kext)) &&
+         Args.hasArg(options::OPT_fapple_kext)) &&
         (!getDarwinToolChain().isTargetIPhoneOS() ||
          getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) ||
        Args.hasArg(options::OPT_static)))
@@ -5873,42 +5921,6 @@ void linuxtools::Link::ConstructJob(Comp
   C.addCommand(new Command(JA, *this, ToolChain.Linker.c_str(), CmdArgs));
 }
 
-void linuxtools::SplitDebug::ConstructJob(Compilation &C, const JobAction &JA,
-                                          const InputInfo &Output,
-                                          const InputInfoList &Inputs,
-                                          const ArgList &Args,
-                                          const char *LinkingOutput) const {
-  // Assert some invariants.
-  assert(Inputs.size() == 1 && "Unable to handle multiple inputs.");
-  const InputInfo &Input = Inputs[0];
-  assert(Input.isFilename() && "Unexpected verify input");
-
-  ArgStringList ExtractArgs;
-  ExtractArgs.push_back("--extract-dwo");
-
-  ArgStringList StripArgs;
-  StripArgs.push_back("--strip-dwo");
-
-  // Grabbing the output of the earlier compile step.
-  StripArgs.push_back(Input.getFilename());
-  ExtractArgs.push_back(Input.getFilename());
-
-  // Add an output for the extract.
-  SmallString<128> T(Inputs[0].getBaseInput());
-  llvm::sys::path::replace_extension(T, "dwo");
-  const char *OutFile = Args.MakeArgString(T);
-  ExtractArgs.push_back(OutFile);
-
-  const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath("objcopy"));
-
-  // First extract the dwo sections.
-  C.addCommand(new Command(JA, *this, Exec, ExtractArgs));
-
-  // Then remove them from the original .o file.
-  C.addCommand(new Command(JA, *this, Exec, StripArgs));
-}
-
 void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
                                    const InputInfo &Output,
                                    const InputInfoList &Inputs,

Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Thu Feb 21 16:35:01 2013
@@ -54,6 +54,10 @@ 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 };
 
@@ -450,20 +454,6 @@ namespace linuxtools {
 
     virtual void ConstructJob(Compilation &C, const JobAction &JA,
                               const InputInfo &Output,
-                              const InputInfoList &Inputs,
-                              const ArgList &TCArgs,
-                              const char *LinkingOutput) const;
-  };
-
-  class LLVM_LIBRARY_VISIBILITY SplitDebug : public Tool  {
-  public:
-    SplitDebug(const ToolChain &TC) : Tool("linuxtools::SplitDebug",
-                                           "objcopy", TC) {}
-
-    virtual bool hasIntegratedCPP() const { return false; }
-
-    virtual void ConstructJob(Compilation &C, const JobAction &JA,
-                              const InputInfo &Output,
                               const InputInfoList &Inputs,
                               const ArgList &TCArgs,
                               const char *LinkingOutput) const;

Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Thu Feb 21 16:35:01 2013
@@ -55,8 +55,6 @@ Tool &Windows::SelectTool(const Compilat
     case Action::LipoJobClass:
     case Action::DsymutilJobClass:
     case Action::VerifyJobClass:
-    case Action::SplitDebugJobClass:
-      llvm_unreachable("Invalid tool kind.");
     case Action::PreprocessJobClass:
     case Action::PrecompileJobClass:
     case Action::AnalyzeJobClass:

Modified: cfe/trunk/test/Driver/split-debug.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.c?rev=175813&r1=175812&r2=175813&view=diff
==============================================================================
--- cfe/trunk/test/Driver/split-debug.c (original)
+++ cfe/trunk/test/Driver/split-debug.c Thu Feb 21 16:35:01 2013
@@ -1,19 +1,10 @@
 // Check that we split debug output properly
 //
 // REQUIRES: asserts
-// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases \
-// RUN:   -gsplit-dwarf -arch x86_64 %s 2> %t
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
-// CHECK-ACTIONS: 0: input, "{{.*}}split-debug.c", c
-// CHECK-ACTIONS: 4: split-debug, {3}, object
+// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
-// Check output name derivation.
-//
-// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-bindings \
-// RUN:   -gsplit-dwarf -arch x86_64 -c %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
-//
-// CHECK-OUTPUT-NAME:# "x86_64-unknown-linux-gnu" - "clang", inputs: ["{{.*}}split-debug.c"], output: "{{.*}}split-debug{{.*}}.o"
-// CHECK-OUTPUT-NAME:# "x86_64-unknown-linux-gnu" - "linuxtools::SplitDebug", inputs: ["{{.*}}split-debug{{.*}}.o"], output: "{{.*}}split-debug{{.*}}.o"
 





More information about the cfe-commits mailing list