Skip to content

Commit 113fe16

Browse files
committed
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 <[email protected]>
1 parent fabb8b0 commit 113fe16

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gcc/rust/backend/rust-compile-intrinsic.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,10 @@ uninit_handler (Context *ctx, TyTy::FnType *fntype)
10171017

10181018
auto fndecl = compile_intrinsic_function (ctx, fntype);
10191019

1020+
// Most intrinsic functions are pure - not `uninit_handler`
1021+
TREE_READONLY (fndecl) = 0;
1022+
TREE_SIDE_EFFECTS (fndecl) = 1;
1023+
10201024
// get the template parameter type tree fn uninit<T>();
10211025
rust_assert (fntype->get_num_substitutions () == 1);
10221026
auto &param_mapping = fntype->get_substs ().at (0);
@@ -1055,9 +1059,6 @@ uninit_handler (Context *ctx, TyTy::FnType *fntype)
10551059

10561060
tree memset_call = build_call_expr_loc (BUILTINS_LOCATION, memset_builtin, 3,
10571061
dst_addr, constant_byte, size_expr);
1058-
TREE_READONLY (memset_call) = 0;
1059-
TREE_SIDE_EFFECTS (memset_call) = 1;
1060-
10611062
ctx->add_statement (memset_call);
10621063

10631064
auto return_statement

0 commit comments

Comments
 (0)