]>
git.proxmox.com Git - rustc.git/blob - src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs
1 // revisions: cfail1 cfail2
2 // compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
5 // rust-lang/rust#59535:
7 // Consider a call-graph like `[A] -> [B -> D] <- [C]` (where the letters are
8 // functions and the modules are enclosed in `[]`)
10 // In our specific instance, the earlier compilations were inlining the call
11 // to`B` into `A`; thus `A` ended up with an external reference to the symbol `D`
12 // in its object code, to be resolved at subsequent link time. The LTO import
13 // information provided by LLVM for those runs reflected that information: it
14 // explicitly says during those runs, `B` definition and `D` declaration were
15 // imported into `[A]`.
17 // The change between incremental builds was that the call `D <- C` was removed.
19 // That change, coupled with other decisions within `rustc`, made the compiler
20 // decide to make `D` an internal symbol (since it was no longer accessed from
21 // other codegen units, this makes sense locally). And then the definition of
22 // `D` was inlined into `B` and `D` itself was eliminated entirely.
24 // The current LTO import information reported that `B` alone is imported into
25 // `[A]` for the *current compilation*. So when the Rust compiler surveyed the
26 // dependence graph, it determined that nothing `[A]` imports changed since the
27 // last build (and `[A]` itself has not changed either), so it chooses to reuse
28 // the object code generated during the previous compilation.
30 // But that previous object code has an unresolved reference to `D`, and that
31 // causes a link time failure!
40 // In cfail1, foo() gets inlined into main.
41 // In cfail2, ThinLTO decides that foo() does not get inlined into main, and
42 // instead bar() gets inlined into foo(). But faulty logic in our incr.
43 // ThinLTO implementation thought that `main()` is unchanged and thus reused
44 // the object file still containing a call to the now non-existent bar().
49 // This function needs to be big so that it does not get inlined by ThinLTO
50 // but *does* get inlined into foo() once it is declared `internal` in