diff options
| author | Erik Desjardins <erikdesjardins@users.noreply.github.com> | 2022-02-18 15:57:10 -0500 |
|---|---|---|
| committer | Erik Desjardins <erikdesjardins@users.noreply.github.com> | 2022-02-18 15:57:10 -0500 |
| commit | b7e5597491a7880934f927edb506605d3368794e (patch) | |
| tree | 9ba5b57f286f113d989ef95effffe258572ef78f /compiler/rustc_codegen_llvm/src | |
| parent | b8c56fa8c30821129b0960180f528d4a1a4f9316 (diff) | |
| download | rust-b7e5597491a7880934f927edb506605d3368794e.tar.gz rust-b7e5597491a7880934f927edb506605d3368794e.zip | |
Use undef for partially-uninit constants up to 1024 bytes
There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 6707de93352..ddd87c5b24d 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -53,8 +53,10 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> } }; - // Generating partially-uninit consts inhibits optimizations, so it is disabled by default. - // See https://github.com/rust-lang/rust/issues/84565. + // Generating partially-uninit consts is limited to small allocations, + // to avoid the cost of generating large complex const expressions. + // For example, `[(u32, u8); 1024 * 1024]` contains uninit padding in each element, + // and would result in `{ [5 x i8] zeroinitializer, [3 x i8] undef, ...repeat 1M times... }`. let allow_partially_uninit = match cx.sess().opts.debugging_opts.partially_uninit_const_threshold { Some(max) => range.len() <= max, |
