diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-03-14 15:56:33 +0000 | 
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-03-28 09:19:57 +0000 | 
| commit | a5fa12b6b908894f59a788641c4b14839e556c5f (patch) | |
| tree | 723c7409ef9e8d964dc492cb96ab533d585a7def /compiler/rustc_codegen_llvm/src/consts.rs | |
| parent | f7b43542838f0a4a6cfdb17fbeadf45002042a77 (diff) | |
| download | rust-a5fa12b6b908894f59a788641c4b14839e556c5f.tar.gz rust-a5fa12b6b908894f59a788641c4b14839e556c5f.zip | |
Avoid wrapping constant allocations in packed structs when not necessary
This way LLVM will set the string merging flag if the alloc is a nul terminated string, reducing binary sizes.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/consts.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 2 | 
1 files changed, 1 insertions, 1 deletions
| diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index a4e5749b3ac..a1ab6714d37 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -128,7 +128,7 @@ pub(crate) fn const_alloc_to_llvm<'ll>( append_chunks_of_init_and_uninit_bytes(&mut llvals, cx, alloc, range); } - cx.const_struct(&llvals, true) + if let &[data] = &*llvals { data } else { cx.const_struct(&llvals, true) } } fn codegen_static_initializer<'ll, 'tcx>( | 
