aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-08-31 11:33:27 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:04:30 +0100
commitb79f6432799f983470a5d19f4e91b45531166e90 (patch)
treeccf65d061012acabbb367e3f1c6f909d86e48cdc /gcc
parent7519a5fb37aeb459bad022c9a41dd47b2d5b2b12 (diff)
downloadgcc-b79f6432799f983470a5d19f4e91b45531166e90.zip
gcc-b79f6432799f983470a5d19f4e91b45531166e90.tar.gz
gcc-b79f6432799f983470a5d19f4e91b45531166e90.tar.bz2
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-intrinsic.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index 5b41a3f..f2650c9 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