aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-06-10 19:30:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-06-10 19:30:21 +0000
commitc2f879e1fe5b388fb0fcfee97f97fcbeae765e83 (patch)
treeb0d0979b7a397c489b1c465432ff8e85c11e67f0
parentf359611b363490b48a7ce0fd021f7e47d8816eb0 (diff)
downloadgcc-c2f879e1fe5b388fb0fcfee97f97fcbeae765e83.zip
gcc-c2f879e1fe5b388fb0fcfee97f97fcbeae765e83.tar.gz
gcc-c2f879e1fe5b388fb0fcfee97f97fcbeae765e83.tar.bz2
compiler: make escape analysis work with imported inlineable functions
The escape analysis was written before we import inlineable function bodies, and in some places it skipped functions that are not in the local package. Now that there are imported function bodies, make the escape analysis work with them. Note that it is necessary for the escape analysis to run on imported function bodies, even if they are already tagged. The tags only have the information of the parameters (receiver, results), but not the internal nodes, e.g. local variables. We still need to do the analysis to get all the information. (In the future maybe we could export/import escape info for internal nodes also, then we don't need to redo the analysis.) Also add assertions to ensure that if we analyze the same function in multiple places, they'd better agree with each other. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/181537 From-SVN: r272124
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/escape.cc14
-rw-r--r--gcc/go/gofrontend/types.h7
3 files changed, 9 insertions, 14 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 91b85c0..eae2756 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-b79e9e79fddc9040ab58c7c518eb08454f308def
+a32739aadf0c7a65fcd5d5b6d0a0d206bff24a4f
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/escape.cc b/gcc/go/gofrontend/escape.cc
index 2957c0d..a155834 100644
--- a/gcc/go/gofrontend/escape.cc
+++ b/gcc/go/gofrontend/escape.cc
@@ -2773,15 +2773,8 @@ Gogo::assign_connectivity(Escape_context* context, Named_object* fn)
if (!p->type()->has_pointer())
continue;
- // External function? Parameters must escape unless //go:noescape is set.
- // TODO(cmang): Implement //go:noescape directive.
- if (fn->package() != NULL)
- param_node->set_encoding(Node::ESCAPE_HEAP);
- else
- {
- param_node->set_encoding(Node::ESCAPE_NONE);
- context->track(param_node);
- }
+ param_node->set_encoding(Node::ESCAPE_NONE);
+ context->track(param_node);
}
Escape_analysis_loop el;
@@ -3319,9 +3312,6 @@ Escape_analysis_tag::tag(Named_object* fn)
{
// External functions are assumed unsafe
// unless //go:noescape is given before the declaration.
- if (fn->package() != NULL)
- return;
-
if (fn->is_function_declaration())
{
Function_declaration* fdcl = fn->func_declaration_value();
diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h
index 375f711..2b51df5 100644
--- a/gcc/go/gofrontend/types.h
+++ b/gcc/go/gofrontend/types.h
@@ -1494,7 +1494,12 @@ class Typed_identifier
// Set the escape note.
void
set_note(const std::string& note)
- { this->note_ = new std::string(note); }
+ {
+ if (this->note_ != NULL)
+ go_assert(*this->note_ == note);
+ else
+ this->note_ = new std::string(note);
+ }
private:
// Identifier name.