Author: Fangrui Song
Date: 2026-11-09T21:10:59-08:00
New Revision: 309f2bb4959846f680d29d64a1dba085a819ddfe

URL: 
https://github.com/llvm/llvm-project/commit/309f2bb4959846f680d29d64a1dba085a819ddfe
DIFF: 
https://github.com/llvm/llvm-project/commit/309f2bb4959846f680d29d64a1dba085a819ddfe.diff

LOG: Revert #222531 "[clang] Support multiple in-process cc1 jobs in a 
ToolSession" (#240706)

This reverts commit cbf54d65f620f2efb78ee795ffdec28d269d9b21.

llvm-driver always constructs a ToolSession, so every clang invocation
through the multicall binary (LLVM_TOOL_LLVM_DRIVER_BUILD) takes the
reusable-cc1 path:

* -save-stats files accumulate Statistic counters across inputs
  (b.stats includes a.c's counts), and -mllvm -stats output is merged.
* --offload-jobs is ignored: in-process device jobs are excluded from
  parallel offload groups.
* After a crash or report_fatal_error in one input, the remaining inputs
  are skipped, unlike standalone clang and -fno-integrated-cc1:
  `clang -c crash.c ok.c` no longer produces ok.o.
* -disable-free is dropped for every compile, including single-file
  compiles (+1.1% instructions at -O0 -g).

Embedding hosts should opt in explicitly rather than keying on
ToolContext::hasSession().

LLM-aided

Added: 
    

Modified: 
    clang/include/clang/Driver/Compilation.h
    clang/include/clang/Driver/Driver.h
    clang/include/clang/Driver/Job.h
    clang/lib/Driver/Compilation.cpp
    clang/lib/Driver/Driver.cpp
    clang/lib/Driver/Job.cpp
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/cc1-spawnprocess.c
    clang/test/Driver/clang-translation.c
    clang/tools/driver/cc1_main.cpp
    clang/tools/driver/driver.cpp
    llvm/include/llvm/Support/Driver.h
    llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp

Removed: 
    clang/test/Driver/in-process-multiple-cc1-crash.c
    clang/test/Driver/in-process-multiple-cc1.c


################################################################################
diff  --git a/clang/include/clang/Driver/Compilation.h 
b/clang/include/clang/Driver/Compilation.h
index 79960bb6e80a12..825806b6cfe332 100644
--- a/clang/include/clang/Driver/Compilation.h
+++ b/clang/include/clang/Driver/Compilation.h
@@ -121,10 +121,6 @@ class Compilation {
   /// Whether we're compiling for diagnostic purposes.
   bool ForDiagnostics = false;
 
-  /// Whether the in-process cc1 callback supports repeated invocation.
-  /// Reusable callbacks must free per-invocation state before returning.
-  bool CC1MainIsReusable = false;
-
   /// Whether an error during the parsing of the input args.
   bool ContainsError;
 
@@ -138,8 +134,7 @@ class Compilation {
 public:
   Compilation(const Driver &D, const ToolChain &DefaultToolChain,
               llvm::opt::InputArgList *Args,
-              llvm::opt::DerivedArgList *TranslatedArgs, bool ContainsError,
-              bool CC1MainIsReusable);
+              llvm::opt::DerivedArgList *TranslatedArgs, bool ContainsError);
   ~Compilation();
 
   const Driver &getDriver() const { return TheDriver; }
@@ -342,8 +337,6 @@ class Compilation {
   /// Return true if we're compiling for diagnostics.
   bool isForDiagnostics() const { return ForDiagnostics; }
 
-  bool isCC1MainReusable() const { return CC1MainIsReusable; }
-
   /// Return whether an error during the parsing of the input args.
   bool containsError() const { return ContainsError; }
 

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 7d75e5e03a79d1..6ba0acacdeaf26 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -464,15 +464,11 @@ class Driver {
   /// BuildCompilation - Construct a compilation object for a command
   /// line argument vector.
   ///
-  /// \param CC1MainIsReusable Whether the in-process cc1 callback supports
-  /// repeated invocation and therefore requires normal per-job cleanup.
-  ///
   /// \return A compilation, or 0 if none was built for the given
   /// argument vector. A null return value does not necessarily
   /// indicate an error condition, the diagnostics should be queried
   /// to determine if an error occurred.
-  Compilation *BuildCompilation(ArrayRef<const char *> Args,
-                                bool CC1MainIsReusable = false);
+  Compilation *BuildCompilation(ArrayRef<const char *> Args);
 
   /// ParseArgStrings - Parse the given list of strings into an
   /// ArgList.

diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 5ac3d2bae84bb7..03779be5b5a6a0 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -259,13 +259,7 @@ class Command {
 
 /// Use the CC1 tool callback when available, to avoid creating a new process
 class CC1Command : public Command {
-  static bool CanRunAgain;
-
 public:
-  /// Whether this process can run cc1 again after crash recovery.
-  /// Embedding hosts must discard it if this returns false.
-  static bool canRunAgain();
-
   CC1Command(const Action &Source, const Tool &Creator,
              ResponseFileSupport ResponseSupport, const char *Executable,
              const llvm::opt::ArgStringList &Arguments,

diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index e5340f471be156..9b46b38811cb0b 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -39,10 +39,9 @@ using namespace llvm::opt;
 
 Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain,
                          InputArgList *_Args, DerivedArgList *_TranslatedArgs,
-                         bool ContainsError, bool CC1MainIsReusable)
+                         bool ContainsError)
     : TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args),
-      TranslatedArgs(_TranslatedArgs), CC1MainIsReusable(CC1MainIsReusable),
-      ContainsError(ContainsError) {
+      TranslatedArgs(_TranslatedArgs), ContainsError(ContainsError) {
   // The offloading host toolchain is the default toolchain.
   OrderedOffloadingToolchains.insert(
       std::make_pair(Action::OFK_Host, &DefaultToolChain));
@@ -407,8 +406,6 @@ void Compilation::ExecuteJobs(const JobList &Jobs,
       if (TheDriver.IsCLMode())
         return;
     }
-    if (Job.InProcess && !CC1Command::canRunAgain())
-      return;
   }
 }
 

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index c6f0bb0325a440..9d95f69f1bbfe1 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1549,8 +1549,7 @@ bool 
Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
   return false;
 }
 
-Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList,
-                                      bool CC1MainIsReusable) {
+Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
   llvm::PrettyStackTraceString CrashInfo("Compilation construction");
 
   // FIXME: Handle environment options which affect driver behavior, somewhere
@@ -1883,7 +1882,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char 
*> ArgList,
 
   // The compilation takes ownership of Args.
   Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs,
-                                   ContainsError, CC1MainIsReusable);
+                                   ContainsError);
 
   if (!HandleImmediateArgs(*C))
     return C;
@@ -4755,10 +4754,9 @@ void Driver::BuildJobs(Compilation &C) const {
                        /*TargetDeviceOffloadKind*/ Action::OFK_None);
   }
 
-  // Unless the callback explicitly supports repeated invocation, use a
-  // separate process when there is more than one job. Process execution
-  // statistics always require a separate process.
-  if ((C.getJobs().size() > 1 && !C.isCC1MainReusable()) || 
CCPrintProcessStats)
+  // If we have more than one job, then disable integrated-cc1 for now. Do this
+  // also when we need to report process execution statistics.
+  if (C.getJobs().size() > 1 || CCPrintProcessStats)
     for (auto &J : C.getJobs())
       J.InProcess = false;
 

diff  --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 7ceaae0860b2fe..da7a1f2e07e900 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -387,10 +387,6 @@ int Command::Execute(ArrayRef<std::optional<StringRef>> 
Redirects,
                                    ErrMsg, ExecutionFailed, &ProcStat);
 }
 
-bool CC1Command::CanRunAgain = true;
-
-bool CC1Command::canRunAgain() { return CanRunAgain; }
-
 CC1Command::CC1Command(const Action &Source, const Tool &Creator,
                        ResponseFileSupport ResponseSupport,
                        const char *Executable,
@@ -404,15 +400,17 @@ CC1Command::CC1Command(const Action &Source, const Tool 
&Creator,
 
 void CC1Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
                        CrashReportInfo *CrashInfo) const {
-  if (InProcess && canRunAgain())
+  if (InProcess)
     OS << " (in-process)\n";
   Command::Print(OS, Terminator, Quote, CrashInfo);
 }
 
 int CC1Command::Execute(ArrayRef<std::optional<StringRef>> Redirects,
                         std::string *ErrMsg, bool *ExecutionFailed) const {
-  // Use a separate process for crash diagnostics after an in-process crash.
-  if (!InProcess || !canRunAgain())
+  // FIXME: Currently, if there're more than one job, we disable
+  // -fintegrate-cc1. If we're no longer a integrated-cc1 job, fallback to
+  // out-of-process execution. See discussion in 
https://reviews.llvm.org/D74447
+  if (!InProcess)
     return Command::Execute(Redirects, ErrMsg, ExecutionFailed);
 
   PrintFileNames();
@@ -442,7 +440,6 @@ int CC1Command::Execute(ArrayRef<std::optional<StringRef>> 
Redirects,
   int R = 0;
   // Enter ExecuteCC1Tool() instead of starting up a new process
   if (!CRC.RunSafely([&]() { R = D.CC1Main(Argv); })) {
-    CanRunAgain = false;
     llvm::RestorePrettyStackState(PrettyState);
     return CRC.RetCode;
   }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a33b116eda7105..df8c9ccb1027bb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5832,10 +5832,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
     CmdArgs.push_back("-fembed-bitcode=marker");
 
   // We normally speed up the clang process a bit by skipping destructors at
-  // exit. Diagnostic compilations and reusable in-process callbacks must run
-  // the normal cleanup instead.
-  if (!C.isForDiagnostics() &&
-      (!C.isCC1MainReusable() || D.CCPrintProcessStats))
+  // exit, but when we're generating diagnostics we can rely on some of the
+  // cleanup.
+  if (!C.isForDiagnostics())
     CmdArgs.push_back("-disable-free");
   CmdArgs.push_back("-clear-ast-before-backend");
 

diff  --git a/clang/test/Driver/cc1-spawnprocess.c 
b/clang/test/Driver/cc1-spawnprocess.c
index dea0a778ec9cca..a6ff7d148604e3 100644
--- a/clang/test/Driver/cc1-spawnprocess.c
+++ b/clang/test/Driver/cc1-spawnprocess.c
@@ -31,18 +31,15 @@
 // Only one TU, one job, thus integrated-cc1 is enabled.
 // RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
 
-// Only one TU, but we're linking, two jobs. A reusable cc1 callback remains
-// in-process; an ordinary callback is disabled.
-// RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s \
-// RUN:   --check-prefix=%if llvm-driver %{YES%} %else %{NO%}
+// Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
+// RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO
 
 // RUN: echo 'int main() { return f() + g(); }' > %t1.cpp
 // RUN: echo 'int f() { return 1; }' > %t2.cpp
 // RUN: echo 'int g() { return 2; }' > %t3.cpp
 
-// Three jobs likewise use a reusable callback when one is available.
-// RUN: %clang -fintegrated-cc1 -c %t1.cpp %t2.cpp %t3.cpp -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=%if llvm-driver %{YES%} %else %{NO%}
+// 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.
 // macOS triples have an extra -x assembler-with-cpp job so (in-process) is 
not triggered.

diff  --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index 3f98b0bc8c5f62..5ec052a7aaa112 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fno-integrated-cc1 -target i386-unknown-unknown -### -S -O0 
-Os %s -o %t.s -fverbose-asm -fvisibility=hidden 2>&1 | FileCheck 
-check-prefix=I386 %s
+// RUN: %clang -target i386-unknown-unknown -### -S -O0 -Os %s -o %t.s 
-fverbose-asm -fvisibility=hidden 2>&1 | FileCheck -check-prefix=I386 %s
 // I386: "-triple" "i386-unknown-unknown"
 // I386: "-Os"
 // I386: "-S"
@@ -10,7 +10,7 @@
 // I386: "-o"
 // I386: clang-translation
 
-// RUN: %clang -fno-integrated-cc1 -target i386-unknown-unknown -### -S %s -o 
%t.s -Xclang -no-disable-free 2>&1 | FileCheck -check-prefix=FREE %s
+// RUN: %clang -target i386-unknown-unknown -### -S %s -o %t.s -Xclang 
-no-disable-free 2>&1 | FileCheck -check-prefix=FREE %s
 // FREE: "-disable-free"
 // FREE: "-no-disable-free"
 

diff  --git a/clang/test/Driver/in-process-multiple-cc1-crash.c 
b/clang/test/Driver/in-process-multiple-cc1-crash.c
deleted file mode 100644
index 3fc4d39a7d06dc..00000000000000
--- a/clang/test/Driver/in-process-multiple-cc1-crash.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// REQUIRES: llvm-driver, webassembly-registered-target, crash-recovery
-
-// A recovered compiler crash must not execute the next independent cc1 job.
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-// RUN: cd %t && not %clang -fintegrated-cc1 -fno-crash-diagnostics \
-// RUN:   --target=wasm32-unknown-unknown -c before.c crash.c after.c 2>&1 \
-// RUN:   | FileCheck %s --implicit-check-not='Error handler already 
registered'
-// RUN: test -f %t/before.o
-// RUN: not test -f %t/after.o
-// CHECK: fatal error: error in backend: #pragma clang __debug llvm_fatal_error
-
-//--- before.c
-int before(void) { return 1; }
-
-//--- crash.c
-#pragma clang __debug llvm_fatal_error
-
-//--- after.c
-int after(void) { return 2; }

diff  --git a/clang/test/Driver/in-process-multiple-cc1.c 
b/clang/test/Driver/in-process-multiple-cc1.c
deleted file mode 100644
index a01f91e1680fb2..00000000000000
--- a/clang/test/Driver/in-process-multiple-cc1.c
+++ /dev/null
@@ -1,68 +0,0 @@
-// REQUIRES: llvm-driver, webassembly-registered-target
-
-// A Clang invocation owned by ToolSession can execute multiple cc1 jobs
-// in-process. Each job must free its CompilerInstance before returning.
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-// RUN: cd %t && %clang -fintegrated-cc1 --target=wasm32-unknown-unknown -c 
-### \
-// RUN:   first.c second.c 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=COMMANDS \
-// RUN:       --implicit-check-not='"-disable-free"'
-// COMMANDS-COUNT-2: (in-process)
-
-// The same cleanup rule applies to a single cc1 job because the session stays
-// alive after the top-level Clang invocation returns.
-// RUN: cd %t && %clang -fintegrated-cc1 --target=wasm32-unknown-unknown -c 
-### first.c 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=SINGLE \
-// RUN:       --implicit-check-not='"-disable-free"'
-// SINGLE: (in-process)
-
-// An explicit request for a separate cc1 process remains authoritative.
-// RUN: cd %t && %clang --target=wasm32-unknown-unknown \
-// RUN:   -fno-integrated-cc1 -c -### first.c second.c 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=SPAWN \
-// RUN:       --implicit-check-not='(in-process)'
-// SPAWN-COUNT-2: "-disable-free"
-
-// Exercise the jobs and verify that both objects were emitted successfully.
-// RUN: cd %t && %clang -fintegrated-cc1 --target=wasm32-unknown-unknown \
-// RUN:   -c first.c second.c
-// RUN: llvm-readobj --file-headers %t/first.o %t/second.o \
-// RUN:   | FileCheck %s --check-prefix=OBJECTS
-// OBJECTS-COUNT-2: Format: WASM
-
-// A failed cc1 job does not prevent the following job from running in the
-// same process, regardless of which source comes first.
-// RUN: cd %t && not %clang -fintegrated-cc1 --target=wasm32-unknown-unknown \
-// RUN:   -c good-before-bad.c bad-after-good.c
-// RUN: test -f %t/good-before-bad.o
-// RUN: cd %t && not %clang -fintegrated-cc1 --target=wasm32-unknown-unknown \
-// RUN:   -c bad-before-good.c good-after-bad.c
-// RUN: test -f %t/good-after-bad.o
-
-// Failure to open one time-trace file must still clean up the profiler before
-// the next in-process job initializes it again.
-// RUN: mkdir %t/first.json
-// RUN: cd %t && %clang -fintegrated-cc1 --target=wasm32-unknown-unknown \
-// RUN:   -ftime-trace -c first.c second.c 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=TRACE
-// RUN: test -f %t/second.json
-// TRACE: error: unable to open output file 'first.json'
-
-//--- first.c
-int first(void) { return 1; }
-
-//--- second.c
-int second(void) { return 2; }
-
-//--- good-before-bad.c
-int good_before_bad(void) { return 3; }
-
-//--- bad-after-good.c
-int bad_after_good(void) { return does_not_parse( }
-
-//--- bad-before-good.c
-int bad_before_good(void) { return does_not_parse( }
-
-//--- good-after-bad.c
-int good_after_bad(void) { return 4; }

diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index ebba605bf33ed0..c49648cbf969d8 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -38,7 +38,6 @@
 #include "llvm/Option/OptTable.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/IOSandbox.h"
 #include "llvm/Support/ManagedStatic.h"
@@ -251,6 +250,16 @@ int cc1_main(ArrayRef<const char *> Argv, const char 
*Argv0, void *MainAddr) {
   auto Clang = std::make_unique<CompilerInstance>(std::move(Invocation),
                                                   std::move(PCHOps));
 
+  if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
+    llvm::TimeTraceCompression Compress =
+        Clang->getFrontendOpts().TimeTraceCompress;
+    if (Compress == llvm::TimeTraceCompression::Infer)
+      Compress = llvm::inferTimeTraceCompressionFromPath(
+          Clang->getFrontendOpts().TimeTracePath);
+    llvm::timeTraceProfilerInitialize(
+        Clang->getFrontendOpts().TimeTraceGranularity, Argv0,
+        Clang->getFrontendOpts().TimeTraceVerbose, Compress);
+  }
   // --print-supported-cpus takes priority over the actual compilation.
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
     return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
@@ -279,29 +288,15 @@ int cc1_main(ArrayRef<const char *> Argv, const char 
*Argv0, void *MainAddr) {
   // Create the actual diagnostics engine.
   Clang->createDiagnostics();
 
+  // Set an error handler, so that any LLVM backend diagnostics go through our
+  // error handler.
+  llvm::install_fatal_error_handler(
+      LLVMErrorHandler, static_cast<void *>(&Clang->getDiagnostics()));
+
   DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics());
   if (!Success)
     return 1;
 
-  // Initialize process-global state only after the early-return paths above.
-  if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
-    llvm::TimeTraceCompression Compress =
-        Clang->getFrontendOpts().TimeTraceCompress;
-    if (Compress == llvm::TimeTraceCompression::Infer)
-      Compress = llvm::inferTimeTraceCompressionFromPath(
-          Clang->getFrontendOpts().TimeTracePath);
-    llvm::timeTraceProfilerInitialize(
-        Clang->getFrontendOpts().TimeTraceGranularity, Argv0,
-        Clang->getFrontendOpts().TimeTraceVerbose, Compress);
-  }
-
-  // Set an error handler, so that any LLVM backend diagnostics go through our
-  // error handler.
-  auto ErrorHandler = std::make_unique<llvm::ScopedFatalErrorHandler>(
-      LLVMErrorHandler, &Clang->getDiagnostics());
-  llvm::CrashRecoveryContextCleanupRegistrar<llvm::ScopedFatalErrorHandler>
-      ErrorHandlerCleanup(ErrorHandler.get());
-
   // Execute the frontend actions.
   Success = ExecuteCompilerInvocation(Clang.get());
 
@@ -334,16 +329,15 @@ int cc1_main(ArrayRef<const char *> Argv, const char 
*Argv0, void *MainAddr) {
             /*useTemporary=*/false)) {
       llvm::timeTraceProfilerWrite(*profilerOutput);
       profilerOutput.reset();
+      llvm::timeTraceProfilerCleanup();
       Clang->clearOutputFiles(false);
     }
-    llvm::timeTraceProfilerCleanup();
   }
 
   // Our error handler depends on the Diagnostics object, which we're
   // potentially about to delete. Uninstall the handler now so that any
   // later errors use the default handling behavior instead.
-  ErrorHandlerCleanup.unregister();
-  ErrorHandler.reset();
+  llvm::remove_fatal_error_handler();
 
   // When running with -disable-free, don't do any destruction or shutdown.
   if (Clang->getFrontendOpts().DisableFree) {

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index ab41b11c2046ca..af96812e9ebd97 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -385,9 +385,7 @@ int clang_main(int Argc, char **Argv, const 
llvm::ToolContext &ToolContext) {
         /*NeedsPOSIXUtilitySignalHandling=*/true);
   }
 
-  bool CC1MainIsReusable = ToolContext.hasSession() && !UseNewCC1Process;
-  std::unique_ptr<Compilation> C(
-      TheDriver.BuildCompilation(Args, CC1MainIsReusable));
+  std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(Args));
 
   Driver::ReproLevel ReproLevel = Driver::ReproLevel::OnCrash;
   if (Arg *A = C->getArgs().getLastArg(options::OPT_gen_reproducer_eq)) {

diff  --git a/llvm/include/llvm/Support/Driver.h 
b/llvm/include/llvm/Support/Driver.h
index e65cc416ba048e..eef1d21cc8e0a9 100644
--- a/llvm/include/llvm/Support/Driver.h
+++ b/llvm/include/llvm/Support/Driver.h
@@ -56,9 +56,6 @@ class ToolContext {
 
   /// Invokes another tool registered with the same host session.
   LLVM_ABI ErrorOr<int> callTool(ArrayRef<const char *> Args) const;
-
-  /// Returns true when this invocation is owned by a tool session.
-  bool hasSession() const { return Session != nullptr; }
 };
 
 /// Owns LLVM process initialization and an in-process tool registry.

diff  --git a/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp 
b/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp
index c6eb625f347076..e0252324ed4037 100644
--- a/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp
+++ b/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp
@@ -28,7 +28,6 @@ int linkerMain(int Argc, char **Argv, const ToolContext 
&Context) {
   ++LinkerCalls;
   EXPECT_EQ(Argc, 3);
   EXPECT_STREQ(Argv[0], "wasm-ld");
-  EXPECT_TRUE(Context.hasSession());
   EXPECT_TRUE(Context.getCallableTool("clang"));
   return 0;
 }
@@ -73,11 +72,6 @@ int fuzzyMain(int Argc, char **Argv, const ToolContext 
&Context) {
   return 0;
 }
 
-TEST(LLVMToolSessionTest, DistinguishesStandaloneContext) {
-  ToolContext Context("clang", nullptr, false);
-  EXPECT_FALSE(Context.hasSession());
-}
-
 TEST(LLVMToolSessionTest, SupportsSequentialNestedToolCalls) {
   unsigned CompilerCallsBefore = CompilerCalls;
   unsigned LinkerCallsBefore = LinkerCalls;


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to