public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Merge #1087
@ 2022-06-08 12:26 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:da3d59db1f13fb08aa9bd394b36379068315477c

commit da3d59db1f13fb08aa9bd394b36379068315477c
Merge: b829e7c0a21 5559bdc8663
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date:   Fri Apr 8 08:30:30 2022 +0000

    Merge #1087
    
    1087: Use loop to initialize repeat arrays r=philberty a=dafaust
    
    This PR changes how we compile initializers for arrays of repeating elements. I use the same approach outlined in the comments of the linked issue, with some tweaks. It is very similar to how the D language front-end compiles, the new function `Gcc_backend::array_initializer` is heavily inspired by the D front-end's `build_array_set`
    
    This fixes the issue where the compiler tries to allocate a vec containing all elements of the array to be constructed, and therefore explodes on huge constructions (e.g. `let x = [0u8; 4 * 1024 * 1024 * 1024 * 1024]`)
    
    However, we can only initialize non-const arrays in this way. For arrays in const contexts we must initialize them at compile time, and therefore continue using the old method.
    
    Fixes: #1068
    
    
    Co-authored-by: David Faust <david.faust@oracle.com>

Diff:

 gcc/rust/backend/rust-compile-context.h       | 15 ++++++
 gcc/rust/backend/rust-compile-expr.cc         | 57 +++++++++++++++++----
 gcc/rust/backend/rust-compile-item.cc         |  2 +
 gcc/rust/rust-backend.h                       |  4 ++
 gcc/rust/rust-gcc.cc                          | 73 +++++++++++++++++++++++++++
 gcc/testsuite/rust/compile/torture/arrays5.rs |  6 +++
 gcc/testsuite/rust/compile/torture/arrays6.rs | 10 ++++
 7 files changed, 156 insertions(+), 11 deletions(-)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:26 [gcc/devel/rust/master] Merge #1087 Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).