aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/ChangeLog8
-rw-r--r--gcc/go/gccgo.texi5
-rw-r--r--gcc/go/go-c.h1
-rw-r--r--gcc/go/go-lang.c1
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/go.cc2
-rw-r--r--gcc/go/gofrontend/gogo.cc1
-rw-r--r--gcc/go/gofrontend/gogo.h13
-rw-r--r--gcc/go/gofrontend/statements.cc4
-rw-r--r--gcc/go/lang.opt4
10 files changed, 40 insertions, 1 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index 2c88593..a73072f 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,11 @@
+2019-05-07 Cherry Zhang <cherryyz@google.com>
+
+ * lang.opt (-fgo-debug-optimization): New option.
+ * go-c.h (struct go_create_gogo_args): Add debug_optimization
+ field.
+ * go-lang.c (go_langhook_init): Set debug_optimization field.
+ * gccgo.texi (Invoking gccgo): Document -fgo-debug-optimization.
+
2019-03-06 Ian Lance Taylor <iant@golang.org>
PR go/89227
diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi
index 23101954..92fd745 100644
--- a/gcc/go/gccgo.texi
+++ b/gcc/go/gccgo.texi
@@ -246,6 +246,11 @@ This runs escape analysis only on functions whose names hash to values
that match the given suffix @var{n}. This can be used to binary
search across functions to uncover escape analysis bugs.
+@item -fgo-debug-optimization
+@cindex @option{-fgo-debug-optimization}
+@cindex @option{-fno-go-debug-optimization}
+Output optimization diagnostics.
+
@item -fgo-c-header=@var{file}
@cindex @option{-fgo-c-header}
Write top-level named Go struct definitions to @var{file} as C code.
diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h
index 42e86cd..695484c 100644
--- a/gcc/go/go-c.h
+++ b/gcc/go/go-c.h
@@ -49,6 +49,7 @@ struct go_create_gogo_args
int debug_escape_level;
const char* debug_escape_hash;
int64_t nil_check_size_threshold;
+ bool debug_optimization;
};
extern void go_create_gogo (const struct go_create_gogo_args*);
diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c
index dd22fda..94f2cb2 100644
--- a/gcc/go/go-lang.c
+++ b/gcc/go/go-lang.c
@@ -118,6 +118,7 @@ go_langhook_init (void)
args.debug_escape_level = go_debug_escape_level;
args.debug_escape_hash = go_debug_escape_hash;
args.nil_check_size_threshold = TARGET_AIX ? -1 : 4096;
+ args.debug_optimization = go_debug_optimization;
args.linemap = go_get_linemap();
args.backend = go_get_backend();
go_create_gogo (&args);
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 6cb0662..aafb52c 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-4b3015de639cf22ed11ff96097555700909827c8
+dc9c1b43753f392fdc2045bcb7a4abaa44fe79f1
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/go.cc b/gcc/go/gofrontend/go.cc
index d8da232..183664a 100644
--- a/gcc/go/gofrontend/go.cc
+++ b/gcc/go/gofrontend/go.cc
@@ -44,6 +44,8 @@ go_create_gogo(const struct go_create_gogo_args* args)
if (args->debug_escape_hash != NULL)
::gogo->set_debug_escape_hash(args->debug_escape_hash);
::gogo->set_nil_check_size_threshold(args->nil_check_size_threshold);
+ if (args->debug_optimization)
+ ::gogo->set_debug_optimization(args->debug_optimization);
}
// Parse the input files.
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index f45576e..9f18e14 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -55,6 +55,7 @@ Gogo::Gogo(Backend* backend, Linemap* linemap, int, int pointer_size)
check_divide_overflow_(true),
compiling_runtime_(false),
debug_escape_level_(0),
+ debug_optimization_(false),
nil_check_size_threshold_(4096),
verify_types_(),
interface_types_(),
diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h
index 1c9f0de..cfa238a 100644
--- a/gcc/go/gofrontend/gogo.h
+++ b/gcc/go/gofrontend/gogo.h
@@ -326,6 +326,16 @@ class Gogo
set_debug_escape_hash(const std::string& s)
{ this->debug_escape_hash_ = s; }
+ // Return whether to output optimization diagnostics.
+ bool
+ debug_optimization() const
+ { return this->debug_optimization_; }
+
+ // Set the option to output optimization diagnostics.
+ void
+ set_debug_optimization(bool b)
+ { this->debug_optimization_ = b; }
+
// Return the size threshold used to determine whether to issue
// a nil-check for a given pointer dereference. A threshold of -1
// implies that all potentially faulting dereference ops should
@@ -1075,6 +1085,9 @@ class Gogo
// -fgo-debug-escape-hash option. The analysis is run only on
// functions with names that hash to the matching value.
std::string debug_escape_hash_;
+ // Whether to output optimization diagnostics, from the
+ // -fgo-debug-optimization option.
+ bool debug_optimization_;
// Nil-check size threshhold.
int64_t nil_check_size_threshold_;
// A list of types to verify.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 1827f81..2e2d039 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -5512,6 +5512,8 @@ For_range_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing,
range_temp, loc);
if (clear != NULL)
{
+ if (gogo->debug_optimization())
+ go_inform(loc, "map range clear");
temp_block->add_statement(clear);
return Statement::make_block_statement(temp_block, loc);
}
@@ -5527,6 +5529,8 @@ For_range_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing,
range_temp, loc);
if (clear != NULL)
{
+ if (gogo->debug_optimization())
+ go_inform(loc, "array range clear");
temp_block->add_statement(clear);
return Statement::make_block_statement(temp_block, loc);
}
diff --git a/gcc/go/lang.opt b/gcc/go/lang.opt
index f1a81266..91b8e46 100644
--- a/gcc/go/lang.opt
+++ b/gcc/go/lang.opt
@@ -85,6 +85,10 @@ fgo-debug-escape-hash=
Go Joined RejectNegative Var(go_debug_escape_hash) Init(0)
-fgo-debug-escape-hash=<string> Hash value to debug escape analysis.
+fgo-debug-optimization
+Go Var(go_debug_optimization) Init(0)
+Emit optimization diagnostics.
+
o
Go Joined Separate
; Documented in common.opt