diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-01-23 14:44:20 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-01-29 15:29:48 +0000 |
commit | 618f41a3cd69f3be63528ba8c451a43574500aeb (patch) | |
tree | bef3db4c66c632eef1a1217695a431a56d8f772a /gcc/rust/backend/rust-compile-expr.cc | |
parent | 84bca6f2712a04eb8c0f951c16cafd11202ba950 (diff) | |
download | gcc-618f41a3cd69f3be63528ba8c451a43574500aeb.zip gcc-618f41a3cd69f3be63528ba8c451a43574500aeb.tar.gz gcc-618f41a3cd69f3be63528ba8c451a43574500aeb.tar.bz2 |
gccrs: add new -frust-overflow-checks flag to control overflow checks
This will be crucial for more complex gimple debugging to make it easier
to follow the code vs the original rust code.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): disable overflow checks
* lang.opt: new flag
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 1d68e85..7938330 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -159,27 +159,28 @@ CompileExpr::visit (HIR::ArithmeticOrLogicalExpr &expr) return; } - if (ctx->in_fn () && !ctx->const_context_p ()) - { - auto receiver_tmp = NULL_TREE; - auto receiver - = Backend::temporary_variable (ctx->peek_fn ().fndecl, NULL_TREE, - TREE_TYPE (lhs), lhs, true, - expr.get_locus (), &receiver_tmp); - auto check - = Backend::arithmetic_or_logical_expression_checked (op, lhs, rhs, - expr.get_locus (), - receiver); - - ctx->add_statement (check); - translated = receiver->get_tree (expr.get_locus ()); - } - else + bool can_generate_overflow_checks + = (ctx->in_fn () && !ctx->const_context_p ()) && flag_overflow_checks; + if (!can_generate_overflow_checks) { translated = Backend::arithmetic_or_logical_expression (op, lhs, rhs, expr.get_locus ()); + return; } + + auto receiver_tmp = NULL_TREE; + auto receiver + = Backend::temporary_variable (ctx->peek_fn ().fndecl, NULL_TREE, + TREE_TYPE (lhs), lhs, true, + expr.get_locus (), &receiver_tmp); + auto check + = Backend::arithmetic_or_logical_expression_checked (op, lhs, rhs, + expr.get_locus (), + receiver); + + ctx->add_statement (check); + translated = receiver->get_tree (expr.get_locus ()); } void |