public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7953] gccrs: Mark uninit-intrinsic as side-effects
@ 2024-01-16 18:10 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7519a5fb37aeb459bad022c9a41dd47b2d5b2b12

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

    gccrs: Mark uninit-intrinsic as side-effects
    
    Ensure the uninit intrinsic does not get optimized away
    
    Addresses #1895
    
    gcc/rust/ChangeLog:
    
            * backend/rust-compile-intrinsic.cc (uninit_handler): Update fndecl attributes
    
    Signed-off-by: Philip Herron <herron.philip@googlemail.com>

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

diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index cbf6c0bb2b8..5b41a3f6b05 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -1017,6 +1017,10 @@ uninit_handler (Context *ctx, TyTy::FnType *fntype)
 
   auto fndecl = compile_intrinsic_function (ctx, fntype);
 
+  // Most intrinsic functions are pure - not `uninit_handler`
+  TREE_READONLY (fndecl) = 0;
+  TREE_SIDE_EFFECTS (fndecl) = 1;
+
   // get the template parameter type tree fn uninit<T>();
   rust_assert (fntype->get_num_substitutions () == 1);
   auto &param_mapping = fntype->get_substs ().at (0);
@@ -1055,9 +1059,6 @@ uninit_handler (Context *ctx, TyTy::FnType *fntype)
 
   tree memset_call = build_call_expr_loc (BUILTINS_LOCATION, memset_builtin, 3,
 					  dst_addr, constant_byte, size_expr);
-  TREE_READONLY (memset_call) = 0;
-  TREE_SIDE_EFFECTS (memset_call) = 1;
-
   ctx->add_statement (memset_call);
 
   auto return_statement

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

only message in thread, other threads:[~2024-01-16 18:10 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:10 [gcc r14-7953] gccrs: Mark uninit-intrinsic as side-effects 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).