From d4e80fd645a9b4cac48957283e820f23d6e18aab Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Mon, 25 Jul 2022 12:59:15 +0100 Subject: Each intrinsic needs marked as const These intrinsics and builtin's need to be marked as const in order for the const eval code to generate copy's to cache their results and folded function bodies. --- gcc/rust/backend/rust-compile-base.cc | 2 ++ gcc/rust/backend/rust-compile-intrinsic.cc | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index ab330c4..cde0f08 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -701,6 +701,8 @@ HIRCompileBase::compile_constant_item ( gcc_assert (TREE_CODE (bind_tree) == BIND_EXPR); DECL_SAVED_TREE (fndecl) = bind_tree; + DECL_DECLARED_CONSTEXPR_P (fndecl); + maybe_save_constexpr_fundef (fndecl); ctx->pop_fn (); diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 61084b9..ae50c8a 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -15,17 +15,18 @@ // . #include "rust-compile-intrinsic.h" -#include "fold-const.h" -#include "langhooks.h" #include "rust-compile-context.h" #include "rust-compile-type.h" #include "rust-compile-fnparam.h" #include "rust-builtins.h" #include "rust-diagnostics.h" #include "rust-location.h" +#include "rust-constexpr.h" #include "rust-tree.h" #include "tree-core.h" #include "print-tree.h" +#include "fold-const.h" +#include "langhooks.h" namespace Rust { namespace Compile { @@ -213,6 +214,9 @@ finalize_intrinsic_block (Context *ctx, tree fndecl) DECL_SAVED_TREE (fndecl) = bind_tree; ctx->push_function (fndecl); + + DECL_DECLARED_CONSTEXPR_P (fndecl); + maybe_save_constexpr_fundef (fndecl); } static tree -- cgit v1.1