Skip to content

Commit 3a7ea22

Browse files
author
ian
committed
escape: Enable escape analysis in gccgo.
Off by default, enabled through -fgo-optimize-allocs. Reviewed-on: https://go-review.googlesource.com/22378 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239109 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 84c4c3c commit 3a7ea22

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

gcc/go/gofrontend/MERGE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
3096ac81185edacbf800783f0f803d1c419dccdd
1+
4ba387176e8a826dd5dd6cad4caa2f93434d0b14
22

33
The first line of this file holds the git revision number of the last
44
merge done from the gofrontend repository.

gcc/go/gofrontend/escape.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "statements.h"
1515
#include "escape.h"
1616
#include "ast-dump.h"
17+
#include "go-optimize.h"
1718

1819
// class Node.
1920

@@ -678,11 +679,19 @@ Escape_note::parse_tag(std::string* tag)
678679
return encoding;
679680
}
680681

682+
683+
// The -fgo-optimize-alloc flag activates this escape analysis.
684+
685+
Go_optimize optimize_allocation_flag("allocs");
686+
681687
// Analyze the program flow for escape information.
682688

683689
void
684690
Gogo::analyze_escape()
685691
{
692+
if (!optimize_allocation_flag.is_enabled() || saw_errors())
693+
return;
694+
686695
// Discover strongly connected groups of functions to analyze for escape
687696
// information in this package.
688697
this->discover_analysis_sets();

gcc/go/gofrontend/go.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ go_parse_input_files(const char** filenames, unsigned int filename_count,
112112
if (only_check_syntax)
113113
return;
114114

115+
::gogo->analyze_escape();
116+
115117
// Export global identifiers as appropriate.
116118
::gogo->do_exports();
117119

0 commit comments

Comments
 (0)