public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7954] gccrs: Fix move_val_init
@ 2024-01-16 18:08 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:08 UTC (permalink / raw)
  To: gcc-cvs

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

commit r14-7954-gb79f6432799f983470a5d19f4e91b45531166e90
Author: Philip Herron <herron.philip@googlemail.com>
Date:   Thu Aug 31 11:33:27 2023 +0100

    gccrs: Fix move_val_init
    
    The intrinsic move_val_init was being optimized away even at -O0 because
    the function looked "pure" but this adds in the attributes to enforce that
    this function has side-effects to override that bad assumption by the
    middle-end.
    
    Addresses #1895
    
    gcc/rust/ChangeLog:
    
            * backend/rust-compile-intrinsic.cc (move_val_init_handler): mark as side-effects
    
    Signed-off-by: Philip Herron <herron.philip@googlemail.com>

Diff:
---
 gcc/rust/backend/rust-compile-intrinsic.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index 5b41a3f6b05..f2650c98c15 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -1082,6 +1082,10 @@ move_val_init_handler (Context *ctx, TyTy::FnType *fntype)
 
   auto fndecl = compile_intrinsic_function (ctx, fntype);
 
+  // Most intrinsic functions are pure - not `move_val_init`
+  TREE_READONLY (fndecl) = 0;
+  TREE_SIDE_EFFECTS (fndecl) = 1;
+
   // get the template parameter type tree fn size_of<T>();
   rust_assert (fntype->get_num_substitutions () == 1);
   auto &param_mapping = fntype->get_substs ().at (0);
@@ -1113,8 +1117,6 @@ move_val_init_handler (Context *ctx, TyTy::FnType *fntype)
   src = build_fold_addr_expr_loc (BUILTINS_LOCATION, src);
   tree memset_call = build_call_expr_loc (BUILTINS_LOCATION, memcpy_builtin, 3,
 					  dst, src, size);
-  TREE_READONLY (memset_call) = 0;
-  TREE_SIDE_EFFECTS (memset_call) = 1;
 
   ctx->add_statement (memset_call);
   // BUILTIN size_of FN BODY END

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

only message in thread, other threads:[~2024-01-16 18:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:08 [gcc r14-7954] gccrs: Fix move_val_init Arthur Cohen

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).