[gcc/devel/rust/master] Ensure we set TREE_SIDE_EFFECTS on call expressions

Thomas Schwinge tschwinge@gcc.gnu.org
Thu Aug 11 19:19:36 GMT 2022


https://gcc.gnu.org/g:f891a13aa2af912584176d2c595c295b77ff5ff9

commit f891a13aa2af912584176d2c595c295b77ff5ff9
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Thu Aug 11 12:34:13 2022 +0100

    Ensure we set TREE_SIDE_EFFECTS on call expressions
    
    When we compiling call expressions the GCC helper has quite a simple
    implementation to determine if there are SIDE_EFFECTS we have more
    information in the front-end to determine this. This adds a check that
    the call expression is deemed to have no side effects ensure we check this
    against the fndecl used.
    
    Fixes #1460

Diff:
---
 gcc/rust/rust-gcc.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 27196e88593..f396aa867b9 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1848,6 +1848,9 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
       ret = build1_loc (location.gcc_location (), NOP_EXPR, rettype, ret);
     }
 
+  if (!TREE_SIDE_EFFECTS (ret))
+    TREE_SIDE_EFFECTS (ret) = TREE_SIDE_EFFECTS (fndecl);
+
   delete[] args;
   return ret;
 }


More information about the Gcc-cvs mailing list