Commit 2794baab by Cherry Zhang Committed by Ian Lance Taylor

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
parent 90bf9487
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.
......
......@@ -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}
......
......@@ -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*);
......
......@@ -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_:
......
023c3d4358d101c71ac1436065690eaec2ce138e
e148068360699f24118950b728f23a5c98e1f85e
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
......@@ -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.
......
......@@ -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;
}
......@@ -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.
......
......@@ -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=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment