From: Ian Lance Taylor <iant@golang.org>
To: gofrontend-dev <gofrontend-dev@googlegroups.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Go patch committed: Move lowering pass after check types pass
Date: Mon, 18 Dec 2023 17:32:14 -0800 [thread overview]
Message-ID: <CAOyqgcUEoynrUfZpbd8RrSRi-x0pXVEiFZXiiHZHJGw+-xDnQg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1453 bytes --]
This Go frontend patch moves the lowering pass after the type
determination and the type checking passes. This lets us simplify
some of the code that determines the type of an expression, which
previously had to work correctly both before and after type
determination.
I'm doing this to help with future generic support. For example, with
generics, we can see code like
func ident[T any](v T) T { return v }
func F() int32 {
s := int32(1)
return ident(s)
}
Before this change, we would type check return statements in the
lowering pass (see Return_statement::do_lower). With a generic
example like the above, that means we have to determine the type of s,
and use that to infer the type arguments passed to ident, and use that
to determine the result type of ident. That is too much to do at
lowering time. Of course we can change the way that return statements
work, but similar issues arise with index expressions, the types of
closures for function literals, and probably other cases as well.
Rather than try to deal with all those cases, we move the lowering
pass after type checking. This requires a bunch of changes, notably
for determining constant types. We have to add type checking for
various constructs that formerly disappeared in the lowering pass. So
it's a lot of shuffling. Sorry for the size of the patch.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed
to mainline.
Ian
[-- Attachment #2: patch.txt.bz2 --]
[-- Type: application/x-bzip, Size: 46117 bytes --]
next reply other threads:[~2023-12-19 1:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 1:32 Ian Lance Taylor [this message]
2024-01-19 4:49 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOyqgcUEoynrUfZpbd8RrSRi-x0pXVEiFZXiiHZHJGw+-xDnQg@mail.gmail.com \
--to=iant@golang.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=gofrontend-dev@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).