From bc7df035ae68648fe39304d9e77cd7618812cca8 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 14 Nov 2020 01:16:16 -0800 Subject: [PATCH] Make -fintegrated-cc1 work with cc1as Tested 0.018s faster on my machine. --- clang/lib/Driver/ToolChains/Clang.cpp | 13 ++++++++++--- clang/test/Driver/cc1-spawnprocess.c | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c8d58f0..9ef408f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7186,9 +7186,16 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Input.getFilename()); const char *Exec = getToolChain().getDriver().getClangProgramPath(); - C.addCommand(std::make_unique(JA, *this, - ResponseFileSupport::AtFileUTF8(), - Exec, CmdArgs, Inputs, Output)); + if (D.CC1Main && !D.CCGenDiagnostics) { + // Invoke cc1as directly in this process. + C.addCommand(std::make_unique(JA, *this, + ResponseFileSupport::AtFileUTF8(), + Exec, CmdArgs, Inputs, Output)); + } else { + C.addCommand(std::make_unique(JA, *this, + ResponseFileSupport::AtFileUTF8(), + Exec, CmdArgs, Inputs, Output)); + } } // Begin OffloadBundler diff --git a/clang/test/Driver/cc1-spawnprocess.c b/clang/test/Driver/cc1-spawnprocess.c index 36df706..7f6dad66 100644 --- a/clang/test/Driver/cc1-spawnprocess.c +++ b/clang/test/Driver/cc1-spawnprocess.c @@ -40,3 +40,8 @@ // Three jobs, thus integrated-cc1 is disabled. // RUN: %clang -fintegrated-cc1 -c %t1.cpp %t2.cpp %t3.cpp -### 2>&1 | FileCheck %s --check-prefix=NO + +// -fintegrated-cc1 works with cc1as. +// RUN: echo > %t.s +// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %t.s 2>&1 | FileCheck %s --check-prefix=YES +// RUN: %clang -fno-integrated-cc1 -c -### %t.s 2>&1 | FileCheck %s --check-prefix=NO -- 2.7.4