Don't ICE in `might_permit_raw_init` if reference is polymorphic
Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition.
cc `@saethlin`
fixes#107999
This slightly improves performance on systems with many cores and
barely affects systems with few cores.
My laptop (2 core + HT):
Before:
Benchmark 2: RUSTC=rustc /home/bjorn/Projects/cg_clif2/./dist/cargo-clif build --manifest-path /home/bjorn/Projects/cg_clif2/./download/simple-raytracer/Cargo.toml --target-dir /home/bjorn/Projects/cg_clif2/./build/simple_raytracer
Time (mean ± σ): 12.042 s ± 0.313 s [User: 29.434 s, System: 4.720 s]
Range (min … max): 11.670 s … 12.795 s 10 runs
After:
Benchmark 2: RUSTC=rustc /home/bjorn/Projects/cg_clif2/./dist/cargo-clif build --manifest-path /home/bjorn/Projects/cg_clif2/./download/simple-raytracer/Cargo.toml --target-dir /home/bjorn/Projects/cg_clif2/./build/simple_raytracer
Time (mean ± σ): 12.037 s ± 0.384 s [User: 29.960 s, System: 4.722 s]
Range (min … max): 11.673 s … 12.769 s 10 runs
Dev desktop (32 cores)
Before:
Benchmark 2: RUSTC=rustc /home/gh-bjorn3/cg_clif/./dist/cargo-clif build --manifest-path /home/gh-bjorn3/cg_clif/./download/simple-raytracer/Cargo.toml --target-dir /home/gh-bjorn3/cg_clif/./build/simple_raytracer
Time (mean ± σ): 10.425 s ± 0.104 s [User: 25.877 s, System: 5.513 s]
Range (min … max): 10.267 s … 10.640 s 10 runs
After:
Benchmark 2: RUSTC=rustc /home/gh-bjorn3/cg_clif/./dist/cargo-clif build --manifest-path /home/gh-bjorn3/cg_clif/./download/simple-raytracer/Cargo.toml --target-dir /home/gh-bjorn3/cg_clif/./build/simple_raytracer
Time (mean ± σ): 10.212 s ± 0.100 s [User: 25.918 s, System: 5.555 s]
Range (min … max): 10.079 s … 10.362 s 10 runs
This significantly improves performance. For example for the
simple-raytracer benchmark it goes from a 13% improvement over LLVM to
39% improvement over LLVM.
Sometimes it is necessary for handling vector to scalar pair transmutes,
but if the types are the same there is no need for this.
This improves runtime performance on simple-raytracer by 12%.