aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-08-31 11:33:12 +0100
committerPhilip Herron <philip.herron@embecosm.com>2023-08-31 21:25:00 +0000
commit113fe163a4ce2c44d880abe659aff08b85b5dc51 (patch)
tree0835d6363567e56807ccdd99f63c81c23adb45c9 /gcc/rust
parentfabb8b050e3ff8095b576eaa135904221bd4b53f (diff)
downloadgcc-113fe163a4ce2c44d880abe659aff08b85b5dc51.zip
gcc-113fe163a4ce2c44d880abe659aff08b85b5dc51.tar.gz
gcc-113fe163a4ce2c44d880abe659aff08b85b5dc51.tar.bz2
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>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/backend/rust-compile-intrinsic.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index cbf6c0b..5b41a3f 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