[clang] [Clang][Inliner] Enable module-local optimizer hints by default (PR #238529)

Kuba Mracek via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 7 04:07:25 PST 2026


kubamracek wrote:

> investigate/discuss the outsized compile time impact on tramp3d-v4

Now, tramp3d-v4 compiles significantly slower with this change. Very significantly: +20% on ThinLTO, +35% on full LTO, and +75% on non-LTO -O3.

Looking a the structure of tramp3d-v4, it's no surprise: The llvm-test-suite's version (https://github.com/llvm/llvm-test-suite/tree/main/MultiSource/Benchmarks/tramp3d-v4) is a single-file amalgamation in a single 56,000-line .cpp file very heavy on C++ templated code (almost all the code is from some template). This PR then triggers a lot more inlining basically everywhere and this makes many LLVM passes just process larger functions, all adding up. There's no single function or pass that would stand up heavily.

I assume that the original version of tramp3d-v4 is not structured this way, and what we have in llvm-test-suite is a result of some post-processing.

My understanding of why it's sometimes useful to concatenate a whole into one source file is:

- (1) to speed up compilation by skipping re-parsing of the same headers ("unity builds")
    - ...but that doesn't seem to be the case here because that directly trades off build parallelism and is better done in "batches" instead of a single file, and also because the total "header content" and preprocessing/parsing time in this benchmark is very small, in contrast with e.g. some larger TUs of LLVM source code where the amount of #included code can be massive

or:

- (2) to maximize optimizations by giving the compiler full visibility into all used code ("poor man's LTO"), and especially expecting more IPO and inlining
    - this is famously done in SQLite production builds, and I believe that's the same motivation here in tramp3d-v4

Under that assumption, I would argue that this change (allow more inlining of templated code) is exactly giving tramp3d-v4 what it's asking for. I'm wondering if anyone has a good sense on whether there's other C++ projects that also do this sort of amalgamation and whether longer compile times (in exchange for more optimizations!) on those builds are actually a concern?

---

As an almost unrelated data point, I also compared the compile time with GCC. But I wouldn't take this too seriously, my understanding is that GCC's -O3 is today already much slower on compile-times compared to Clang on essentially all inputs:

```
                       |     Clang before |     Clang after |           GCC 16 |
compile-time for -O3   |  8.8s (baseline) |    13.2s (+50%) |     16.2s (+84%) |
```


https://github.com/llvm/llvm-project/pull/238529


More information about the cfe-commits mailing list