[PATCH] D63978: Very early work on interface stub merger plumbing.

Puyan Lotfi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 30 10:11:43 PDT 2019


plotfi created this revision.
plotfi added a reviewer: compnerd.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is really early.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63978

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h


Index: clang/lib/Driver/ToolChains/Gnu.h
===================================================================
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -45,6 +45,21 @@
       : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
 };
 
+namespace ifstool {
+class LLVM_LIBRARY_VISIBILITY Merger : public GnuTool {
+public:
+  Merger(const ToolChain &TC) : GnuTool("IFS::Merger", "merger", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+                    const InputInfo &Output, const InputInfoList &Inputs,
+                    const llvm::opt::ArgList &TCArgs,
+                    const char *LinkingOutput) const override;
+};
+} // end namespace ifstool
+
 /// Directly call GNU Binutils' assembler and linker.
 namespace gnutools {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -341,6 +341,21 @@
       !Args.hasArg(options::OPT_static_pie);
 }
 
+void tools::ifstool::Merger::ConstructJob(Compilation &C, const JobAction &JA,
+                                          const InputInfo &Output,
+                                          const InputInfoList &Inputs,
+                                          const ArgList &Args,
+                                          const char *LinkingOutput) const {
+  llvm::errs() << "Construct merger job\n";
+  SmallVector<const char *, 16> CmdArgs;
+  const char *Exec = "/path/to/llvm-ifs";
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+  for (auto Input : Inputs)
+    CmdArgs.push_back(Input.getFilename());
+  C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
+}
+
 void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
                                            const InputInfo &Output,
                                            const InputInfoList &Inputs,
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,7 +286,6 @@
              (PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
              (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
              (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
-             (PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs)) ||
              (PhaseArg = DAL.getLastArg(options::OPT__analyze,
                                         options::OPT__analyze_auto)) ||
              (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
@@ -301,6 +300,10 @@
     FinalPhase = phases::Assemble;
 
     // Otherwise do everything.
+  } else if ((PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs))) {
+    FinalPhase = phases::Link;
+    SkipPhases.insert(phases::Backend);
+    SkipPhases.insert(phases::Assemble);
   } else
     FinalPhase = phases::Link;
 
@@ -3312,6 +3315,7 @@
       // If we find Phase in the SkipPhases, then skip it.
       if (PhasesToRun.SkipPhases.find(Phase) != PhasesToRun.SkipPhases.end())
         continue;
+      llvm::errs() << "PHASE: " << Phase << "\n";
 
       // Add any offload action the host action depends on.
       Current = OffloadBuilder.addDeviceDependencesToHostAction(
@@ -3900,6 +3904,11 @@
       T = combineAssembleBackend(ActionChain, Inputs, CollapsedOffloadAction);
     if (!T)
       T = combineBackendCompile(ActionChain, Inputs, CollapsedOffloadAction);
+    if (!T && C.getArgs().getLastArg(options::OPT_emit_iterface_stubs) &&
+        isa<LinkJobAction>(BaseAction)) {
+      llvm::errs() << "WTF\n";
+      T = new tools::ifstool::Merger(TC);
+    }
     if (!T) {
       Inputs = BaseAction->getInputs();
       T = TC.SelectTool(*BaseAction);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63978.207223.patch
Type: text/x-patch
Size: 4066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190630/57e66448/attachment-0001.bin>


More information about the cfe-commits mailing list