diff options
author | Than McIntosh <thanm@google.com> | 2017-05-12 16:36:50 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-05-12 16:36:50 +0000 |
commit | da55a299c5159a622bcf04bf3f97707f5335bcad (patch) | |
tree | 6ae18ad0b0ccac78b05dd11e1c152bafdda97e4d /gcc/go | |
parent | 9dd19976b1b01fd5490fe9f3e840153db8a9610b (diff) | |
download | gcc-da55a299c5159a622bcf04bf3f97707f5335bcad.zip gcc-da55a299c5159a622bcf04bf3f97707f5335bcad.tar.gz gcc-da55a299c5159a622bcf04bf3f97707f5335bcad.tar.bz2 |
compiler: add calling Bfunction Backend::call_expression
Pass in the calling (containing) Bfunction when invoking the Backend
method call_expression(), so as to handle the case where generation of
the call forces the creation of a temp var within the calling
function.
Reviewed-on: https://go-review.googlesource.com/43270
From-SVN: r247981
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/go/go-gcc.cc | 9 | ||||
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/backend.h | 6 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 9 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 6 |
6 files changed, 24 insertions, 12 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 1155000..59b4e6e 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2017-05-12 Than McIntosh <thanm@google.com> + + * go-gcc.cc (Gcc_backend::call_expression): Add caller parameter. + 2017-05-11 Ian Lance Taylor <iant@google.com> PR go/64238 diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 06bc6d7..a7977fe 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -348,7 +348,8 @@ class Gcc_backend : public Backend array_index_expression(Bexpression* array, Bexpression* index, Location); Bexpression* - call_expression(Bexpression* fn, const std::vector<Bexpression*>& args, + call_expression(Bfunction* caller, Bexpression* fn, + const std::vector<Bexpression*>& args, Bexpression* static_chain, Location); Bexpression* @@ -1892,9 +1893,11 @@ Gcc_backend::array_index_expression(Bexpression* array, Bexpression* index, // Create an expression for a call to FN_EXPR with FN_ARGS. Bexpression* -Gcc_backend::call_expression(Bexpression* fn_expr, +Gcc_backend::call_expression(Bfunction*, // containing fcn for call + Bexpression* fn_expr, const std::vector<Bexpression*>& fn_args, - Bexpression* chain_expr, Location location) + Bexpression* chain_expr, + Location location) { tree fn = fn_expr->get_tree(); if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index f4bcf46..0221986 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -d5bfa6cebb19a154cbfbc53f6e647d2ca7adef68 +2f21020c9f61b31bd04d5b814aaa27bf976bf07a 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/backend.h b/gcc/go/gofrontend/backend.h index e51efe4ef..9951a72 100644 --- a/gcc/go/gofrontend/backend.h +++ b/gcc/go/gofrontend/backend.h @@ -372,9 +372,11 @@ class Backend virtual Bexpression* array_index_expression(Bexpression* array, Bexpression* index, Location) = 0; - // Create an expression for a call to FN with ARGS. + // Create an expression for a call to FN with ARGS, taking place within + // caller CALLER. virtual Bexpression* - call_expression(Bexpression* fn, const std::vector<Bexpression*>& args, + call_expression(Bfunction *caller, Bexpression* fn, + const std::vector<Bexpression*>& args, Bexpression* static_chain, Location) = 0; // Return an expression that allocates SIZE bytes on the stack. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index ecafe16..c5e9a0b 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -10290,13 +10290,16 @@ Call_expression::do_get_backend(Translate_context* context) bfn = gogo->backend()->convert_expression(bft, bfn, location); } - Bexpression* call = gogo->backend()->call_expression(bfn, fn_args, - bclosure, location); + Bfunction* bfunction = NULL; + if (context->function()) + bfunction = context->function()->func_value()->get_decl(); + Bexpression* call = gogo->backend()->call_expression(bfunction, bfn, + fn_args, bclosure, + location); if (this->results_ != NULL) { Bexpression* bcall_ref = this->call_result_ref(context); - Bfunction* bfunction = context->function()->func_value()->get_decl(); Bstatement* assn_stmt = gogo->backend()->assignment_statement(bfunction, bcall_ref, call, location); diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 12135d7..b076b87 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -708,8 +708,8 @@ Gogo::init_imports(std::vector<Bstatement*>& init_stmts, Bfunction *bfunction) Bexpression* pfunc_code = this->backend()->function_code_expression(pfunc, unknown_loc); Bexpression* pfunc_call = - this->backend()->call_expression(pfunc_code, empty_args, - NULL, unknown_loc); + this->backend()->call_expression(bfunction, pfunc_code, empty_args, + NULL, unknown_loc); init_stmts.push_back(this->backend()->expression_statement(bfunction, pfunc_call)); } @@ -1498,7 +1498,7 @@ Gogo::write_globals() Bfunction* initfn = func->get_or_make_decl(this, *p); Bexpression* func_code = this->backend()->function_code_expression(initfn, func_loc); - Bexpression* call = this->backend()->call_expression(func_code, + Bexpression* call = this->backend()->call_expression(initfn, func_code, empty_args, NULL, func_loc); Bstatement* ist = this->backend()->expression_statement(initfn, call); |