aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-09-10 02:37:42 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-09-10 02:37:42 +0000
commit5447e8e2e249a12b0f22ccfb171ccc8fff9fcadc (patch)
tree6035009eba3ff49350241fb098c94923426439f3 /gcc/go
parent77df40e8127ec4f62c01c15f2d6f76d995424863 (diff)
downloadgcc-5447e8e2e249a12b0f22ccfb171ccc8fff9fcadc.zip
gcc-5447e8e2e249a12b0f22ccfb171ccc8fff9fcadc.tar.gz
gcc-5447e8e2e249a12b0f22ccfb171ccc8fff9fcadc.tar.bz2
compiler: permit inlining constant expressions and expression statements
This relatively minor change increases the number of inlinable functions/methods in the standard library from 983 to 2179. In particular it permits inlining math/bits/RotateLeftNN. This restores the speed of crypto/sha256 back to what it was before the update to 1.13beta1. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194340 From-SVN: r275558
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc4
-rw-r--r--gcc/go/gofrontend/statements.cc12
-rw-r--r--gcc/go/gofrontend/statements.h7
4 files changed, 24 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 21f9e48..a762d6b 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c6097f269d2b3dbfd5204cf7e3d0b9f8d7ec2b5e
+5c3f52ffbae7a9bb59bce63cd2cffdd8af8f4a92
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index cb09ec0..7d8963e 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -3283,6 +3283,10 @@ class Const_expression : public Expression
Bexpression*
do_get_backend(Translate_context* context);
+ int
+ do_inlining_cost() const
+ { return 1; }
+
// When exporting a reference to a const as part of a const
// expression, we export the value. We ignore the fact that it has
// a name.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 27c309e..3dc394a 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -158,6 +158,10 @@ Statement::import_statement(Import_function_body* ifb, Location loc)
return Goto_statement::do_import(ifb, loc);
Expression* lhs = Expression::import_expression(ifb, loc);
+
+ if (ifb->match_c_string(" //"))
+ return Statement::make_statement(lhs, true);
+
ifb->require_c_string(" = ");
Expression* rhs = Expression::import_expression(ifb, loc);
return Statement::make_assignment(lhs, rhs, loc);
@@ -2089,6 +2093,14 @@ Expression_statement::do_may_fall_through() const
return true;
}
+// Export an expression statement.
+
+void
+Expression_statement::do_export_statement(Export_function_body* efb)
+{
+ this->expr_->export_expression(efb);
+}
+
// Convert to backend representation.
Bstatement*
diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h
index 311bbaa..f1c6be9 100644
--- a/gcc/go/gofrontend/statements.h
+++ b/gcc/go/gofrontend/statements.h
@@ -924,6 +924,13 @@ class Expression_statement : public Statement
bool
do_may_fall_through() const;
+ int
+ do_inlining_cost()
+ { return 0; }
+
+ void
+ do_export_statement(Export_function_body*);
+
Bstatement*
do_get_backend(Translate_context* context);