Make -fintegrated-cc1 work with cc1as
authorFangrui Song <i@maskray.me>
Sat, 14 Nov 2020 09:16:16 +0000 (01:16 -0800)
committerFangrui Song <i@maskray.me>
Sat, 14 Nov 2020 09:16:16 +0000 (01:16 -0800)
Tested 0.018s faster on my machine.

clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cc1-spawnprocess.c

index c8d58f0..9ef408f 100644 (file)
@@ -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<Command>(JA, *this,
-                                         ResponseFileSupport::AtFileUTF8(),
-                                         Exec, CmdArgs, Inputs, Output));
+  if (D.CC1Main && !D.CCGenDiagnostics) {
+    // Invoke cc1as directly in this process.
+    C.addCommand(std::make_unique<CC1Command>(JA, *this,
+                                              ResponseFileSupport::AtFileUTF8(),
+                                              Exec, CmdArgs, Inputs, Output));
+  } else {
+    C.addCommand(std::make_unique<Command>(JA, *this,
+                                           ResponseFileSupport::AtFileUTF8(),
+                                           Exec, CmdArgs, Inputs, Output));
+  }
 }
 
 // Begin OffloadBundler
index 36df706..7f6dad6 100644 (file)
@@ -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