Commit 7295570d by Chris Manghane Committed by Ian Lance Taylor

escape: Add basic debugging.

    
    Emit basic debug information when compiling with the flag
    -fgo-debug-escape#.
    
    Reviewed-on: https://go-review.googlesource.com/22376

	2016-08-02  Chris Manghane  <cmang@google.com>

	* lang.opt: Add -fgo-debug-escape option.
	* go-c.h (go_create_gogo): Add debug_escape_level parameter.
	* go-lang.c (go_langhook_init): Pass go_debug_escape_level to
	go_create_gogo.

From-SVN: r239002
parent 00803109
2016-08-02 Chris Manghane <cmang@google.com>
* lang.opt: Add -fgo-debug-escape option.
* go-c.h (go_create_gogo): Add debug_escape_level parameter.
* go-lang.c (go_langhook_init): Pass go_debug_escape_level to
go_create_gogo.
2016-05-06 Chris Manghane <cmang@google.com>
* Make-lang.in (GO_OBJS): Add go/escape.o (based on an entirely
......
......@@ -34,7 +34,8 @@ extern void go_add_search_path (const char*);
extern void go_create_gogo (int int_type_size, int pointer_size,
const char* pkgpath, const char *prefix,
const char *relative_import_path,
bool check_divide_zero, bool check_divide_overflow);
bool check_divide_zero, bool check_divide_overflow,
int debug_escape_level);
extern void go_parse_input_files (const char**, unsigned int,
bool only_check_syntax,
......
......@@ -101,7 +101,7 @@ go_langhook_init (void)
go_type_for_size). */
go_create_gogo (INT_TYPE_SIZE, POINTER_SIZE, go_pkgpath, go_prefix,
go_relative_import_path, go_check_divide_zero,
go_check_divide_overflow);
go_check_divide_overflow, go_debug_escape_level);
build_common_builtin_nodes ();
......
d4b47fef149fc905ae6b418934f6be8cf6be433e
89a0b3a04f80df388242166b8835f12e82ceb194
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
......@@ -193,6 +193,17 @@ class Node
Location
location() const;
// Return this node's AST formatted string.
std::string
ast_format(Gogo*) const;
// Return this node's detailed format string.
std::string
details() const;
std::string
op_format() const;
// Return this node's escape state.
Escape_state*
state(Escape_context* context, Named_object* fn);
......@@ -343,6 +354,10 @@ class Escape_context
set_current_function(Named_object* fn)
{ this->current_function_ = fn; }
// Return the name of the current function.
std::string
current_function_name() const;
// Return true if this is the context for a mutually recursive set of functions.
bool
recursive() const
......
......@@ -22,7 +22,8 @@ GO_EXTERN_C
void
go_create_gogo(int int_type_size, int pointer_size, const char *pkgpath,
const char *prefix, const char *relative_import_path,
bool check_divide_by_zero, bool check_divide_overflow)
bool check_divide_by_zero, bool check_divide_overflow,
int debug_escape_level)
{
go_assert(::gogo == NULL);
Linemap* linemap = go_get_linemap();
......@@ -39,6 +40,7 @@ go_create_gogo(int int_type_size, int pointer_size, const char *pkgpath,
::gogo->set_check_divide_by_zero(check_divide_by_zero);
if (check_divide_overflow)
::gogo->set_check_divide_overflow(check_divide_overflow);
::gogo->set_debug_escape_level(debug_escape_level);
}
// Parse the input files.
......
......@@ -239,6 +239,16 @@ class Gogo
set_check_divide_overflow(bool b)
{ this->check_divide_overflow_ = b; }
// Return the level of escape analysis debug information to emit.
int
debug_escape_level() const
{ return this->debug_escape_level_; }
// Set the level of escape analysis debugging from a command line option.
void
set_debug_escape_level(int level)
{ this->debug_escape_level_ = level; }
// Return the priority to use for the package we are compiling.
// This is two more than the largest priority of any package we
// import.
......@@ -786,6 +796,9 @@ class Gogo
// Whether or not to check for division overflow, from the
// -fgo-check-divide-overflow option.
bool check_divide_overflow_;
// The level of escape analysis debug information to emit, from the
// -fgo-debug-escape option.
int debug_escape_level_;
// A list of types to verify.
std::vector<Type*> verify_types_;
// A list of interface types defined while parsing.
......@@ -2715,7 +2728,7 @@ class Unnamed_label
{
public:
Unnamed_label(Location location)
: location_(location), blabel_(NULL)
: location_(location), derived_from_(NULL), blabel_(NULL)
{ }
// Get the location where the label is defined.
......@@ -2728,6 +2741,16 @@ class Unnamed_label
set_location(Location location)
{ this->location_ = location; }
// Get the top level statement this unnamed label is derived from.
Statement*
derived_from() const
{ return this->derived_from_; }
// Set the top level statement this unnamed label is derived from.
void
set_derived_from(Statement* s)
{ this->derived_from_ = s; }
// Return a statement which defines this label.
Bstatement*
get_definition(Translate_context*);
......@@ -2743,6 +2766,9 @@ class Unnamed_label
// The location where the label is defined.
Location location_;
// The top-level statement this unnamed label was derived/lowered from.
// This is NULL is this label is not the top-level of a lowered statement.
Statement* derived_from_;
// The backend representation of this label.
Blabel* blabel_;
};
......
......@@ -3058,7 +3058,6 @@ Unnamed_label_statement::do_get_backend(Translate_context* context)
return this->label_->get_definition(context);
}
// Dump the AST representation for an unnamed label definition statement.
void
......@@ -5091,6 +5090,7 @@ For_statement::do_lower(Gogo*, Named_object*, Block* enclosing,
}
Unnamed_label* top = new Unnamed_label(this->location());
top->set_derived_from(this);
b->add_statement(Statement::make_unnamed_label_statement(top));
s = Statement::make_block_statement(this->statements_,
......
......@@ -69,6 +69,10 @@ frequire-return-statement
Go Var(go_require_return_statement) Init(1) Warning
Functions which return values must end with return statements.
fgo-debug-escape
Go Joined UInteger Var(go_debug_escape_level) Init(0)
Emit debugging information related to the escape analysis pass when run with -fgo-optimize-allocs.
o
Go Joined Separate
; Documented in common.opt
......
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