This patch to the Go frontend, by Chris Manghane, adds the -fgo-optimize-allocs option. This turns on escape analysis. However, escape analysis is still not turned on by default. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 239100) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -3096ac81185edacbf800783f0f803d1c419dccdd +4ba387176e8a826dd5dd6cad4caa2f93434d0b14 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/escape.cc =================================================================== --- gcc/go/gofrontend/escape.cc (revision 239002) +++ gcc/go/gofrontend/escape.cc (working copy) @@ -14,6 +14,7 @@ #include "statements.h" #include "escape.h" #include "ast-dump.h" +#include "go-optimize.h" // class Node. @@ -678,11 +679,19 @@ Escape_note::parse_tag(std::string* tag) return encoding; } + +// The -fgo-optimize-alloc flag activates this escape analysis. + +Go_optimize optimize_allocation_flag("allocs"); + // Analyze the program flow for escape information. void Gogo::analyze_escape() { + if (!optimize_allocation_flag.is_enabled() || saw_errors()) + return; + // Discover strongly connected groups of functions to analyze for escape // information in this package. this->discover_analysis_sets(); Index: gcc/go/gofrontend/go.cc =================================================================== --- gcc/go/gofrontend/go.cc (revision 239002) +++ gcc/go/gofrontend/go.cc (working copy) @@ -112,6 +112,8 @@ go_parse_input_files(const char** filena if (only_check_syntax) return; + ::gogo->analyze_escape(); + // Export global identifiers as appropriate. ::gogo->do_exports();