[PATCH] D62722: [Driver] Simplify Assemble and Backend action collapsing

Kévin Petit via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 02:08:59 PDT 2019

kpet created this revision.
kpet added reviewers: tra, ABataev, echristo, jlebar, hfinkel, rsmith.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

The action collapsing logic introduced in
https://reviews.llvm.org/D21840 generally works by replacing
action A followed by B by an action that uses the tool for A
with action B.

The logic in combineAssembleBackend however does something
different and selects a tool for an action that is not part
of the list of actions under consideration for collapsing,
specifically it selects the tool for the CompileJobAction on
which the BackendJobAction depends.

There doesn't seem to be any good reason that I could find for
doing this. My understanding is that all cases of interest rely
on the Clang tool being selected for the CompileJobAction.
However the same Clang tool would be selected for a
BackendJobAction and doing so would make the collapsing logic
more symmetric and make it easier to further refactor into
something more generic.

The reason I'm looking at this is that I am currently working
on a toolchain that uses a single tool with combined
BackendJobAction and AssembleJobAction that is not Clang but
uses Clang as the tool for CompileJobAction.

Am I missing something? Are we missing a test?

Signed-off-by: Kevin Petit <kevin.petit at arm.com>

  rC Clang



Index: clang/lib/Driver/Driver.cpp
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3733,18 +3733,8 @@
     if (!AJ || !BJ)
       return nullptr;
-    // Retrieve the compile job, backend action must always be preceded by one.
-    ActionList CompileJobOffloadActions;
-    auto *CJ = getPrevDependentAction(BJ->getInputs(), CompileJobOffloadActions,
-                                      /*CanBeCollapsed=*/false);
-    if (!AJ || !BJ || !CJ)
-      return nullptr;
-    assert(isa<CompileJobAction>(CJ) &&
-           "Expecting compile job preceding backend job.");
-    // Get compiler tool.
-    const Tool *T = TC.SelectTool(*CJ);
+    // Get backend tool.
+    const Tool *T = TC.SelectTool(*BJ);
     if (!T)
       return nullptr;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62722.202395.patch
Type: text/x-patch
Size: 837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190531/495212e5/attachment.bin>

More information about the cfe-commits mailing list