rust/tests/codegen-units/partitioning
Tomasz Miąsko 8c8225afe8 Remove mono item collection strategy override from -Zprint-mono-items
Previously `-Zprint-mono-items` would override the mono item collection
strategy. When debugging one doesn't want to change the behaviour, so
this was counter productive. Additionally, the produced behaviour was
artificial and might never arise without using the option in the first
place (`-Zprint-mono-items=eager` without `-Clink-dead-code`).  Finally,
the option was incorrectly marked as `UNTRACKED`.

Resolve those issues, by turning `-Zprint-mono-items` into a boolean
flag that prints results of mono item collection without changing the
behaviour of mono item collection.

For codegen-units test incorporate `-Zprint-mono-items` flag directly
into compiletest tool.

Test changes are mechanical. `-Zprint-mono-items=lazy` was removed
without additional changes, and `-Zprint-mono-items=eager` was turned
into `-Clink-dead-code`.  Linking dead code disables internalization, so
tests have been updated accordingly.
2025-05-09 12:19:09 +02:00
..
auxiliary Remove -Zinline-in-all-cgus and clean up CGU partitioning tests 2025-01-27 23:48:47 -05:00
extern-drop-glue.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
extern-generic.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
incremental-merging.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
inline-always.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
inlining-from-extern-crate.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
local-drop-glue.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
local-generic.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
local-transitive-inlining.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
methods-are-with-self-type.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
README.md Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
regular-modules.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
shared-generics.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
statics.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
vtable-through-const.rs Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00

codegen-units/partitioning tests

This test suite is designed to test that codegen unit partitioning works as intended. Note that it does not evaluate whether CGU partitioning is good. That is the job of the compiler benchmark suite.

All tests in this suite use the flag -Zprint-mono-items, which makes the compiler print a machine-readable summary of all MonoItems that were collected, which CGUs they were assigned to, and the linkage in each CGU. The output looks like:

MONO_ITEM <item> @@ <cgu name>[<linkage>] <other cgu name>[<linkage in other cgu>]

The current CGU partitioning algorithm essentially groups MonoItems by which module they are defined in, then merges small CGUs. There are a lot of inline modules in this test suite because that's the only way to observe the partitioning.

Currently, the test suite is very heavily biased towards incremental builds with -Copt-level=0. This is mostly an accident of history; the entire test suite was added as part of supporting incremental compilation in #32779. But also CGU partitioning is mostly valuable because the CGU is the unit of incrementality to the codegen backend (cached queries are the unit of incrementality for the rest of the compiler).