aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2018-02-02 00:00:04 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-02-02 00:00:04 +0000
commit2794baab686973f39045327970e4a7302c31ea88 (patch)
tree86c02d77baa7232c84a3d624601cc0f9e7405174 /gcc/go
parent90bf94878bea2883158d02370cb2692d4b2ed4a1 (diff)
downloadgcc-2794baab686973f39045327970e4a7302c31ea88.zip
gcc-2794baab686973f39045327970e4a7302c31ea88.tar.gz
gcc-2794baab686973f39045327970e4a7302c31ea88.tar.bz2
compiler: turn on escape analysis by default
The escape analysis now runs by default. It can be disabled with the negative flag, -fno-go-optimize-allocs. Reviewed-on: https://go-review.googlesource.com/86247 * lang.opt (fgo-optimize): Remove RejectNegative. * go-c.h (go_enable_optimize): Update declaration to take value argument. * go-lang.c (go_langhook_handle_option): Pass value to go_enable_optimize. * gccgo.texi (Invoking gccgo): Update -fgo-optimize-allocs doc. From-SVN: r257319
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/ChangeLog9
-rw-r--r--gcc/go/gccgo.texi8
-rw-r--r--gcc/go/go-c.h2
-rw-r--r--gcc/go/go-lang.c4
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/escape.cc2
-rw-r--r--gcc/go/gofrontend/go-optimize.cc14
-rw-r--r--gcc/go/gofrontend/go-optimize.h6
-rw-r--r--gcc/go/lang.opt2
9 files changed, 29 insertions, 20 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index b1876c5..92abf59 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,12 @@
+2018-02-01 Cherry Zhang <cherryyz@google.com>
+
+ * lang.opt (fgo-optimize): Remove RejectNegative.
+ * go-c.h (go_enable_optimize): Update declaration to take value
+ argument.
+ * go-lang.c (go_langhook_handle_option): Pass value to
+ go_enable_optimize.
+ * gccgo.texi (Invoking gccgo): Update -fgo-optimize-allocs doc.
+
2018-01-30 Ian Lance Taylor <iant@golang.org>
* go-gcc.cc (Gcc_backend::convert_tree): New private method.
diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi
index 48e69d4..f42be9a 100644
--- a/gcc/go/gccgo.texi
+++ b/gcc/go/gccgo.texi
@@ -229,10 +229,10 @@ may be used. Or the checks may be removed via
by default, but in the future may be off by default on systems that do
not require it.
-@item -fgo-optimize-allocs
-@cindex @option{-fgo-optimize-allocs}
-Use escape analysis to allocate objects on the stack rather than the
-heap when possible. In the future this may be the default.
+@item -fno-go-optimize-allocs
+@cindex @option{-fno-go-optimize-allocs}
+Disable escape analysis, which tries to allocate objects on the stack
+rather than the heap.
@item -fgo-debug-escape@var{n}
@cindex @option{-fgo-debug-escape}
diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h
index 139c233..2dc1d43 100644
--- a/gcc/go/go-c.h
+++ b/gcc/go/go-c.h
@@ -29,7 +29,7 @@ class Backend;
interface. */
extern int go_enable_dump (const char*);
-extern int go_enable_optimize (const char*);
+extern int go_enable_optimize (const char*, int);
extern void go_add_search_path (const char*);
diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c
index b5d8224..45dee88 100644
--- a/gcc/go/go-lang.c
+++ b/gcc/go/go-lang.c
@@ -194,7 +194,7 @@ static bool
go_langhook_handle_option (
size_t scode,
const char *arg,
- int value ATTRIBUTE_UNUSED,
+ int value,
int kind ATTRIBUTE_UNUSED,
location_t loc ATTRIBUTE_UNUSED,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
@@ -251,7 +251,7 @@ go_langhook_handle_option (
break;
case OPT_fgo_optimize_:
- ret = go_enable_optimize (arg) ? true : false;
+ ret = go_enable_optimize (arg, value) ? true : false;
break;
case OPT_fgo_pkgpath_:
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 6e58038..cc64fad 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-023c3d4358d101c71ac1436065690eaec2ce138e
+e148068360699f24118950b728f23a5c98e1f85e
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/escape.cc b/gcc/go/gofrontend/escape.cc
index 873c187..51e80e4 100644
--- a/gcc/go/gofrontend/escape.cc
+++ b/gcc/go/gofrontend/escape.cc
@@ -825,7 +825,7 @@ Escape_note::parse_tag(std::string* tag)
// The -fgo-optimize-alloc flag activates this escape analysis.
-Go_optimize optimize_allocation_flag("allocs");
+Go_optimize optimize_allocation_flag("allocs", true);
// A helper function to compute whether a function name has a
// matching hash value.
diff --git a/gcc/go/gofrontend/go-optimize.cc b/gcc/go/gofrontend/go-optimize.cc
index 6da934f..d24f35c 100644
--- a/gcc/go/gofrontend/go-optimize.cc
+++ b/gcc/go/gofrontend/go-optimize.cc
@@ -19,8 +19,8 @@ Go_optimize* optimizations;
// Create a new optimization.
-Go_optimize::Go_optimize(const char* name)
- : next_(optimizations), name_(name), is_enabled_(false)
+Go_optimize::Go_optimize(const char* name, bool enabled)
+ : next_(optimizations), name_(name), is_enabled_(enabled)
{
optimizations = this;
}
@@ -28,7 +28,7 @@ Go_optimize::Go_optimize(const char* name)
// Enable an optimization by name.
bool
-Go_optimize::enable_by_name(const char* name)
+Go_optimize::enable_by_name(const char* name, bool value)
{
bool is_all = strcmp(name, "all") == 0;
bool found = false;
@@ -36,18 +36,18 @@ Go_optimize::enable_by_name(const char* name)
{
if (is_all || strcmp(name, p->name_) == 0)
{
- p->is_enabled_ = true;
+ p->is_enabled_ = value;
found = true;
}
}
return found;
}
-// Enable an optimization. Return 1 if this is a real name, 0 if not.
+// Enable/disable an optimization. Return 1 if this is a real name, 0 if not.
GO_EXTERN_C
int
-go_enable_optimize(const char* name)
+go_enable_optimize(const char* name, int value)
{
- return Go_optimize::enable_by_name(name) ? 1 : 0;
+ return Go_optimize::enable_by_name(name, (bool)value) ? 1 : 0;
}
diff --git a/gcc/go/gofrontend/go-optimize.h b/gcc/go/gofrontend/go-optimize.h
index 8638498..1ca68de 100644
--- a/gcc/go/gofrontend/go-optimize.h
+++ b/gcc/go/gofrontend/go-optimize.h
@@ -15,16 +15,16 @@
class Go_optimize
{
public:
- Go_optimize(const char* name);
+ Go_optimize(const char*, bool);
// Whether this optimizaiton was enabled.
bool
is_enabled() const
{ return this->is_enabled_; }
- // Enable an optimization by name. Return true if found.
+ // Enable/disable an optimization by name. Return true if found.
static bool
- enable_by_name(const char*);
+ enable_by_name(const char*, bool);
private:
// The next optimize flag. These are not in any order.
diff --git a/gcc/go/lang.opt b/gcc/go/lang.opt
index 6dbb542..ee1c291 100644
--- a/gcc/go/lang.opt
+++ b/gcc/go/lang.opt
@@ -58,7 +58,7 @@ Go Joined RejectNegative
-fgo-dump-<type> Dump Go frontend internal information.
fgo-optimize-
-Go Joined RejectNegative
+Go Joined
-fgo-optimize-<type> Turn on optimization passes in the frontend.
fgo-pkgpath=