From: Ian Lance Taylor Date: Wed, 8 Jan 2020 00:38:34 +0000 (+0000) Subject: compiler: fix loopdepth tracking in array slicing expression in escape analysis X-Git-Tag: releases/gcc-9.3.0~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae0b4a0a1c0ddda91b7d4ce5faba854a5332b2ed;p=thirdparty%2Fgcc.git compiler: fix loopdepth tracking in array slicing expression in escape analysis In the gc compiler, for slicing an array, its AST has an implicit address operation node. There isn't such node in the gofrontend AST. During the escape analysis, we create a fake node to mimic the gc compiler's behavior. For the fake node, the loopdepth was not tracked correctly, causing miscompilation. Since this is an address operation, do the same thing as we do for the address operator. Fixes golang/go#36404. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/213643 From-SVN: r279985 --- diff --git a/gcc/go/gofrontend/escape.cc b/gcc/go/gofrontend/escape.cc index e1c98094831f..23fa7552f4cb 100644 --- a/gcc/go/gofrontend/escape.cc +++ b/gcc/go/gofrontend/escape.cc @@ -1879,7 +1879,8 @@ Escape_analysis_assign::expression(Expression** pexpr) this->context_->track(addr_node); Node::Escape_state* addr_state = addr_node->state(this->context_, NULL); - addr_state->loop_depth = array_state->loop_depth; + if (array_state->loop_depth != 0) + addr_state->loop_depth = array_state->loop_depth; } } break;