MaskRay wrote:

I'm reverting this as a clang driver maintainer: #240706.

`llvm-driver` always constructs a `ToolSession`, so `ToolContext::hasSession()` 
is true for every `clang` invocation through the multicall binary 
(`LLVM_TOOL_LLVM_DRIVER_BUILD=ON`), not just for embedding hosts. Those builds 
now get the reusable-cc1 behavior. Compared with standalone clang and with 
`-fno-integrated-cc1` on the same binary:

* `clang -O2 -c a.c b.c -save-stats=obj`: `b.stats` includes a.c's counts 
(instcombine.NumCombined 28 vs 14), because `Statistic` counters are 
process-global and nothing resets them between in-process cc1 jobs. `-mllvm 
-stats` prints one merged block instead of one per input.
* `--offload-jobs=N` has no effect: `CanRunInParallelOffloadJobGroup` requires 
`!Job.InProcess`, so device cc1 jobs run serially.
* After a crash or `report_fatal_error` in one input, the remaining inputs are 
skipped: `clang -c crash.c ok.c` no longer produces ok.o. `CC1Command::Execute` 
already falls back to a subprocess once `!canRunAgain()`, so the early return 
in `ExecuteJobs` only matters for hosts that cannot spawn processes.
* `-disable-free` is dropped for every compile, including the common 
one-TU-per-invocation case, which gains nothing from reuse (+1.1% instructions 
at -O0 -g on ScalarEvolution.cpp).

The follow-ups #240278 and #240520 are test-only and pass with or without this 
patch, so the revert leaves them in place.

Running cc1 repeatedly in one long-lived process is a new contract for clang. 
Process-global state (`cl::opt`, `Statistic`, the fatal error handler, 
`parallel::strategy`) and crash recovery become things the driver has to keep 
correct, and this patch shows how easily they leak into ordinary builds. That 
maintenance burden falls on the driver, so please don't reland until the RFC 
(https://discourse.llvm.org/t/rfc-embeddable-llvm-tool-drivers-for-long-lived-hosts/91754)
 has reached consensus on supporting it. If it does, the embedding behavior 
should be an explicit opt-in by the host (e.g. a `ToolSession` option that 
`llvm-driver` does not set) rather than keyed on `hasSession()`, with 
`REQUIRES: llvm-driver` tests covering the cases above. The same applies to 
#224023.

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

Reply via email to