There are several `mk_foo`/`intern_foo` pairs, where the former takes an
iterator and the latter takes a slice. (This naming convention is bad,
but that's a fix for another PR.)
This commit changes several `mk_foo` occurrences into `intern_foo`,
avoiding the need for some `.iter()`/`.into_iter()` calls. Affected
cases:
- mk_type_list
- mk_tup
- mk_substs
- mk_const_list
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%.
Use stable metric for const eval limit instead of current terminator-based logic
This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.
The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).
Also see: #103877