From patchwork Mon Oct 23 21:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 157108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1555533vqx; Mon, 23 Oct 2023 14:10:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ+7zA8Met79z3s33J8lg+3l2z4ZEYc2m84cZRkN09zyJyXtBkz5Sf+WtFEAtuVdZFWT2I X-Received: by 2002:a05:622a:1449:b0:41c:bbbc:2ede with SMTP id v9-20020a05622a144900b0041cbbbc2edemr12523186qtx.14.1698095414524; Mon, 23 Oct 2023 14:10:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698095414; cv=pass; d=google.com; s=arc-20160816; b=FAlt9GPMjnADpTQGrgwjP4/HxXhTdz5UbRJ6Z5DSpPuLVSYbgEzJXQLartiepIiLbT j+/AlJA7ObJeTTkKTLyDe0+rp8s9lxR2HRkrQDAObIZ5CkZb976tM7W4/oilO8o7qUDA 8vUzPQh641NH2tXPX+sHhODamLN04y9Y+hUtpbr7SG000tzRvY0tPVofgB7r4d5MKu26 4Qa8zn2hdhO9tkhX1hypIOxIPyupQ3OTW/O16Nn2KwVh86O3NvSF0cL7Oo9tIgYKKiOu C60BxRtGC7i0v0By8mAI3WzB34sy/2937Q/Dey9YVxG1GXZDrYNj1yM4fG/tNPsjSxBJ uPqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:message-id:date:from :mime-version:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=jOMQL8ikn07LJLW3tNmWYLiI8D7GnfYoGTzcG1yeCeI=; fh=sx1AF6BoRLLvWrm7PiL2RBt/kekZxFGoFwZKL1Ho560=; b=Ws3V29/+YtfbQhUgIz8GowaH761WQbA/TxoY1/HEuTxPqWROCuehdmFaXudd3RahH/ mjug73Dfgv+4Lfznyn5lTLePrjtjtyw3U5A4LQ3mNDlfFaYaAZeY12C9GIjpmh66i7+c o8Dz+p8idtntav4u/ojkhN30IkrAJp1iHq7unRsx7Pmse+XNAHAPUdpvbbP61cX5ABs0 c9OFHBlIR1JNDmRaJJvVZh/IuJLI4u+p223/Nk/44mo16cuqeqdCX9Tgyq/MKkhS0ACs xAgqUu0eU5MmzXMbbas74h7T2JBXSDHBUz9dHSpHvOAQ7r6qHWh5mGxy/K/jKVfDpWd8 /VgA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@golang-org.20230601.gappssmtp.com header.s=20230601 header.b=Rdyit5rn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=golang.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b7-20020ac85bc7000000b0041cb9401ca9si6428899qtb.216.2023.10.23.14.10.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@golang-org.20230601.gappssmtp.com header.s=20230601 header.b=Rdyit5rn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=golang.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0EEE1386191F for ; Mon, 23 Oct 2023 21:09:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by sourceware.org (Postfix) with ESMTPS id E05863856948 for ; Mon, 23 Oct 2023 21:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E05863856948 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=golang.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=golang.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E05863856948 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698095352; cv=none; b=RAl0kYtwKLhhT7r2Yz0DI+OoWUH3Tg588NM+fTi5Nhnk0jXzx400JJIzPDzrDNqKdH496pEZCOo9UjiQVbgs8ZalBqjWd059//l82CXopBlaxsnm+Ntn8AH10Md5IoEI+5aIIFhr2cleuL+bk2x/dPSJBhaqbHQgeV29kGadbno= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698095352; c=relaxed/simple; bh=+BTXLtThqp9flKb9W2CK7l4a0BrXdAv6yvox4oEYYVw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=OdHkj5DjgVvfLdrDiMCgTtYs5FbJxyO1G4tocG7OvSNuX63y/sr1Us/ESiqpqNpv/PREhcxTLrhs3IMz3RoQcxgdWBeVD/jOXf5siTqQ5iUVNg11ww217ch76pqTj7j0GIet52D5EwDj57lmpI1JuwzmsYFv9y+tpmLt5b6dt2U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5a7ac4c3666so37675637b3.3 for ; Mon, 23 Oct 2023 14:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20230601.gappssmtp.com; s=20230601; t=1698095342; x=1698700142; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=jOMQL8ikn07LJLW3tNmWYLiI8D7GnfYoGTzcG1yeCeI=; b=Rdyit5rnPFz0MSJTo4UVyIKhVAzc3Ct6cVz3jo97MSmSwcUmF6hvCW0x2R/DUbp5KW 3O0oZGAME9x8IlaeV6ymh0oEiPFjIylHR82yVyVLXR7eysfsjh/YWJet9lZDD+jgjqM/ +FN2VoVoXUTKslG8eugBNH6sBFAs8YUgBUoBxSyPbLsJGQSHws/1uw8/Ewh4tamMmt3D kaD3Z25O41FYRmpeMZpOhmCW4/2NdcZd3RizYuHclReoGTmC8nKA19XzVnt1B/tvMdbT wy17EW/v0NLh1pJcUZ9TCSlmxsLjspyhA3Ctw5EYi9UoBX2gmZjtVKiE3/l4HIF6ptrC 7v8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698095342; x=1698700142; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jOMQL8ikn07LJLW3tNmWYLiI8D7GnfYoGTzcG1yeCeI=; b=dj0oIuxMIeD45mV8+nJH26jlcAzmwdVTJ6Y+D8p0Gkf4RWiT6mjEqIrQPbNF/ExNVu eeBWnh3J4hZQsp+p2rnIiyJwnQ2zMY1x3RPBLgG3YRqOrHJDExQahmZ+oYxB6273sQfi SXE3Kc7WjFZYFgNWOX9ocRUBDzAMxe4MwkwkXIcArL5hZm9mV2XUGatyVCgpZIZNmUKT FSG10A9uv9hp5jnfmMiAHgUteH4Uzj9iyedLHrafCGYnl1GamkxKVntxFT9lWxf4vszi HN5plD2AECNAOM67EhF0GtnMkpOHTCVW+9PtfIHqNWFpIanyIYpiw8mtNN/qs2wI8Q3X 9THQ== X-Gm-Message-State: AOJu0Yx3dGBrzOPaAewJEGYNNIMUZ0SlLy3km33XfCne+td+gtrQ7N39 rEdi237XQu4j1RCS1pmtbSzBykKvwtCrv9U8YE2aALTGHVvk/gGqbCo= X-Received: by 2002:a0d:e84f:0:b0:5a8:5079:422 with SMTP id r76-20020a0de84f000000b005a850790422mr11275661ywe.26.1698095342639; Mon, 23 Oct 2023 14:09:02 -0700 (PDT) MIME-Version: 1.0 From: Ian Lance Taylor Date: Mon, 23 Oct 2023 14:08:51 -0700 Message-ID: Subject: Go patch committed: Pass Gogo to Runtime::make_call To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780582097642921730 X-GMAIL-MSGID: 1780582097642921730 This Go frontend patches passes the Gogo IR pointer to Runtime::make_call. This is a boilerplate change that doesn't affect compiler output. It's not currently used but will be used by later CLs in this series. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 45a5ab0503569e57883dca4d8e76d83dc3a60ff6 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d4095637cea..d962c4f5770 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -1c0a7c9338801d15afba7e39109554ed3406654e +806217827fe30553d535f876f182a9e92f5f648e 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/expressions.cc b/gcc/go/gofrontend/expressions.cc index 5bea6238def..c7b442d3a03 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -305,8 +305,8 @@ Expression::convert_for_assignment(Gogo* gogo, Type* lhs_type, { // Type to interface conversions have been made explicit early. go_assert(rhs_type->interface_type() != NULL); - return Expression::convert_interface_to_interface(lhs_type, rhs, false, - location); + return Expression::convert_interface_to_interface(gogo, lhs_type, rhs, + false, location); } else if (!are_identical && rhs_type->interface_type() != NULL) return Expression::convert_interface_to_type(gogo, lhs_type, rhs, location); @@ -525,7 +525,8 @@ Expression::get_interface_type_descriptor(Expression* rhs) // interface type. Expression* -Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs, +Expression::convert_interface_to_interface(Gogo* gogo, Type *lhs_type, + Expression* rhs, bool for_type_guard, Location location) { @@ -558,7 +559,7 @@ Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs, if (for_type_guard) { // A type assertion fails when converting a nil interface. - first_field = Runtime::make_call(Runtime::ASSERTITAB, location, 2, + first_field = Runtime::make_call(gogo, Runtime::ASSERTITAB, location, 2, lhs_type_expr, rhs_type_expr); } else if (lhs_is_empty) @@ -571,7 +572,7 @@ Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs, { // A conversion to a non-empty interface may fail, but unlike a // type assertion converting nil will always succeed. - first_field = Runtime::make_call(Runtime::REQUIREITAB, location, 2, + first_field = Runtime::make_call(gogo, Runtime::REQUIREITAB, location, 2, lhs_type_expr, rhs_type_expr); } @@ -610,7 +611,7 @@ Expression::convert_interface_to_type(Gogo* gogo, Type *lhs_type, Expression* rh Expression* cond; if (gogo->need_eqtype()) { - cond = Runtime::make_call(Runtime::EQTYPE, location, + cond = Runtime::make_call(gogo, Runtime::EQTYPE, location, 2, lhs_type_expr, rhs_descriptor); } else { @@ -619,7 +620,7 @@ Expression::convert_interface_to_type(Gogo* gogo, Type *lhs_type, Expression* rh } rhs_descriptor = Expression::get_interface_type_descriptor(rhs); - Expression* panic = Runtime::make_call(Runtime::PANICDOTTYPE, location, + Expression* panic = Runtime::make_call(gogo, Runtime::PANICDOTTYPE, location, 3, lhs_type_expr->copy(), rhs_descriptor, rhs_inter_expr); @@ -719,7 +720,8 @@ Expression::backend_numeric_constant_expression(Translate_context* context, // functions, which will panic. void -Expression::check_bounds(Expression* val, Operator op, Expression* bound, +Expression::check_bounds(Gogo* gogo, Expression* val, Operator op, + Expression* bound, Runtime::Function code, Runtime::Function code_u, Runtime::Function code_extend, @@ -813,7 +815,7 @@ Expression::check_bounds(Expression* val, Operator op, Expression* bound, } Expression* ignore = Expression::make_boolean(true, loc); - Expression* crash = Runtime::make_call(c, loc, 2, + Expression* crash = Runtime::make_call(gogo, c, loc, 2, val->copy(), bound->copy()); Expression* cond = Expression::make_conditional(check, ignore, crash, loc); inserter->insert(Statement::make_statement(cond, true)); @@ -3916,7 +3918,7 @@ Type_conversion_expression::do_traverse(Traverse* traverse) // from slice to pointer-to-array, as they can panic. Expression* -Type_conversion_expression::do_lower(Gogo*, Named_object*, +Type_conversion_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter* inserter, int) { Type* type = this->type_; @@ -4037,7 +4039,7 @@ Type_conversion_expression::do_lower(Gogo*, Named_object*, location); vallen = Expression::make_temporary_reference(vallen_temp, location); - Expression* panic = Runtime::make_call(Runtime::PANIC_SLICE_CONVERT, + Expression* panic = Runtime::make_call(gogo, Runtime::PANIC_SLICE_CONVERT, location, 2, arrlen, vallen); Expression* nil = Expression::make_nil(location); @@ -4358,7 +4360,7 @@ Type_conversion_expression::do_get_backend(Translate_context* context) else buf = Expression::make_nil(loc); Expression* i2s_expr = - Runtime::make_call(Runtime::INTSTRING, loc, 2, buf, this->expr_); + Runtime::make_call(gogo, Runtime::INTSTRING, loc, 2, buf, this->expr_); return Expression::make_cast(type, i2s_expr, loc)->get_backend(context); } else if (type->is_string_type() && expr_type->is_slice_type()) @@ -4396,14 +4398,14 @@ Type_conversion_expression::do_get_backend(Translate_context* context) Expression* str = Expression::make_string_value(ptr, len, loc); return str->get_backend(context); } - return Runtime::make_call(Runtime::SLICEBYTETOSTRING, loc, 3, buf, - ptr, len)->get_backend(context); + return Runtime::make_call(gogo, Runtime::SLICEBYTETOSTRING, loc, 3, + buf, ptr, len)->get_backend(context); } else { go_assert(e->integer_type()->is_rune()); - return Runtime::make_call(Runtime::SLICERUNETOSTRING, loc, 2, buf, - this->expr_)->get_backend(context); + return Runtime::make_call(gogo, Runtime::SLICERUNETOSTRING, loc, 2, + buf, this->expr_)->get_backend(context); } } else if (type->is_slice_type() && expr_type->is_string_type()) @@ -4432,7 +4434,8 @@ Type_conversion_expression::do_get_backend(Translate_context* context) } else buf = Expression::make_nil(loc); - Expression* s2a = Runtime::make_call(code, loc, 2, buf, this->expr_); + Expression* s2a = Runtime::make_call(gogo, code, loc, 2, buf, + this->expr_); return Expression::make_unsafe_cast(type, s2a, loc)->get_backend(context); } else if (type->is_numeric_type()) @@ -5480,7 +5483,7 @@ Unary_expression::do_get_backend(Translate_context* context) Bexpression* compare = gogo->backend()->binary_expression(OPERATOR_EQEQ, tbexpr, nil, loc); - Expression* crash = Runtime::make_call(Runtime::PANIC_MEM, + Expression* crash = Runtime::make_call(gogo, Runtime::PANIC_MEM, loc, 0); Bexpression* bcrash = crash->get_backend(context); Bfunction* bfn = context->function()->func_value()->get_decl(); @@ -6626,7 +6629,8 @@ Binary_expression::lower_interface_value_comparison(Gogo*, // Lower a struct or array comparison to a call to memcmp. Expression* -Binary_expression::lower_compare_to_memcmp(Gogo*, Statement_inserter* inserter) +Binary_expression::lower_compare_to_memcmp(Gogo* gogo, + Statement_inserter* inserter) { Location loc = this->location(); @@ -6635,7 +6639,8 @@ Binary_expression::lower_compare_to_memcmp(Gogo*, Statement_inserter* inserter) Expression* len = Expression::make_type_info(this->left_->type(), TYPE_INFO_SIZE); - Expression* call = Runtime::make_call(Runtime::MEMCMP, loc, 3, a1, a2, len); + Expression* call = Runtime::make_call(gogo, Runtime::MEMCMP, loc, 3, + a1, a2, len); Type* int32_type = Type::lookup_integer_type("int32"); Expression* zero = Expression::make_integer_ul(0, int32_type, loc); return Expression::make_binary(this->op_, call, zero, loc); @@ -7337,7 +7342,7 @@ Binary_expression::do_get_backend(Translate_context* context) Bexpression* compare = gogo->backend()->binary_expression(OPERATOR_LT, right, zero_expr, loc); - Expression* crash = Runtime::make_call(Runtime::PANIC_SHIFT, + Expression* crash = Runtime::make_call(gogo, Runtime::PANIC_SHIFT, loc, 0); Bexpression* bcrash = crash->get_backend(context); Bfunction* bfn = context->function()->func_value()->get_decl(); @@ -7358,7 +7363,7 @@ Binary_expression::do_get_backend(Translate_context* context) gogo->backend()->binary_expression(OPERATOR_EQEQ, right, zero_expr, loc); - Expression* crash = Runtime::make_call(Runtime::PANIC_DIVIDE, + Expression* crash = Runtime::make_call(gogo, Runtime::PANIC_DIVIDE, loc, 0); Bexpression* bcrash = crash->get_backend(context); @@ -7661,6 +7666,7 @@ Expression::comparison(Translate_context* context, Type* result_type, Operator op, Expression* left, Expression* right, Location location) { + Gogo* gogo = context->gogo(); Type* left_type = left->type(); Type* right_type = right->type(); @@ -7693,7 +7699,8 @@ Expression::comparison(Translate_context* context, Type* result_type, Expression* ptreq = Expression::make_binary(OPERATOR_EQEQ, lptr, rptr, location); Expression* btrue = Expression::make_boolean(true, location); - Expression* call = Runtime::make_call(Runtime::MEMCMP, location, 3, + Expression* call = Runtime::make_call(gogo, Runtime::MEMCMP, + location, 3, lptr->copy(), rptr->copy(), rlen->copy()); Type* int32_type = Type::lookup_integer_type("int32"); @@ -7708,7 +7715,7 @@ Expression::comparison(Translate_context* context, Type* result_type, } else { - left = Runtime::make_call(Runtime::CMPSTRING, location, 2, + left = Runtime::make_call(gogo, Runtime::CMPSTRING, location, 2, left, right); right = zexpr; } @@ -7742,9 +7749,10 @@ Expression::comparison(Translate_context* context, Type* result_type, Expression* descriptor = Expression::make_type_descriptor(right_type, location); left = - Runtime::make_call((left_type->interface_type()->is_empty() - ? Runtime::EFACEVALEQ - : Runtime::IFACEVALEQ), + Runtime::make_call(gogo, + (left_type->interface_type()->is_empty() + ? Runtime::EFACEVALEQ + : Runtime::IFACEVALEQ), location, 3, left, descriptor, pointer_arg); go_assert(op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ); @@ -7772,7 +7780,8 @@ Expression::comparison(Translate_context* context, Type* result_type, compare_function = Runtime::IFACEEFACEEQ; } - left = Runtime::make_call(compare_function, location, 2, left, right); + left = Runtime::make_call(gogo, compare_function, location, 2, + left, right); go_assert(op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ); right = Expression::make_boolean(true, location); } @@ -7803,7 +7812,6 @@ Expression::comparison(Translate_context* context, Type* result_type, Bexpression* left_bexpr = left->get_backend(context); Bexpression* right_bexpr = right->get_backend(context); - Gogo* gogo = context->gogo(); Bexpression* ret = gogo->backend()->binary_expression(op, left_bexpr, right_bexpr, location); if (result_type != NULL) @@ -7941,7 +7949,7 @@ String_concat_expression::do_check_types(Gogo*) } Expression* -String_concat_expression::do_flatten(Gogo*, Named_object*, +String_concat_expression::do_flatten(Gogo* gogo, Named_object*, Statement_inserter* inserter) { if (this->is_error_expression()) @@ -8011,8 +8019,8 @@ String_concat_expression::do_flatten(Gogo*, Named_object*, Expression* ref = Expression::make_temporary_reference(ts, loc); ref = Expression::make_unary(OPERATOR_AND, ref, loc); Expression* call = - Runtime::make_call(Runtime::CONCATSTRINGS, loc, 3, buf, - ref, len->copy()); + Runtime::make_call(gogo, Runtime::CONCATSTRINGS, loc, 3, + buf, ref, len->copy()); return Expression::make_cast(type, call, loc); } @@ -8377,7 +8385,7 @@ Bound_method_expression::do_flatten(Gogo* gogo, Named_object*, if (nil_check != NULL) { - Expression* crash = Runtime::make_call(Runtime::PANIC_MEM, loc, 0); + Expression* crash = Runtime::make_call(gogo, Runtime::PANIC_MEM, loc, 0); // Fix the type of the conditional expression by pretending to // evaluate to RET either way through the conditional. crash = Expression::make_compound(crash, ret, loc); @@ -8730,7 +8738,7 @@ Builtin_call_expression::do_flatten(Gogo* gogo, Named_object* function, Expression::make_slice_info(arg2, SLICE_INFO_VALUE_POINTER, loc); Expression* ls = Expression::make_slice_info(arg2, SLICE_INFO_LENGTH, loc); - ret = Runtime::make_call(Runtime::TYPEDSLICECOPY, loc, + ret = Runtime::make_call(gogo, Runtime::TYPEDSLICECOPY, loc, 5, td, pd, ld, ps, ls); } else @@ -8786,7 +8794,9 @@ Builtin_call_expression::do_flatten(Gogo* gogo, Named_object* function, : Expression::make_slice_info(arg2, SLICE_INFO_VALUE_POINTER, loc)); - Expression* call = Runtime::make_call(Runtime::BUILTIN_MEMMOVE, loc, 3, + Expression* call = Runtime::make_call(gogo, + Runtime::BUILTIN_MEMMOVE, + loc, 3, p1, p2, sz); // n is the return value of copy @@ -8916,7 +8926,7 @@ Builtin_call_expression::do_flatten(Gogo* gogo, Named_object* function, } } - return Runtime::make_call(code, loc, 3, e1, e2, e3); + return Runtime::make_call(gogo, code, loc, 3, e1, e2, e3); } case BUILTIN_ADD: @@ -8980,7 +8990,7 @@ Builtin_call_expression::do_flatten(Gogo* gogo, Named_object* function, : Runtime::UNSAFESLICE64); Expression* td = Expression::make_type_descriptor(ptr->type()->points_to(), loc); - Expression* check = Runtime::make_call(code, loc, 3, + Expression* check = Runtime::make_call(gogo, code, loc, 3, td, ptr, len); if (ptr_temp == NULL) @@ -9181,8 +9191,8 @@ Builtin_call_expression::lower_make(Gogo* gogo, Statement_inserter* inserter) Runtime::Function code = Runtime::MAKESLICE; if (!len_small || !cap_small) code = Runtime::MAKESLICE64; - Expression* mem = Runtime::make_call(code, loc, 3, type_arg, len_arg, - cap_arg); + Expression* mem = Runtime::make_call(gogo, code, loc, 3, + type_arg, len_arg, cap_arg); mem = Expression::make_unsafe_cast(Type::make_pointer_type(et), mem, loc); Type* int_type = Type::lookup_integer_type("int"); @@ -9194,7 +9204,7 @@ Builtin_call_expression::lower_make(Gogo* gogo, Statement_inserter* inserter) { Expression* type_arg = Expression::make_type_descriptor(type, type_loc); if (!len_small) - call = Runtime::make_call(Runtime::MAKEMAP64, loc, 3, type_arg, + call = Runtime::make_call(gogo, Runtime::MAKEMAP64, loc, 3, type_arg, len_arg, Expression::make_nil(loc)); else @@ -9202,9 +9212,9 @@ Builtin_call_expression::lower_make(Gogo* gogo, Statement_inserter* inserter) if (len_arg->numeric_constant_value(&nclen) && nclen.to_unsigned_long(&vlen) == Numeric_constant::NC_UL_VALID && vlen <= Map_type::bucket_size) - call = Runtime::make_call(Runtime::MAKEMAP_SMALL, loc, 0); + call = Runtime::make_call(gogo, Runtime::MAKEMAP_SMALL, loc, 0); else - call = Runtime::make_call(Runtime::MAKEMAP, loc, 3, type_arg, + call = Runtime::make_call(gogo, Runtime::MAKEMAP, loc, 3, type_arg, len_arg, Expression::make_nil(loc)); } @@ -9215,7 +9225,7 @@ Builtin_call_expression::lower_make(Gogo* gogo, Statement_inserter* inserter) Runtime::Function code = Runtime::MAKECHAN; if (!len_small) code = Runtime::MAKECHAN64; - call = Runtime::make_call(code, loc, 2, type_arg, len_arg); + call = Runtime::make_call(gogo, code, loc, 2, type_arg, len_arg); } else go_unreachable(); @@ -9325,7 +9335,8 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function, loc); len2 = Expression::make_temporary_reference(l2tmp, loc); Expression* cap2 = Expression::make_temporary_reference(c2tmp, loc); - Expression* check = Runtime::make_call(Runtime::CHECK_MAKE_SLICE, + Expression* check = Runtime::make_call(gogo, + Runtime::CHECK_MAKE_SLICE, loc, 3, elem, len2, cap2); gogo->lower_expression(function, inserter, &check); gogo->flatten_expression(function, inserter, &check); @@ -9421,7 +9432,7 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function, Expression* a3 = Expression::make_temporary_reference(l1tmp, loc); Expression* a4 = Expression::make_temporary_reference(c1tmp, loc); Expression* a5 = Expression::make_temporary_reference(ntmp, loc); - Expression* call = Runtime::make_call(Runtime::GROWSLICE, loc, 5, + Expression* call = Runtime::make_call(gogo, Runtime::GROWSLICE, loc, 5, a1, a2, a3, a4, a5); call = Expression::make_unsafe_cast(slice_type, call, loc); @@ -9491,13 +9502,14 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function, a2 = Expression::make_binary(OPERATOR_MULT, a2, ref, loc); if (element_type->has_pointer()) - call = Runtime::make_call(Runtime::MEMCLRHASPTR, loc, 2, a1, a2); + call = Runtime::make_call(gogo, Runtime::MEMCLRHASPTR, loc, 2, + a1, a2); else { Type* int32_type = Type::lookup_integer_type("int32"); zero = Expression::make_integer_ul(0, int32_type, loc); - call = Runtime::make_call(Runtime::BUILTIN_MEMSET, loc, 3, a1, - zero, a2); + call = Runtime::make_call(gogo, Runtime::BUILTIN_MEMSET, loc, 3, + a1, zero, a2); } if (element_type->has_pointer()) @@ -9557,7 +9569,7 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function, a3 = Expression::make_type_info(element_type, TYPE_INFO_SIZE); a3 = Expression::make_binary(OPERATOR_MULT, a3, ref, loc); - call = Runtime::make_call(Runtime::BUILTIN_MEMMOVE, loc, 3, + call = Runtime::make_call(gogo, Runtime::BUILTIN_MEMMOVE, loc, 3, a1, a2, a3); } } @@ -11001,7 +11013,7 @@ Builtin_call_expression::do_get_backend(Translate_context* context) { const bool is_ln = this->code_ == BUILTIN_PRINTLN; - Expression* print_stmts = Runtime::make_call(Runtime::PRINTLOCK, + Expression* print_stmts = Runtime::make_call(gogo, Runtime::PRINTLOCK, location, 0); const Expression_list* call_args = this->args(); @@ -11014,7 +11026,7 @@ Builtin_call_expression::do_get_backend(Translate_context* context) if (is_ln && p != call_args->begin()) { Expression* print_space = - Runtime::make_call(Runtime::PRINTSP, location, 0); + Runtime::make_call(gogo, Runtime::PRINTSP, location, 0); print_stmts = Expression::make_compound(print_stmts, print_space, @@ -11082,7 +11094,8 @@ Builtin_call_expression::do_get_backend(Translate_context* context) return context->backend()->error_expression(); } - Expression* call = Runtime::make_call(code, location, 1, arg); + Expression* call = Runtime::make_call(gogo, code, location, 1, + arg); print_stmts = Expression::make_compound(print_stmts, call, location); } @@ -11091,12 +11104,12 @@ Builtin_call_expression::do_get_backend(Translate_context* context) if (is_ln) { Expression* print_nl = - Runtime::make_call(Runtime::PRINTNL, location, 0); + Runtime::make_call(gogo, Runtime::PRINTNL, location, 0); print_stmts = Expression::make_compound(print_stmts, print_nl, location); } - Expression* unlock = Runtime::make_call(Runtime::PRINTUNLOCK, + Expression* unlock = Runtime::make_call(gogo, Runtime::PRINTUNLOCK, location, 0); print_stmts = Expression::make_compound(print_stmts, unlock, location); @@ -11113,7 +11126,7 @@ Builtin_call_expression::do_get_backend(Translate_context* context) arg = Expression::convert_for_assignment(gogo, empty, arg, location); Expression* panic = - Runtime::make_call(Runtime::GOPANIC, location, 1, arg); + Runtime::make_call(gogo, Runtime::GOPANIC, location, 1, arg); return panic->get_backend(context); } @@ -11133,7 +11146,8 @@ Builtin_call_expression::do_get_backend(Translate_context* context) // We need to handle a deferred call to recover specially, // because it changes whether it can recover a panic or not. // See test7 in test/recover1.go. - Expression* recover = Runtime::make_call((this->is_deferred() + Expression* recover = Runtime::make_call(gogo, + (this->is_deferred() ? Runtime::DEFERREDRECOVER : Runtime::GORECOVER), location, 0); @@ -11147,7 +11161,7 @@ Builtin_call_expression::do_get_backend(Translate_context* context) const Expression_list* args = this->args(); go_assert(args != NULL && args->size() == 1); Expression* arg = args->front(); - Expression* close = Runtime::make_call(Runtime::CLOSE, location, + Expression* close = Runtime::make_call(gogo, Runtime::CLOSE, location, 1, arg); return close->get_backend(context); } @@ -11925,7 +11939,7 @@ Call_expression::intrinsify(Gogo* gogo, { Expression* arg = Expression::make_integer_ul(0, uint32_type, loc); Expression* call = - Runtime::make_call(Runtime::BUILTIN_RETURN_ADDRESS, loc, + Runtime::make_call(gogo, Runtime::BUILTIN_RETURN_ADDRESS, loc, 1, arg); // The builtin functions return void*, but the Go functions return uintptr. return Expression::make_cast(uintptr_type, call, loc); @@ -11935,7 +11949,7 @@ Call_expression::intrinsify(Gogo* gogo, { Expression* call = - Runtime::make_call(Runtime::BUILTIN_DWARF_CFA, loc, 0); + Runtime::make_call(gogo, Runtime::BUILTIN_DWARF_CFA, loc, 0); // The builtin functions return void*, but the Go functions return uintptr. return Expression::make_cast(uintptr_type, call, loc); } @@ -11961,7 +11975,7 @@ Call_expression::intrinsify(Gogo* gogo, else go_unreachable(); Expression* arg = this->args_->front(); - Expression* call = Runtime::make_call(code, loc, 1, arg); + Expression* call = Runtime::make_call(gogo, code, loc, 1, arg); if (name == "ReverseBytes") return Expression::make_cast(uint_type, call, loc); return call; @@ -11976,7 +11990,8 @@ Call_expression::intrinsify(Gogo* gogo, unsigned long mask = (name == "TrailingZeros8" ? 0x100 : 0x10000); Expression* c = Expression::make_integer_ul(mask, uint32_type, loc); arg = Expression::make_binary(OPERATOR_OR, arg, c, loc); - Expression* call = Runtime::make_call(Runtime::BUILTIN_CTZ, loc, 1, arg); + Expression* call = Runtime::make_call(gogo, Runtime::BUILTIN_CTZ, + loc, 1, arg); return Expression::make_cast(int_type, call, loc); } else if ((name == "TrailingZeros32" @@ -11994,7 +12009,8 @@ Call_expression::intrinsify(Gogo* gogo, Expression* zero = Expression::make_integer_ul(0, uint32_type, loc); Expression* cmp = Expression::make_binary(OPERATOR_EQEQ, arg, zero, loc); Expression* c32 = Expression::make_integer_ul(32, int_type, loc); - Expression* call = Runtime::make_call(Runtime::BUILTIN_CTZ, loc, 1, arg->copy()); + Expression* call = Runtime::make_call(gogo, Runtime::BUILTIN_CTZ, + loc, 1, arg->copy()); call = Expression::make_cast(int_type, call, loc); return Expression::make_conditional(cmp, c32, call, loc); } @@ -12013,7 +12029,8 @@ Call_expression::intrinsify(Gogo* gogo, Expression* zero = Expression::make_integer_ul(0, uint64_type, loc); Expression* cmp = Expression::make_binary(OPERATOR_EQEQ, arg, zero, loc); Expression* c64 = Expression::make_integer_ul(64, int_type, loc); - Expression* call = Runtime::make_call(Runtime::BUILTIN_CTZLL, loc, 1, arg->copy()); + Expression* call = Runtime::make_call(gogo, Runtime::BUILTIN_CTZLL, + loc, 1, arg->copy()); call = Expression::make_cast(int_type, call, loc); return Expression::make_conditional(cmp, c64, call, loc); } @@ -12033,7 +12050,8 @@ Call_expression::intrinsify(Gogo* gogo, ((name == "LeadingZeros8" || name == "Len8") ? 0xffffff : 0xffff); c = Expression::make_integer_ul(mask, uint32_type, loc); arg = Expression::make_binary(OPERATOR_OR, arg, c, loc); - Expression* call = Runtime::make_call(Runtime::BUILTIN_CLZ, loc, 1, arg); + Expression* call = Runtime::make_call(gogo, Runtime::BUILTIN_CLZ, + loc, 1, arg); call = Expression::make_cast(int_type, call, loc); // len = width - clz if (name == "Len8") @@ -12063,7 +12081,8 @@ Call_expression::intrinsify(Gogo* gogo, Expression* zero = Expression::make_integer_ul(0, uint32_type, loc); Expression* cmp = Expression::make_binary(OPERATOR_EQEQ, arg, zero, loc); Expression* c32 = Expression::make_integer_ul(32, int_type, loc); - Expression* call = Runtime::make_call(Runtime::BUILTIN_CLZ, loc, 1, arg->copy()); + Expression* call = Runtime::make_call(gogo, Runtime::BUILTIN_CLZ, + loc, 1, arg->copy()); call = Expression::make_cast(int_type, call, loc); Expression* cond = Expression::make_conditional(cmp, c32, call, loc); // len = 32 - clz @@ -12086,7 +12105,8 @@ Call_expression::intrinsify(Gogo* gogo, Expression* zero = Expression::make_integer_ul(0, uint64_type, loc); Expression* cmp = Expression::make_binary(OPERATOR_EQEQ, arg, zero, loc); Expression* c64 = Expression::make_integer_ul(64, int_type, loc); - Expression* call = Runtime::make_call(Runtime::BUILTIN_CLZLL, loc, 1, arg->copy()); + Expression* call = Runtime::make_call(gogo, Runtime::BUILTIN_CLZLL, + loc, 1, arg->copy()); call = Expression::make_cast(int_type, call, loc); Expression* cond = Expression::make_conditional(cmp, c64, call, loc); // len = 64 - clz @@ -12107,7 +12127,7 @@ Call_expression::intrinsify(Gogo* gogo, else code = Runtime::BUILTIN_POPCOUNT; Expression* arg = this->args_->front(); - Expression* call = Runtime::make_call(code, loc, 1, arg); + Expression* call = Runtime::make_call(gogo, code, loc, 1, arg); return Expression::make_cast(int_type, call, loc); } } @@ -12311,7 +12331,7 @@ Call_expression::intrinsify(Gogo* gogo, go_unreachable(); Expression* a1 = this->args_->front(); Expression* a2 = Expression::make_integer_ul(memorder, int32_type, loc); - Expression* call = Runtime::make_call(code, loc, 2, a1, a2); + Expression* call = Runtime::make_call(gogo, code, loc, 2, a1, a2); return Expression::make_unsafe_cast(res_type, call, loc); } @@ -12352,7 +12372,7 @@ Call_expression::intrinsify(Gogo* gogo, else go_unreachable(); Expression* a3 = Expression::make_integer_ul(memorder, int32_type, loc); - return Runtime::make_call(code, loc, 3, a1, a2, a3); + return Runtime::make_call(gogo, code, loc, 3, a1, a2, a3); } if ((name == "Xchg" || name == "Xchg64" || name == "Xchguintptr" @@ -12396,7 +12416,7 @@ Call_expression::intrinsify(Gogo* gogo, Expression* a1 = this->args_->at(0); Expression* a2 = this->args_->at(1); Expression* a3 = Expression::make_integer_ul(memorder, int32_type, loc); - Expression* call = Runtime::make_call(code, loc, 3, a1, a2, a3); + Expression* call = Runtime::make_call(gogo, code, loc, 3, a1, a2, a3); return Expression::make_cast(res_type, call, loc); } @@ -12450,7 +12470,7 @@ Call_expression::intrinsify(Gogo* gogo, Expression* a4 = Expression::make_boolean(false, loc); Expression* a5 = Expression::make_integer_ul(memorder, int32_type, loc); Expression* a6 = Expression::make_integer_ul(__ATOMIC_RELAXED, int32_type, loc); - return Runtime::make_call(code, loc, 6, a1, a2, a3, a4, a5, a6); + return Runtime::make_call(gogo, code, loc, 6, a1, a2, a3, a4, a5, a6); } if ((name == "Xadd" || name == "Xadd64" || name == "Xaddint64" @@ -12494,7 +12514,7 @@ Call_expression::intrinsify(Gogo* gogo, Expression* a1 = this->args_->at(0); Expression* a2 = this->args_->at(1); Expression* a3 = Expression::make_integer_ul(memorder, int32_type, loc); - Expression* call = Runtime::make_call(code, loc, 3, a1, a2, a3); + Expression* call = Runtime::make_call(gogo, code, loc, 3, a1, a2, a3); return Expression::make_cast(res_type, call, loc); } @@ -12511,7 +12531,7 @@ Call_expression::intrinsify(Gogo* gogo, Expression* a1 = this->args_->at(0); Expression* a2 = this->args_->at(1); Expression* a3 = Expression::make_integer_ul(memorder, int32_type, loc); - return Runtime::make_call(code, loc, 3, a1, a2, a3); + return Runtime::make_call(gogo, code, loc, 3, a1, a2, a3); } } else if (package == "internal/abi" @@ -13861,14 +13881,14 @@ Array_index_expression::do_flatten(Gogo* gogo, Named_object*, if (cap != NULL) { if (array_type->is_slice_type()) - Expression::check_bounds(cap, OPERATOR_LE, scap, + Expression::check_bounds(gogo, cap, OPERATOR_LE, scap, Runtime::PANIC_SLICE3_ACAP, Runtime::PANIC_SLICE3_ACAP_U, Runtime::PANIC_EXTEND_SLICE3_ACAP, Runtime::PANIC_EXTEND_SLICE3_ACAP_U, inserter, loc); else - Expression::check_bounds(cap, OPERATOR_LE, len, + Expression::check_bounds(gogo, cap, OPERATOR_LE, len, Runtime::PANIC_SLICE3_ALEN, Runtime::PANIC_SLICE3_ALEN_U, Runtime::PANIC_EXTEND_SLICE3_ALEN, @@ -13878,7 +13898,7 @@ Array_index_expression::do_flatten(Gogo* gogo, Named_object*, Expression* start_bound = cap; if (end != NULL && !end->is_nil_expression()) { - Expression::check_bounds(end, OPERATOR_LE, cap, + Expression::check_bounds(gogo, end, OPERATOR_LE, cap, Runtime::PANIC_SLICE3_B, Runtime::PANIC_SLICE3_B_U, Runtime::PANIC_EXTEND_SLICE3_B, @@ -13887,7 +13907,7 @@ Array_index_expression::do_flatten(Gogo* gogo, Named_object*, start_bound = end; } - Expression::check_bounds(start, OPERATOR_LE, start_bound, + Expression::check_bounds(gogo, start, OPERATOR_LE, start_bound, Runtime::PANIC_SLICE3_C, Runtime::PANIC_SLICE3_C_U, Runtime::PANIC_EXTEND_SLICE3_C, @@ -13897,21 +13917,21 @@ Array_index_expression::do_flatten(Gogo* gogo, Named_object*, else if (end != NULL && !end->is_nil_expression()) { if (array_type->is_slice_type()) - Expression::check_bounds(end, OPERATOR_LE, scap, + Expression::check_bounds(gogo, end, OPERATOR_LE, scap, Runtime::PANIC_SLICE_ACAP, Runtime::PANIC_SLICE_ACAP_U, Runtime::PANIC_EXTEND_SLICE_ACAP, Runtime::PANIC_EXTEND_SLICE_ACAP_U, inserter, loc); else - Expression::check_bounds(end, OPERATOR_LE, len, + Expression::check_bounds(gogo, end, OPERATOR_LE, len, Runtime::PANIC_SLICE_ALEN, Runtime::PANIC_SLICE_ALEN_U, Runtime::PANIC_EXTEND_SLICE_ALEN, Runtime::PANIC_EXTEND_SLICE_ALEN_U, inserter, loc); - Expression::check_bounds(start, OPERATOR_LE, end, + Expression::check_bounds(gogo, start, OPERATOR_LE, end, Runtime::PANIC_SLICE_B, Runtime::PANIC_SLICE_B_U, Runtime::PANIC_EXTEND_SLICE_B, @@ -13925,7 +13945,7 @@ Array_index_expression::do_flatten(Gogo* gogo, Named_object*, start_bound = scap; else start_bound = len; - Expression::check_bounds(start, OPERATOR_LE, start_bound, + Expression::check_bounds(gogo, start, OPERATOR_LE, start_bound, Runtime::PANIC_SLICE_B, Runtime::PANIC_SLICE_B_U, Runtime::PANIC_EXTEND_SLICE_B, @@ -13933,7 +13953,7 @@ Array_index_expression::do_flatten(Gogo* gogo, Named_object*, inserter, loc); } else - Expression::check_bounds(start, OPERATOR_LT, len, + Expression::check_bounds(gogo, start, OPERATOR_LT, len, Runtime::PANIC_INDEX, Runtime::PANIC_INDEX_U, Runtime::PANIC_EXTEND_INDEX, @@ -14166,7 +14186,7 @@ String_index_expression::do_traverse(Traverse* traverse) } Expression* -String_index_expression::do_flatten(Gogo*, Named_object*, +String_index_expression::do_flatten(Gogo* gogo, Named_object*, Statement_inserter* inserter) { if (this->is_flattened_) @@ -14228,13 +14248,13 @@ String_index_expression::do_flatten(Gogo*, Named_object*, if (end != NULL && !end->is_nil_expression()) { - Expression::check_bounds(end, OPERATOR_LE, len, + Expression::check_bounds(gogo, end, OPERATOR_LE, len, Runtime::PANIC_SLICE_ALEN, Runtime::PANIC_SLICE_ALEN_U, Runtime::PANIC_EXTEND_SLICE_ALEN, Runtime::PANIC_EXTEND_SLICE_ALEN_U, inserter, loc); - Expression::check_bounds(start, OPERATOR_LE, end, + Expression::check_bounds(gogo, start, OPERATOR_LE, end, Runtime::PANIC_SLICE_B, Runtime::PANIC_SLICE_B_U, Runtime::PANIC_EXTEND_SLICE_B, @@ -14242,14 +14262,14 @@ String_index_expression::do_flatten(Gogo*, Named_object*, inserter, loc); } else if (end != NULL) - Expression::check_bounds(start, OPERATOR_LE, len, + Expression::check_bounds(gogo, start, OPERATOR_LE, len, Runtime::PANIC_SLICE_B, Runtime::PANIC_SLICE_B_U, Runtime::PANIC_EXTEND_SLICE_B, Runtime::PANIC_EXTEND_SLICE_B_U, inserter, loc); else - Expression::check_bounds(start, OPERATOR_LT, len, + Expression::check_bounds(gogo, start, OPERATOR_LT, len, Runtime::PANIC_INDEX, Runtime::PANIC_INDEX_U, Runtime::PANIC_EXTEND_INDEX, @@ -14705,11 +14725,11 @@ Map_index_expression::get_value_pointer(Gogo* gogo) code = Runtime::MAPACCESS1; break; } - map_index = Runtime::make_call(code, loc, 3, + map_index = Runtime::make_call(gogo, code, loc, 3, type_expr, map_ref, key); } else - map_index = Runtime::make_call(Runtime::MAPACCESS1_FAT, loc, 4, + map_index = Runtime::make_call(gogo, Runtime::MAPACCESS1_FAT, loc, 4, type_expr, map_ref, index_ptr, zero); Type* val_type = type->val_type(); @@ -14843,7 +14863,7 @@ Field_reference_expression::do_lower(Gogo* gogo, Named_object* function, e = Expression::make_var_reference(no, loc); e = Expression::make_unary(OPERATOR_AND, e, loc); - Expression* call = Runtime::make_call(Runtime::FIELDTRACK, loc, 1, e); + Expression* call = Runtime::make_call(gogo, Runtime::FIELDTRACK, loc, 1, e); gogo->lower_expression(function, inserter, &call); inserter->insert(Statement::make_statement(call, false)); @@ -15242,7 +15262,7 @@ Interface_field_reference_expression::do_get_backend(Translate_context* context) Expression::make_nil(loc), loc); Bexpression* bnil_check = nil_check->get_backend(context); - Expression* crash = Runtime::make_call(Runtime::PANIC_MEM, loc, 0); + Expression* crash = Runtime::make_call(gogo, Runtime::PANIC_MEM, loc, 0); Bexpression* bcrash = crash->get_backend(context); Bfunction* bfn = context->function()->func_value()->get_decl(); @@ -16763,8 +16783,8 @@ Map_construction_expression::do_get_backend(Translate_context* context) Expression::make_struct_field_offset(this->element_type_, valfield); Expression* map_ctor = - Runtime::make_call(Runtime::CONSTRUCT_MAP, loc, 5, descriptor, count, - entry_size, val_offset, ventries); + Runtime::make_call(context->gogo(), Runtime::CONSTRUCT_MAP, loc, 5, + descriptor, count, entry_size, val_offset, ventries); return map_ctor->get_backend(context); } @@ -17841,13 +17861,16 @@ Type_guard_expression::do_get_backend(Translate_context* context) { Expression* conversion; if (this->type_->interface_type() != NULL) - conversion = - Expression::convert_interface_to_interface(this->type_, this->expr_, - true, this->location()); + conversion = Expression::convert_interface_to_interface(context->gogo(), + this->type_, + this->expr_, + true, + this->location()); else - conversion = - Expression::convert_for_assignment(context->gogo(), this->type_, - this->expr_, this->location()); + conversion = Expression::convert_for_assignment(context->gogo(), + this->type_, + this->expr_, + this->location()); Gogo* gogo = context->gogo(); Btype* bt = this->type_->get_backend(gogo); @@ -17947,7 +17970,7 @@ Heap_expression::do_get_backend(Translate_context* context) erhs = Expression::make_backend(btempref, etype, loc); erhs = Expression::unpack_direct_iface(erhs, loc); erhs = Expression::make_unsafe_cast(uintptr_type, erhs, loc); - call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, + call = Runtime::make_call(gogo, Runtime::GCWRITEBARRIER, loc, 2, elhs, erhs); } else @@ -17956,7 +17979,7 @@ Heap_expression::do_get_backend(Translate_context* context) Bexpression* addr = gogo->backend()->address_expression(btempref, loc); erhs = Expression::make_backend(addr, etype_ptr, loc); - call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3, + call = Runtime::make_call(gogo, Runtime::TYPEDMEMMOVE, loc, 3, td, elhs, erhs); } Statement* cs = Statement::make_statement(call, false); @@ -18085,12 +18108,13 @@ Receive_expression::do_get_backend(Translate_context* context) return context->backend()->error_expression(); } + Gogo* gogo = context->gogo(); Expression* recv_ref = Expression::make_temporary_reference(this->temp_receiver_, loc); Expression* recv_addr = Expression::make_temporary_reference(this->temp_receiver_, loc); recv_addr = Expression::make_unary(OPERATOR_AND, recv_addr, loc); - Expression* recv = Runtime::make_call(Runtime::CHANRECV1, loc, 2, + Expression* recv = Runtime::make_call(gogo, Runtime::CHANRECV1, loc, 2, this->channel_, recv_addr); return Expression::make_compound(recv, recv_ref, loc)->get_backend(context); } diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 49140d100a4..3b8ae68f500 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -1090,7 +1090,7 @@ class Expression // interface type. If FOR_TYPE_GUARD is true this is for a type // assertion. static Expression* - convert_interface_to_interface(Type* lhs_type, + convert_interface_to_interface(Gogo*, Type* lhs_type, Expression* rhs, bool for_type_guard, Location); @@ -1125,9 +1125,9 @@ class Expression // Insert bounds checks for an index expression. static void - check_bounds(Expression* val, Operator, Expression* bound, Runtime::Function, + check_bounds(Gogo*, Expression* val, Operator, Expression* bound, Runtime::Function, Runtime::Function, Runtime::Function, - Statement_inserter*, Location); + Runtime::Function, Statement_inserter*, Location); // Return an expression for constructing a direct interface type from a // pointer. diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 499459b5366..3c021b985b9 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -898,7 +898,8 @@ Gogo::register_gc_vars(const std::vector& var_gc, Expression* root_addr = Expression::make_unary(OPERATOR_AND, root_list_ctor, builtin_loc); root_addr->unary_expression()->set_is_gc_root(); - Expression* register_roots = Runtime::make_call(Runtime::REGISTER_GC_ROOTS, + Expression* register_roots = Runtime::make_call(this, + Runtime::REGISTER_GC_ROOTS, builtin_loc, 1, root_addr); Translate_context context(this, NULL, NULL, NULL); @@ -1039,7 +1040,7 @@ Gogo::register_type_descriptors(std::vector& init_stmts, Type* array_ptr_type = Type::make_pointer_type(list_array_type); Expression* expr = Expression::make_backend(bexpr, array_ptr_type, builtin_loc); - expr = Runtime::make_call(Runtime::REGISTER_TYPE_DESCRIPTORS, + expr = Runtime::make_call(this, Runtime::REGISTER_TYPE_DESCRIPTORS, builtin_loc, 2, len_expr->copy(), expr); Bexpression* bcall = expr->get_backend(&context); init_stmts.push_back(this->backend()->expression_statement(init_bfn, @@ -4928,7 +4929,8 @@ Build_recover_thunks::can_recover_arg(Location location) } Expression* zexpr = Expression::make_integer_ul(0, NULL, location); - Expression* call = Runtime::make_call(Runtime::BUILTIN_RETURN_ADDRESS, + Expression* call = Runtime::make_call(this->gogo_, + Runtime::BUILTIN_RETURN_ADDRESS, location, 1, zexpr); call = Expression::make_unsafe_cast(uintptr_type, call, location); @@ -5078,7 +5080,7 @@ Expression* Gogo::allocate_memory(Type* type, Location location) { Expression* td = Expression::make_type_descriptor(type, location); - return Runtime::make_call(Runtime::NEW, location, 1, td); + return Runtime::make_call(this, Runtime::NEW, location, 1, td); } // Traversal class used to check for return statements. @@ -6778,7 +6780,7 @@ Function::build_defer_wrapper(Gogo* gogo, Named_object* named_function, // libgo/runtime/go-unwind.c. std::vector stmts; - Expression* call = Runtime::make_call(Runtime::CHECKDEFER, end_loc, 1, + Expression* call = Runtime::make_call(gogo, Runtime::CHECKDEFER, end_loc, 1, this->defer_stack(end_loc)); Translate_context context(gogo, named_function, NULL, NULL); Bexpression* defer = call->get_backend(&context); @@ -6791,11 +6793,11 @@ Function::build_defer_wrapper(Gogo* gogo, Named_object* named_function, go_assert(*except == NULL); *except = gogo->backend()->statement_list(stmts); - call = Runtime::make_call(Runtime::CHECKDEFER, end_loc, 1, + call = Runtime::make_call(gogo, Runtime::CHECKDEFER, end_loc, 1, this->defer_stack(end_loc)); defer = call->get_backend(&context); - call = Runtime::make_call(Runtime::DEFERRETURN, end_loc, 1, + call = Runtime::make_call(gogo, Runtime::DEFERRETURN, end_loc, 1, this->defer_stack(end_loc)); Bexpression* undefer = call->get_backend(&context); Bstatement* function_defer = diff --git a/gcc/go/gofrontend/runtime.cc b/gcc/go/gofrontend/runtime.cc index e113a1adfc9..274aa4a7c1e 100644 --- a/gcc/go/gofrontend/runtime.cc +++ b/gcc/go/gofrontend/runtime.cc @@ -414,7 +414,7 @@ Runtime::runtime_declaration(Function code) // Make a call to a runtime function. Call_expression* -Runtime::make_call(Runtime::Function code, Location loc, +Runtime::make_call(Gogo*, Runtime::Function code, Location loc, int param_count, ...) { go_assert(code < Runtime::NUMBER_OF_FUNCTIONS); diff --git a/gcc/go/gofrontend/runtime.h b/gcc/go/gofrontend/runtime.h index e92510b33db..bea2dbe33a5 100644 --- a/gcc/go/gofrontend/runtime.h +++ b/gcc/go/gofrontend/runtime.h @@ -32,7 +32,7 @@ class Runtime // Make a call to a runtime function. static Call_expression* - make_call(Function, Location, int, ...); + make_call(Gogo*, Function, Location, int, ...); // Convert all the types used by runtime functions to the backend // representation. diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 91c7627a0e3..5d652a1119d 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -961,7 +961,7 @@ Assignment_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing, code = Runtime::MAPASSIGN; break; } - Expression* call = Runtime::make_call(code, loc, 3, + Expression* call = Runtime::make_call(gogo, code, loc, 3, a1, a2, a3); Type* ptrval_type = Type::make_pointer_type(mt->val_type()); call = Expression::make_cast(ptrval_type, call, loc); @@ -1597,10 +1597,11 @@ Tuple_map_assignment_statement::do_lower(Gogo* gogo, Named_object*, code = Runtime::MAPACCESS2; break; } - call = Runtime::make_call(code, loc, 3, a1, a2, a3); + call = Runtime::make_call(gogo, code, loc, 3, a1, a2, a3); } else - call = Runtime::make_call(Runtime::MAPACCESS2_FAT, loc, 4, a1, a2, a3, a4); + call = Runtime::make_call(gogo, Runtime::MAPACCESS2_FAT, loc, 4, + a1, a2, a3, a4); ref = Expression::make_temporary_reference(val_ptr_temp, loc); ref->set_is_lvalue(); Expression* res = Expression::make_call_result(call, 0); @@ -1701,7 +1702,7 @@ Tuple_receive_assignment_statement::do_traverse(Traverse* traverse) // Lower to a function call. Statement* -Tuple_receive_assignment_statement::do_lower(Gogo*, Named_object*, +Tuple_receive_assignment_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing, Statement_inserter*) { @@ -1744,7 +1745,7 @@ Tuple_receive_assignment_statement::do_lower(Gogo*, Named_object*, Temporary_reference_expression* ref = Expression::make_temporary_reference(val_temp, loc); Expression* p2 = Expression::make_unary(OPERATOR_AND, ref, loc); - Expression* call = Runtime::make_call(Runtime::CHANRECV2, + Expression* call = Runtime::make_call(gogo, Runtime::CHANRECV2, loc, 2, this->channel_, p2); ref = Expression::make_temporary_reference(closed_temp, loc); ref->set_is_lvalue(); @@ -1819,10 +1820,10 @@ class Tuple_type_guard_assignment_statement : public Statement private: Call_expression* - lower_to_type(Runtime::Function); + lower_to_type(Gogo*, Runtime::Function); void - lower_to_object_type(Block*, Runtime::Function); + lower_to_object_type(Gogo*, Block*, Runtime::Function); // The variable which recieves the converted value. Expression* val_; @@ -1849,7 +1850,7 @@ Tuple_type_guard_assignment_statement::do_traverse(Traverse* traverse) // Lower to a function call. Statement* -Tuple_type_guard_assignment_statement::do_lower(Gogo*, Named_object*, +Tuple_type_guard_assignment_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing, Statement_inserter*) { @@ -1876,22 +1877,25 @@ Tuple_type_guard_assignment_statement::do_lower(Gogo*, Named_object*, if (this->type_->interface_type() != NULL) { if (this->type_->interface_type()->is_empty()) - call = Runtime::make_call((expr_is_empty + call = Runtime::make_call(gogo, + (expr_is_empty ? Runtime::IFACEE2E2 : Runtime::IFACEI2E2), loc, 1, this->expr_); else - call = this->lower_to_type(expr_is_empty - ? Runtime::IFACEE2I2 - : Runtime::IFACEI2I2); + call = this->lower_to_type(gogo, + (expr_is_empty + ? Runtime::IFACEE2I2 + : Runtime::IFACEI2I2)); } else if (this->type_->points_to() != NULL) - call = this->lower_to_type(expr_is_empty - ? Runtime::IFACEE2T2P - : Runtime::IFACEI2T2P); + call = this->lower_to_type(gogo, + (expr_is_empty + ? Runtime::IFACEE2T2P + : Runtime::IFACEI2T2P)); else { - this->lower_to_object_type(b, + this->lower_to_object_type(gogo, b, (expr_is_empty ? Runtime::IFACEE2T2 : Runtime::IFACEI2T2)); @@ -1918,10 +1922,11 @@ Tuple_type_guard_assignment_statement::do_lower(Gogo*, Named_object*, // Lower a conversion to a non-empty interface type or a pointer type. Call_expression* -Tuple_type_guard_assignment_statement::lower_to_type(Runtime::Function code) +Tuple_type_guard_assignment_statement::lower_to_type(Gogo* gogo, + Runtime::Function code) { Location loc = this->location(); - return Runtime::make_call(code, loc, 2, + return Runtime::make_call(gogo, code, loc, 2, Expression::make_type_descriptor(this->type_, loc), this->expr_); } @@ -1930,6 +1935,7 @@ Tuple_type_guard_assignment_statement::lower_to_type(Runtime::Function code) void Tuple_type_guard_assignment_statement::lower_to_object_type( + Gogo* gogo, Block* b, Runtime::Function code) { @@ -1955,7 +1961,8 @@ Tuple_type_guard_assignment_statement::lower_to_object_type( Expression* p1 = Expression::make_type_descriptor(this->type_, loc); Expression* ref = Expression::make_temporary_reference(val_temp, loc); Expression* p3 = Expression::make_unary(OPERATOR_AND, ref, loc); - Expression* call = Runtime::make_call(code, loc, 3, p1, this->expr_, p3); + Expression* call = Runtime::make_call(gogo, code, loc, 3, + p1, this->expr_, p3); Statement* s; if (ok_temp == NULL) s = Statement::make_statement(call, true); @@ -2565,7 +2572,7 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function, Expression* nil = Expression::make_nil(location); Expression* isnil = Expression::make_binary(OPERATOR_EQEQ, fn, nil, location); - Expression* crash = Runtime::make_call(Runtime::PANIC_GO_NIL, + Expression* crash = Runtime::make_call(gogo, Runtime::PANIC_GO_NIL, location, 0); crash = Expression::make_conditional(isnil, crash, Expression::make_nil(location), @@ -2749,7 +2756,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name, { retaddr_label = gogo->add_label_reference("retaddr", location, false); Expression* arg = Expression::make_label_addr(retaddr_label, location); - Expression* call = Runtime::make_call(Runtime::SETDEFERRETADDR, + Expression* call = Runtime::make_call(gogo, Runtime::SETDEFERRETADDR, location, 1, arg); // This is a hack to prevent the middle-end from deleting the @@ -2973,7 +2980,8 @@ Go_statement::do_get_backend(Translate_context* context) if (!this->get_fn_and_arg(&fn, &arg)) return context->backend()->error_statement(); - Expression* call = Runtime::make_call(Runtime::GO, this->location(), 2, + Gogo* gogo = context->gogo(); + Expression* call = Runtime::make_call(gogo, Runtime::GO, this->location(), 2, fn, arg); Bexpression* bcall = call->get_backend(context); Bfunction* bfunction = context->function()->func_value()->get_decl(); @@ -3009,6 +3017,7 @@ Defer_statement::do_get_backend(Translate_context* context) if (!this->get_fn_and_arg(&fn, &arg)) return context->backend()->error_statement(); + Gogo* gogo = context->gogo(); Location loc = this->location(); Expression* ds = context->function()->func_value()->defer_stack(loc); @@ -3022,11 +3031,11 @@ Defer_statement::do_get_backend(Translate_context* context) Expression* defer = Expression::make_allocation(defer_type, loc); defer->allocation_expression()->set_allocate_on_stack(); defer->allocation_expression()->set_no_zero(); - call = Runtime::make_call(Runtime::DEFERPROCSTACK, loc, 4, + call = Runtime::make_call(gogo, Runtime::DEFERPROCSTACK, loc, 4, defer, ds, fn, arg); } else - call = Runtime::make_call(Runtime::DEFERPROC, loc, 3, + call = Runtime::make_call(gogo, Runtime::DEFERPROC, loc, 3, ds, fn, arg); Bexpression* bcall = call->get_backend(context); Bfunction* bfunction = context->function()->func_value()->get_decl(); @@ -4632,12 +4641,12 @@ Type_case_clauses::Type_case_clause::lower(Gogo* gogo, Expression::make_type_descriptor(type, loc), loc); else - cond = Runtime::make_call(Runtime::EQTYPE, loc, 2, + cond = Runtime::make_call(gogo, Runtime::EQTYPE, loc, 2, Expression::make_type_descriptor(type, loc), ref); } else - cond = Runtime::make_call(Runtime::IFACET2IP, loc, 2, + cond = Runtime::make_call(gogo, Runtime::IFACET2IP, loc, 2, Expression::make_type_descriptor(type, loc), ref); @@ -5076,6 +5085,7 @@ Send_statement::do_add_conversions() Bstatement* Send_statement::do_get_backend(Translate_context* context) { + Gogo* gogo = context->gogo(); Location loc = this->location(); Channel_type* channel_type = this->channel_->type()->channel_type(); @@ -5147,7 +5157,7 @@ Send_statement::do_get_backend(Translate_context* context) btemp = temp->get_backend(context); } - Expression* call = Runtime::make_call(Runtime::CHANSEND, loc, 2, + Expression* call = Runtime::make_call(gogo, Runtime::CHANSEND, loc, 2, this->channel_, val); context->gogo()->lower_expression(context->function(), NULL, &call); @@ -5660,7 +5670,9 @@ Select_clauses::get_backend(Translate_context* context, if (count == 0) return context->backend()->expression_statement(bfunction, bindex); - Expression* crash = Runtime::make_call(Runtime::UNREACHABLE, location, 0); + Gogo* gogo = context->gogo(); + Expression* crash = Runtime::make_call(gogo, Runtime::UNREACHABLE, + location, 0); Bexpression* bcrash = crash->get_backend(context); clauses[count] = context->backend()->expression_statement(bfunction, bcrash); @@ -5726,7 +5738,7 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function, // Zero-case select. Just block the execution. if (ncases == 0) { - Expression* call = Runtime::make_call(Runtime::BLOCK, loc, 0); + Expression* call = Runtime::make_call(gogo, Runtime::BLOCK, loc, 0); Statement *s = Statement::make_statement(call, false); b->add_statement(s); this->is_lowered_ = true; @@ -5735,12 +5747,12 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function, // One-case select. It is mostly just to run the case. if (ncases == 1) - return this->lower_one_case(b); + return this->lower_one_case(gogo, b); // Two-case select with one default case. It is a non-blocking // send/receive. if (ncases == 2 && has_default) - return this->lower_two_case(b); + return this->lower_two_case(gogo, b); // We don't allocate an entry in scases for the default case. if (has_default) @@ -5803,7 +5815,7 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function, loc); Expression* block_expr = Expression::make_boolean(!has_default, loc); - Call_expression* call = Runtime::make_call(Runtime::SELECTGO, loc, 5, + Call_expression* call = Runtime::make_call(gogo, Runtime::SELECTGO, loc, 5, scases_ref, order_ref, send_count_expr, recv_count_expr, block_expr); @@ -5827,7 +5839,7 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function, // Lower a one-case select statement. Statement* -Select_statement::lower_one_case(Block* b) +Select_statement::lower_one_case(Gogo* gogo, Block* b) { Select_clauses::Select_clause& scase = this->clauses_->at(0); Location loc = this->location(); @@ -5843,7 +5855,7 @@ Select_statement::lower_one_case(Block* b) Expression* nil = Expression::make_nil(loc); Expression* cond = Expression::make_binary(OPERATOR_EQEQ, chanref, nil, loc); Block* bnil = new Block(b, loc); - Expression* call = Runtime::make_call(Runtime::BLOCK, loc, 0); + Expression* call = Runtime::make_call(gogo, Runtime::BLOCK, loc, 0); Statement* s = Statement::make_statement(call, false); bnil->add_statement(s); Statement* ifs = Statement::make_if_statement(cond, bnil, NULL, loc); @@ -5935,7 +5947,7 @@ Select_statement::lower_one_case(Block* b) // Lower a two-case select statement with one default case. Statement* -Select_statement::lower_two_case(Block* b) +Select_statement::lower_two_case(Gogo* gogo, Block* b) { Select_clauses::Select_clause& chancase = (this->clauses_->at(0).is_default() @@ -5968,7 +5980,8 @@ Select_statement::lower_two_case(Block* b) Expression* ref = Expression::make_temporary_reference(ts, loc); Expression* addr = Expression::make_unary(OPERATOR_AND, ref, loc); - cond = Runtime::make_call(Runtime::SELECTNBSEND, loc, 2, chanref, addr); + cond = Runtime::make_call(gogo, Runtime::SELECTNBSEND, loc, 2, + chanref, addr); bchan = chancase.statements(); } else @@ -5980,8 +5993,8 @@ Select_statement::lower_two_case(Block* b) Expression* addr = Expression::make_unary(OPERATOR_AND, ref, loc); // selected, ok = selectnbrecv(&lhs, chan) - Call_expression* call = Runtime::make_call(Runtime::SELECTNBRECV, loc, 2, - addr, chanref); + Call_expression* call = Runtime::make_call(gogo, Runtime::SELECTNBRECV, + loc, 2, addr, chanref); Temporary_statement* selected_temp = Statement::make_temporary(Type::make_boolean_type(), @@ -6389,7 +6402,8 @@ For_range_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing, // calls. if (range_type->map_type() != NULL) { - Statement* clear = this->lower_map_range_clear(range_type, + Statement* clear = this->lower_map_range_clear(gogo, + range_type, enclosing, orig_range_expr, range_object, @@ -6856,7 +6870,7 @@ For_range_statement::lower_range_string(Gogo* gogo, ref = this->make_range_ref(range_object, range_temp, loc); index_ref = Expression::make_temporary_reference(index_temp, loc); - call = Runtime::make_call(Runtime::DECODERUNE, loc, 2, ref, index_ref); + call = Runtime::make_call(gogo, Runtime::DECODERUNE, loc, 2, ref, index_ref); value_ref = Expression::make_temporary_reference(value_temp, loc); value_ref->set_is_lvalue(); @@ -6935,7 +6949,7 @@ For_range_statement::lower_range_map(Gogo* gogo, Expression* p2 = this->make_range_ref(range_object, range_temp, loc); Expression* ref = Expression::make_temporary_reference(hiter, loc); Expression* p3 = Expression::make_unary(OPERATOR_AND, ref, loc); - Expression* call = Runtime::make_call(Runtime::MAPITERINIT, loc, 3, + Expression* call = Runtime::make_call(gogo, Runtime::MAPITERINIT, loc, 3, p1, p2, p3); init->add_statement(Statement::make_statement(call, true)); @@ -6985,7 +6999,7 @@ For_range_statement::lower_range_map(Gogo* gogo, ref = Expression::make_temporary_reference(hiter, loc); p1 = Expression::make_unary(OPERATOR_AND, ref, loc); - call = Runtime::make_call(Runtime::MAPITERNEXT, loc, 1, p1); + call = Runtime::make_call(gogo, Runtime::MAPITERNEXT, loc, 1, p1); post->add_statement(Statement::make_statement(call, true)); *ppost = post; @@ -7069,7 +7083,8 @@ For_range_statement::lower_range_channel(Gogo*, // containing the call. Return NULL otherwise. Statement* -For_range_statement::lower_map_range_clear(Type* map_type, +For_range_statement::lower_map_range_clear(Gogo* gogo, + Type* map_type, Block* enclosing, Expression* orig_range_expr, Named_object* range_object, @@ -7109,7 +7124,7 @@ For_range_statement::lower_map_range_clear(Type* map_type, // Everything matches. Rewrite to mapclear(TYPE, MAP). Expression* e1 = Expression::make_type_descriptor(map_type, loc); Expression* e2 = this->make_range_ref(range_object, range_temp, loc); - call = Runtime::make_call(Runtime::MAPCLEAR, loc, 2, e1, e2); + call = Runtime::make_call(gogo, Runtime::MAPCLEAR, loc, 2, e1, e2); return Statement::make_statement(call, true); } @@ -7198,12 +7213,13 @@ For_range_statement::lower_array_range_clear(Gogo* gogo, Expression* sz_arg = Expression::make_temporary_reference(ts2, loc); Expression* call; if (elem_type->has_pointer()) - call = Runtime::make_call(Runtime::MEMCLRHASPTR, loc, 2, ptr_arg, sz_arg); + call = Runtime::make_call(gogo, Runtime::MEMCLRHASPTR, loc, 2, + ptr_arg, sz_arg); else { Type* int32_type = Type::lookup_integer_type("int32"); Expression* zero32 = Expression::make_integer_ul(0, int32_type, loc); - call = Runtime::make_call(Runtime::BUILTIN_MEMSET, loc, 3, ptr_arg, + call = Runtime::make_call(gogo, Runtime::BUILTIN_MEMSET, loc, 3, ptr_arg, zero32, sz_arg); } Statement* cs3 = Statement::make_statement(call, true); diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h index 5fac01b916e..9a920ba6970 100644 --- a/gcc/go/gofrontend/statements.h +++ b/gcc/go/gofrontend/statements.h @@ -1284,11 +1284,11 @@ class Select_statement : public Statement private: // Lower a one-case select statement. Statement* - lower_one_case(Block*); + lower_one_case(Gogo*, Block*); // Lower a two-case select statement with one defualt case. Statement* - lower_two_case(Block*); + lower_two_case(Gogo*, Block*); // The select clauses. Select_clauses* clauses_; @@ -1760,7 +1760,7 @@ class For_range_statement : public Statement Block**); Statement* - lower_map_range_clear(Type*, Block*, Expression*, Named_object*, + lower_map_range_clear(Gogo*, Type*, Block*, Expression*, Named_object*, Temporary_statement*, Location); Statement* diff --git a/gcc/go/gofrontend/wb.cc b/gcc/go/gofrontend/wb.cc index e039c668847..062101432b9 100644 --- a/gcc/go/gofrontend/wb.cc +++ b/gcc/go/gofrontend/wb.cc @@ -923,7 +923,8 @@ Gogo::assign_with_write_barrier(Function* function, Block* enclosing, { // These types are all represented by a single pointer. rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc); - call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs); + call = Runtime::make_call(this, Runtime::GCWRITEBARRIER, loc, 2, + lhs, rhs); } break; @@ -953,7 +954,8 @@ Gogo::assign_with_write_barrier(Function* function, Block* enclosing, assign = Statement::make_assignment(lhs, rhs, loc); lhs = Expression::make_unary(OPERATOR_AND, lhs, loc); rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc); - call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs); + call = Runtime::make_call(this, Runtime::GCWRITEBARRIER, loc, 2, + lhs, rhs); } break; @@ -990,7 +992,8 @@ Gogo::assign_with_write_barrier(Function* function, Block* enclosing, assign = Statement::make_assignment(lhs, rhs, loc); lhs = Expression::make_unary(OPERATOR_AND, lhs, loc); rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc); - call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs); + call = Runtime::make_call(this, Runtime::GCWRITEBARRIER, loc, 2, + lhs, rhs); } break; @@ -1033,7 +1036,8 @@ Gogo::assign_with_write_barrier(Function* function, Block* enclosing, assign = Statement::make_assignment(lhs, rhs, loc); lhs = Expression::make_unary(OPERATOR_AND, lhs, loc); rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc); - call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs); + call = Runtime::make_call(this, Runtime::GCWRITEBARRIER, loc, 2, + lhs, rhs); break; } // fallthrough @@ -1043,14 +1047,15 @@ Gogo::assign_with_write_barrier(Function* function, Block* enclosing, { rhs = Expression::unpack_direct_iface(rhs, loc); rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc); - call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs); + call = Runtime::make_call(this, Runtime::GCWRITEBARRIER, loc, 2, + lhs, rhs); } else { // TODO: split assignments for small struct/array? rhs = Expression::make_unary(OPERATOR_AND, rhs, loc); rhs->unary_expression()->set_does_not_escape(); - call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3, + call = Runtime::make_call(this, Runtime::TYPEDMEMMOVE, loc, 3, Expression::make_type_descriptor(type, loc), lhs, rhs); }