Merge tag 'go1.12.1' into master

Test: prebuilts/build-tools/build-prebuilts.sh
Test: `m blueprint_tools` with the resulting toolchain
Change-Id: I45bab7df391b0b2d5336f7970ad88ea8e722f3d1
diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE
index d3c3a2d..9d5156b 100644
--- a/.github/ISSUE_TEMPLATE
+++ b/.github/ISSUE_TEMPLATE
@@ -1,24 +1,36 @@
-Please answer these questions before submitting your issue. Thanks!
-
+<!-- Please answer these questions before submitting your issue. Thanks! -->
 
 ### What version of Go are you using (`go version`)?
 
+<pre>
+$ go version
+
+</pre>
 
 ### Does this issue reproduce with the latest release?
 
 
+
 ### What operating system and processor architecture are you using (`go env`)?
 
+<details><summary><code>go env</code> Output</summary><br><pre>
+$ go env
+
+</pre></details>
 
 ### What did you do?
 
+<!--
 If possible, provide a recipe for reproducing the error.
 A complete runnable program is good.
 A link on play.golang.org is best.
+-->
+
 
 
 ### What did you expect to see?
 
 
+
 ### What did you see instead?
 
diff --git a/AUTHORS b/AUTHORS
index 8f0a20a..8b8105b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -418,7 +418,7 @@
 Elbert Fliek <efliek@gmail.com>
 Eldar Rakhimberdin <ibeono@gmail.com>
 Elena Grahovac <elena@grahovac.me>
-Elias Naur <elias.naur@gmail.com>
+Elias Naur <mail@eliasnaur.com> <elias.naur@gmail.com>
 Elliot Morrison-Reed <elliotmr@gmail.com>
 Emerson Lin <linyintor@gmail.com>
 Emil Hessman <emil@hessman.se>
@@ -1304,6 +1304,7 @@
 Sylvain Zimmer <sylvain@sylvainzimmer.com>
 Syohei YOSHIDA <syohex@gmail.com>
 Szabolcs Nagy <nsz@port70.net>
+Taavi Kivisik <taavi.kivisik@gmail.com>
 Tad Fisher <tadfisher@gmail.com>
 Tad Glines <tad.glines@gmail.com>
 Taj Khattra <taj.khattra@gmail.com>
@@ -1404,6 +1405,7 @@
 Vladimir Nikishenko <vova616@gmail.com>
 Vladimir Stefanovic <vladimir.stefanovic@imgtec.com>
 Vladimir Varankin <nek.narqo@gmail.com>
+VMware, Inc.
 Volker Dobler <dr.volker.dobler@gmail.com>
 W. Trevor King <wking@tremily.us>
 Wade Simmons <wade@wades.im>
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 333dff7..b201301 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -25,6 +25,7 @@
 # Please keep the list sorted.
 
 Aamir Khan <syst3m.w0rm@gmail.com>
+Aaron Cannon <cannona@fireantproductions.com>
 Aaron France <aaron.l.france@gmail.com>
 Aaron Jacobs <jacobsa@google.com>
 Aaron Kemp <kemp.aaron@gmail.com>
@@ -32,6 +33,7 @@
 Aaron Torres <tcboox@gmail.com>
 Aaron Zinman <aaron@azinman.com>
 Aarti Parikh <aarti.parikh@gmail.com>
+Abdullah Al Maruf <mymail.maruf@gmail.com>
 Abe Haskins <abeisgreat@abeisgreat.com>
 Abhinav Gupta <abhinav.g90@gmail.com>
 Adam Azarchs <adam.azarchs@10xgenomics.com>
@@ -66,6 +68,7 @@
 Akhil Indurti <contact@akhilindurti.com>
 Akihiro Suda <suda.kyoto@gmail.com>
 Akshat Kumar <seed@mail.nanosouffle.net>
+Alan Braithwaite <alan@ipaddr.org>
 Alan Donovan <adonovan@google.com>
 Alan Shreve <alan@inconshreveable.com>
 Albert Nigmatzianov <albertnigma@gmail.com>
@@ -74,8 +77,10 @@
 Alberto Bertogli <albertito@blitiri.com.ar>
 Alberto Donizetti <alb.donizetti@gmail.com>
 Alberto García Hierro <alberto@garciahierro.com> <alberto.garcia.hierro@gmail.com>
+Aleksa Sarai <cyphar@cyphar.com>
 Aleksandar Dezelin <dezelin@gmail.com>
 Aleksandr Lukinykh <a.lukinykh@xsolla.com>
+Aleksandr Razumov <ar@cydev.ru>
 Alekseev Artem <a.artem060@gmail.com>
 Alessandro Arzilli <alessandro.arzilli@gmail.com>
 Alessandro Baffa <alessandro.baffa@gmail.com>
@@ -85,6 +90,7 @@
 Alex Browne <stephenalexbrowne@gmail.com>
 Alex Carol <alex.carol.c@gmail.com>
 Alex Jin <toalexjin@gmail.com>
+Alex Kohler <alexjohnkohler@gmail.com>
 Alex Myasoedov <msoedov@gmail.com>
 Alex Plugaru <alex@plugaru.org> <alexandru.plugaru@gmail.com>
 Alex Schroeder <alex@gnu.org>
@@ -106,15 +112,19 @@
 Alexander Reece <awreece@gmail.com>
 Alexander Surma <surma@surmair.de>
 Alexander Zhavnerchik <alex.vizor@gmail.com>
+Alexander Zillion <alex@alexzillion.com>
 Alexander Zolotov <goldifit@gmail.com>
 Alexandre Cesaro <alexandre.cesaro@gmail.com>
 Alexandre Fiori <fiorix@gmail.com>
+Alexandre Maari <draeron@gmail.com>
 Alexandre Normand <alexandre.normand@gmail.com>
 Alexandre Parentea <aubonbeurre@gmail.com>
 Alexandre Viau <alexandre@alexandreviau.net>
 Alexandru Moșoi <brtzsnr@gmail.com>
 Alexei Sholik <alcosholik@gmail.com>
+Alexey Alexandrov <aalexand@google.com>
 Alexey Borzenkov <snaury@gmail.com>
+Alexey Naidonov <alexey.naidyonov@gmail.com>
 Alexey Neganov <neganovalexey@gmail.com>
 Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
 Alexis Hildebrandt <surryhill@gmail.com>
@@ -133,14 +143,17 @@
 Anders Pearson <anders@columbia.edu>
 André Carvalho <asantostc@gmail.com>
 Andre Nathan <andrenth@gmail.com>
+Andrea Nodari <andrea.nodari91@gmail.com>
 Andrea Spadaccini <spadaccio@google.com>
 Andreas Auernhammer <aead@mail.de>
 Andreas Jellinghaus <andreas@ionisiert.de> <anj@google.com>
 Andreas Litt <andreas.litt@gmail.com>
+Andrei Gherzan <andrei@resin.io>
 Andrei Korzhevskii <a.korzhevskiy@gmail.com>
 Andrei Tudor Călin <mail@acln.ro>
 Andrei Vieru <euvieru@gmail.com>
 Andres Erbsen <andreser@google.com>
+Andres Lowrie <andres.lowrie@gmail.com>
 Andrew Austin <andrewaclt@gmail.com>
 Andrew Balholm <andybalholm@gmail.com>
 Andrew Benton <andrewmbenton@gmail.com>
@@ -155,9 +168,11 @@
 Andrew Lutomirski <andy@luto.us>
 Andrew Pilloud <andrewpilloud@igneoussystems.com>
 Andrew Pogrebnoy <absourd.noise@gmail.com>
+Andrew Poydence <apoydence@pivotal.io>
 Andrew Pritchard <awpritchard@gmail.com>
 Andrew Radev <andrey.radev@gmail.com>
 Andrew Skiba <skibaa@gmail.com>
+Andrew Stribblehill <ads@wompom.org>
 Andrew Szeto <andrew@jabagawee.com>
 Andrew Werner <andrew@upthere.com> <awerner32@gmail.com>
 Andrew Wilkins <axwalk@gmail.com>
@@ -174,21 +189,26 @@
 Andy Lindeman <andy@lindeman.io>
 Andy Maloney <asmaloney@gmail.com>
 Andy Walker <walkeraj@gmail.com>
+Andzej Maciusovic <andzej.maciusovic@gmail.com>
 Anfernee Yongkun Gui <anfernee.gui@gmail.com>
 Angelo Bulfone <mbulfone@gmail.com>
 Anh Hai Trinh <anh.hai.trinh@gmail.com>
 Anit Gandhi <anitgandhi@gmail.com>
+Ankit Goyal <ankit3goyal@gmail.com>
 Anmol Sethi <anmol@aubble.com>
 Anschel Schaffer-Cohen <anschelsc@gmail.com>
 Anthony Alves <cvballa3g0@gmail.com>
 Anthony Canino <anthony.canino1@gmail.com>
 Anthony Eufemio <anthony.eufemio@gmail.com>
+Anthony Fok <foka@debian.org>
 Anthony Martin <ality@pbrane.org>
 Anthony Sottile <asottile@umich.edu>
 Anthony Starks <ajstarks@gmail.com>
 Anthony Voutas <voutasaurus@gmail.com>
 Anthony Woods <awoods@raintank.io>
+Antoine GIRARD <sapk@sapk.fr>
 Antoine Martin <antoine97.martin@gmail.com>
+Anton Gyllenberg <anton@iki.fi>
 Antonin Amand <antonin.amand@gmail.com>
 Antonio Antelo <aantelov87@gmail.com>
 Antonio Bibiano <antbbn@gmail.com>
@@ -204,6 +224,7 @@
 Arne Hormann <arnehormann@gmail.com>
 Arnout Engelen <arnout@bzzt.net>
 Aron Nopanen <aron.nopanen@gmail.com>
+Arthur Fabre <arthur@arthurfabre.com>
 Arthur Khashaev <arthur@khashaev.ru>
 Artyom Pervukhin <artyom.pervukhin@gmail.com>
 Arvindh Rajesh Tamilmani <art@a-30.net>
@@ -217,6 +238,7 @@
 Aulus Egnatius Varialus <varialus@gmail.com>
 Aurélien Rainone <aurelien.rainone@gmail.com>
 Austin Clements <austin@google.com> <aclements@csail.mit.edu>
+Avi Flax <avi@timehop.com>
 awaw fumin <awawfumin@gmail.com>
 Awn Umar <awn@cryptolosophy.io>
 Axel Wagner <axel.wagner.hh@googlemail.com>
@@ -224,6 +246,7 @@
 Aymerick Jéhanne <aymerick@jehanne.org>
 Azat Kaumov <kaumov.a.r@gmail.com>
 Baiju Muthukadan <baiju.m.mail@gmail.com>
+Balaram Makam <bmakam.qdt@qualcommdatacenter.com>
 Balazs Lecz <leczb@google.com>
 Baokun Lee <nototon@gmail.com>
 Bartosz Grzybowski <melkorm@gmail.com>
@@ -233,6 +256,7 @@
 Ben Eitzen <eitzenb@golang.org>
 Ben Fried <ben.fried@gmail.com>
 Ben Haines <bhainesva@gmail.com>
+Ben Hoyt <benhoyt@gmail.com>
 Ben Laurie <ben@links.org> <benl@google.com>
 Ben Lubar <ben.lubar@gmail.com>
 Ben Lynn <benlynn@gmail.com>
@@ -263,6 +287,7 @@
 Blixt <me@blixt.nyc>
 Bob Briski <rbriski@gmail.com>
 Bob Potter <bobby.potter@gmail.com>
+Bobby DeSimone <bobbydesimone@gmail.com>
 Bobby Powers <bobbypowers@gmail.com>
 Boris Nagaev <nagaev@google.com>
 Borja Clemente <borja.clemente@gmail.com>
@@ -313,6 +338,7 @@
 Carlos Castillo <cookieo9@gmail.com>
 Carlos Cirello <uldericofilho@gmail.com>
 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
+Carlos Souza <carloshrsouza@gmail.com>
 Carolyn Van Slyck <me@carolynvanslyck.com>
 Cary Hull <chull@google.com>
 Case Nelson <case.nelson@gmail.com>
@@ -324,7 +350,9 @@
 Cezar Sá Espinola <cezarsa@gmail.com>
 Chad Rosier <mrosier.qdt@qualcommdatacenter.com>
 ChaiShushan <chaishushan@gmail.com>
+Channing Kimble-Brown <channing@golang.org>
 Charles Fenwick Elliott <Charles@FenwickElliott.io>
+Charles Kenney <charlesc.kenney@gmail.com>
 Charles L. Dorian <cldorian@gmail.com>
 Charles Lee <zombie.fml@gmail.com>
 Charles Weill <weill@google.com>
@@ -355,6 +383,7 @@
 Christian Couder <chriscool@tuxfamily.org>
 Christian Himpel <chressie@googlemail.com> <chressie@gmail.com>
 Christian Pellegrin <chri@evolware.org>
+Christian R. Petrin <christianpetrin@gmail.com>
 Christine Hansmann <chhansmann@gmail.com>
 Christoffer Buchholz <christoffer.buchholz@gmail.com>
 Christoph Blecker <admin@toph.ca>
@@ -371,12 +400,14 @@
 Christos Zoulas <christos@zoulas.com> <zoulasc@gmail.com>
 Christy Perez <christy@linux.vnet.ibm.com>
 CL Sung <clsung@gmail.com> <cl_sung@htc.com>
+Clément Chigot <clement.chigot@atos.net>
 Clement Skau <clementskau@gmail.com>
 Cody Oss <the.cody.oss@gmail.com>
 Colby Ranger <cranger@google.com>
 Colin Cross <ccross@android.com>
 Colin Edwards <colin@recursivepenguin.com>
 Colin Kennedy <moshen.colin@gmail.com>
+Colin Nelson <colnnelson@google.com>
 Colin Rice <clr@google.com>
 Conrad Irwin <conrad.irwin@gmail.com>
 Conrad Meyer <cemeyer@cs.washington.edu>
@@ -401,10 +432,13 @@
 Dan Callahan <dan.callahan@gmail.com>
 Dan Harrington <harringtond@google.com>
 Dan Jacques <dnj@google.com>
+Dan Johnson <computerdruid@google.com>
 Dan Peterson <dpiddy@gmail.com>
 Dan Pupius <dan@medium.com>
 Dan Sinclair <dan.sinclair@gmail.com>
+Daniël de Kok <me@danieldk.eu>
 Daniel Fleischman <danielfleischman@gmail.com>
+Daniel Ingram <ingramds@appstate.edu>
 Daniel Johansson <dajo2002@gmail.com>
 Daniel Kerwin <d.kerwin@gini.net>
 Daniel Krech <eikeon@eikeon.com>
@@ -421,6 +455,7 @@
 Daniela Petruzalek <daniela.petruzalek@gmail.com>
 Danny Rosseau <daniel.rosseau@gmail.com>
 Daria Kolistratova <daria.kolistratova@intel.com>
+Darien Raymond <admin@v2ray.com>
 Darren Elwood <darren@textnode.com>
 Darshan Parajuli <parajulidarshan@gmail.com>
 Datong Sun <dndx@idndx.com>
@@ -445,12 +480,15 @@
 David Forsythe <dforsythe@gmail.com>
 David G. Andersen <dave.andersen@gmail.com>
 David Glasser <glasser@meteor.com>
+David Heuschmann <heuschmann.d@gmail.com>
 David Howden <dhowden@gmail.com>
 David Hubbard <dsp@google.com>
 David Jakob Fritz <david.jakob.fritz@gmail.com>
+David Jones <dxjones@gmail.com>
 David Lazar <lazard@golang.org>
 David Leon Gil <coruus@gmail.com>
 David McLeish <davemc@google.com>
+David Ndungu <dnjuguna@gmail.com>
 David NewHamlet <david@newhamlet.com>
 David Presotto <presotto@gmail.com>
 David R. Jenni <david.r.jenni@gmail.com>
@@ -458,7 +496,9 @@
 David Stainton <dstainton415@gmail.com>
 David Symonds <dsymonds@golang.org>
 David Thomas <davidthomas426@gmail.com>
+David Timm <dtimm@pivotal.io>
 David Titarenco <david.titarenco@gmail.com>
+David Tolpin <david.tolpin@gmail.com>
 David Url <david@urld.io>
 David Volquartz Lebech <david@lebech.info>
 David Wimmer <davidlwimmer@gmail.com>
@@ -471,6 +511,7 @@
 Denis Nagorny <denis.nagorny@intel.com>
 Dennis Kuhnert <mail.kuhnert@gmail.com>
 Denys Honsiorovskyi <honsiorovskyi@gmail.com>
+Denys Smirnov <denis.smirnov.91@gmail.com>
 Derek Buitenhuis <derek.buitenhuis@gmail.com>
 Derek Che <drc@yahoo-inc.com>
 Derek McGowan <derek@mcgstyle.net>
@@ -485,9 +526,11 @@
 Dhruvdutt Jadhav <dhruvdutt.jadhav@gmail.com>
 Di Xiao <dixiao@google.com>
 Didier Spezia <didier.06@gmail.com>
+Diego Siqueira <diego9889@gmail.com>
 Dieter Plaetinck <dieter@raintank.io>
 Dimitri Sokolyuk <sokolyuk@gmail.com>
 Dimitri Tcaciuc <dtcaciuc@gmail.com>
+Dina Garmash <dgrmsh@gmail.com>
 Diogo Pinela <diogoid7400@gmail.com>
 Dirk Gadsden <dirk@esherido.com>
 Diwaker Gupta <diwakergupta@gmail.com>
@@ -499,16 +542,21 @@
 Dmitriy Vyukov <dvyukov@google.com>
 Dmitry Chestnykh <dchest@gmail.com>
 Dmitry Doroginin <doroginin@gmail.com>
+Dmitry Neverov <dmitry.neverov@gmail.com>
 Dmitry Savintsev <dsavints@gmail.com>
 Dmitry Yakunin <nonamezeil@gmail.com>
+Domen Ipavec <domen@ipavec.net>
 Dominic Green <dominicgreen1@gmail.com>
 Dominik Honnef <dominik.honnef@gmail.com>
 Dominik Vogt <vogt@linux.vnet.ibm.com>
+Don Byington <don@dbyington.com>
 Donald Huang <don.hcd@gmail.com>
 Dong-hee Na <donghee.na92@gmail.com>
 Donovan Hide <donovanhide@gmail.com>
 Doug Anderson <douga@google.com>
 Doug Fawley <dfawley@google.com>
+Douglas Danger Manley <doug.manley@gmail.com>
+Drew Flower <drewvanstone@gmail.com>
 Drew Hintz <adhintz@google.com>
 Duncan Holm <mail@frou.org>
 Dustin Carlino <dcarlino@google.com>
@@ -520,6 +568,7 @@
 Dylan Waits <dylan@waits.io>
 Edan Bedrik <3d4nb3@gmail.com>
 Eden Li <eden.li@gmail.com>
+Eduard Urbach <e.urbach@gmail.com>
 Eduardo Ramalho <eduardo.ramalho@gmail.com>
 Edward Muller <edwardam@interlix.com>
 Egon Elbre <egonelbre@gmail.com>
@@ -529,7 +578,7 @@
 Elbert Fliek <efliek@gmail.com>
 Eldar Rakhimberdin <ibeono@gmail.com>
 Elena Grahovac <elena@grahovac.me>
-Elias Naur <elias.naur@gmail.com>
+Elias Naur <mail@eliasnaur.com> <elias.naur@gmail.com>
 Elliot Morrison-Reed <elliotmr@gmail.com>
 Emerson Lin <linyintor@gmail.com>
 Emil Hessman <emil@hessman.se>
@@ -547,6 +596,7 @@
 Eric Lagergren <ericscottlagergren@gmail.com>
 Eric Milliken <emilliken@gmail.com>
 Eric Pauley <eric@pauley.me>
+Eric Ponce <tricokun@gmail.com>
 Eric Rescorla <ekr@rtfm.com>
 Eric Roshan-Eisner <eric.d.eisner@gmail.com>
 Eric Rykwalder <e.rykwalder@gmail.com>
@@ -555,6 +605,7 @@
 Erik St. Martin <alakriti@gmail.com>
 Erik Staab <estaab@google.com>
 Erik Westrup <erik.westrup@gmail.com>
+Erin Masatsugu <erin.masatsugu@gmail.com>
 Ernest Chiang <ernest_chiang@htc.com>
 Erwin Oegema <blablaechthema@hotmail.com>
 Esko Luontola <esko.luontola@gmail.com>
@@ -566,6 +617,7 @@
 Evan Brown <evanbrown@google.com>
 Evan Hicks <evan.hicks2@gmail.com>
 Evan Jones <ej@evanjones.ca>
+Evan Klitzke <evan@eklitzke.org>
 Evan Kroske <evankroske@google.com>
 Evan Martin <evan.martin@gmail.com>
 Evan Phoenix <evan@phx.io>
@@ -584,6 +636,7 @@
 Fatih Arslan <fatih@arslan.io>
 Fazal Majid <majid@apsalar.com>
 Fazlul Shahriar <fshahriar@gmail.com>
+Federico Bond <federicobond@gmail.com>
 Federico Simoncelli <fsimonce@redhat.com>
 Fedor Indutny <fedor@indutny.com>
 Felipe Oliveira <felipeweb.programador@gmail.com>
@@ -591,8 +644,10 @@
 Felix Kollmann <fk@konsorten.de>
 Filip Gruszczyński <gruszczy@gmail.com>
 Filip Haglund <drathier@users.noreply.github.com>
+Filip Stanis <fstanis@google.com>
 Filippo Valsorda <filippo@golang.org> <filippo@cloudflare.com> <hi@filippo.io>
 Firmansyah Adiputra <frm.adiputra@gmail.com>
+Florian Forster <octo@google.com>
 Florian Uekermann <florian@uekermann-online.de> <f1@uekermann-online.de>
 Florian Weimer <fw@deneb.enyo.de>
 Florin Patan <florinpatan@gmail.com>
@@ -610,9 +665,11 @@
 Fredrik Enestad <fredrik.enestad@soundtrackyourbrand.com>
 Fredrik Forsmo <fredrik.forsmo@gmail.com>
 Fredrik Wallgren <fredrik.wallgren@gmail.com>
+Frew Schmidt <github@frew.co>
 Frithjof Schulze <schulze@math.uni-hannover.de> <sfrithjof@gmail.com>
 Frits van Bommel <fvbommel@gmail.com>
 Fumitoshi Ukai <ukai@google.com>
+G. Hussain Chinoy <ghchinoy@gmail.com>
 Gaal Yahas <gaal@google.com>
 Gabríel Arthúr Pétursson <gabriel@system.is>
 Gabriel Aszalos <gabriel.aszalos@gmail.com>
@@ -627,6 +684,7 @@
 Gautham Thambidorai <gautham.dorai@gmail.com>
 Gauthier Jolly <gauthier.jolly@gmail.com>
 Geert-Johan Riemer <gjr19912@gmail.com>
+Genevieve Luyt <genevieve.luyt@gmail.com>
 Gengliang Wang <ltnwgl@gmail.com>
 Geoff Berry <gberry.qdt@qualcommdatacenter.com>
 Geoffroy Lorieux <lorieux.g@gmail.com>
@@ -634,24 +692,41 @@
 Georg Reinke <guelfey@gmail.com>
 George Gkirtsou <ggirtsou@gmail.com>
 George Shammas <george@shamm.as> <georgyo@gmail.com>
+Gerasimos (Makis) Maropoulos <kataras2006@hotmail.com>
 Gerasimos Dimitriadis <gedimitr@gmail.com>
+Gergely Brautigam <skarlso777@gmail.com>
 Getulio Sánchez <valentin2507@gmail.com>
+Gianguido Sora` <g.sora4@gmail.com>
 Gideon Jan-Wessel Redelinghuys <gjredelinghuys@gmail.com>
 Giles Lean <giles.lean@pobox.com>
 Giovanni Bajo <rasky@develer.com>
 GitHub User @ajnirp (1688456) <ajnirp@users.noreply.github.com>
+GitHub User @andrius4669 (4699695) <andrius4669@gmail.com>
 GitHub User @as (8127015) <as.utf8@gmail.com>
 GitHub User @bgadrian (830001) <aditza8@gmail.com>
 GitHub User @bontequero (2674999) <bontequero@gmail.com>
 GitHub User @cch123 (384546) <buaa.cch@gmail.com>
 GitHub User @chanxuehong (3416908) <chanxuehong@gmail.com>
+GitHub User @dupoxy (1143957) <dupoxy@users.noreply.github.com>
 GitHub User @erifan (31343225) <eric.fang@arm.com>
+GitHub User @esell (9735165) <eujon.sellers@gmail.com>
+GitHub User @itchyny (375258) <itchyny@hatena.ne.jp>
+GitHub User @kc1212 (1093806) <kc1212@users.noreply.github.com>
 GitHub User @Kropekk (13366453) <kamilkropiewnicki@gmail.com>
+GitHub User @LotusFenn (13775899) <fenn.lotus@gmail.com>
 GitHub User @madiganz (18340029) <zacharywmadigan@gmail.com>
+GitHub User @mkishere (224617) <224617+mkishere@users.noreply.github.com>
+GitHub User @OlgaVlPetrova (44112727) <OVPpetrova@gmail.com>
 GitHub User @pityonline (438222) <pityonline@gmail.com>
 GitHub User @pytimer (17105586) <lixin20101023@gmail.com>
+GitHub User @saitarunreddy (21041941) <saitarunreddypalla@gmail.com>
 GitHub User @shogo-ma (9860598) <Choroma194@gmail.com>
+GitHub User @tell-k (26263) <ffk2005@gmail.com>
+GitHub User @uhei (2116845) <uhei@users.noreply.github.com>
+GitHub User @uropek (39370426) <uropek@gmail.com>
 Giulio Iotti <dullgiulio@gmail.com>
+Giulio Micheloni <giulio.micheloni@gmail.com>
+Giuseppe Valente <gvalente@arista.com>
 Gleb Stepanov <glebstepanov1992@gmail.com>
 Glenn Brown <glennb@google.com>
 Glenn Lewis <gmlewis@google.com>
@@ -660,14 +735,17 @@
 Graham Miller <graham.miller@gmail.com>
 Grant Griffiths <ggp493@gmail.com>
 Greg Poirier <greg.istehbest@gmail.com>
+Greg Steuck <gnezdo+github@google.com>
 Greg Ward <greg@gerg.ca>
 Grégoire Delattre <gregoire.delattre@gmail.com>
 Gregory Man <man.gregory@gmail.com>
+Guilherme Caruso <gui.martinscaruso@gmail.com>
 Guilherme Garnier <guilherme.garnier@gmail.com>
 Guilherme Goncalves <guilhermeaugustosg@gmail.com>
 Guilherme Rezende <guilhermebr@gmail.com>
 Guillaume J. Charmes <guillaume@charmes.net>
 Guobiao Mei <meiguobiao@gmail.com>
+Guoliang Wang <iamwgliang@gmail.com>
 Gustav Paul <gustav.paul@gmail.com>
 Gustav Westling <gustav@westling.xyz>
 Gustavo Franco <gustavorfranco@gmail.com>
@@ -702,6 +780,7 @@
 Herbert Georg Fischer <herbert.fischer@gmail.com>
 Herbie Ong <herbie@google.com>
 Heschi Kreinick <heschi@google.com>
+Hidetatsu Yaginuma <ygnmhdtt@gmail.com>
 Hilko Bengen <bengen@hilluzination.de>
 Hiroaki Nakamura <hnakamur@gmail.com>
 Hironao OTSUBO <motemen@gmail.com>
@@ -715,11 +794,16 @@
 Hsin-Ho Yeh <yhh92u@gmail.com>
 Hu Keping <hukeping@huawei.com>
 Hugues Bruant <hugues.bruant@gmail.com>
+Huy Le <huy.dinh.le.89@gmail.com>
 Hyang-Ah Hana Kim <hakim@google.com> <hyangah@gmail.com>
 Ian Cottrell <iancottrell@google.com>
+Ian Davis <nospam@iandavis.com>
 Ian Gudger <ian@loosescre.ws>
+Ian Haken <ihaken@netflix.com>
 Ian Kent <iankent85@gmail.com>
 Ian Lance Taylor <iant@golang.org>
+Ian Leue <ian@appboy.com>
+Ian Zapolsky <ianzapolsky@gmail.com>
 Ibrahim AshShohail <ibra.sho@gmail.com>
 Icarus Sparry <golang@icarus.freeuk.com>
 Iccha Sethi <icchasethi@gmail.com>
@@ -727,6 +811,7 @@
 Igor Bernstein <igorbernstein@google.com>
 Igor Dolzhikov <bluesriverz@gmail.com>
 Igor Vashyst <ivashyst@gmail.com>
+Igor Zhilianin <igor.zhilianin@gmail.com>
 Ilya Tocar <ilya.tocar@intel.com>
 INADA Naoki <songofacandy@gmail.com>
 Inanc Gumus <m@inanc.io>
@@ -743,9 +828,12 @@
 Ivan Babrou <ivan@cloudflare.com>
 Ivan Bertona <ivan.bertona@gmail.com>
 Ivan Krasin <krasin@golang.org>
+Ivan Kutuzov <arbrix@gmail.com>
 Ivan Markin <sw@nogoegst.net>
 Ivan Moscoso <moscoso@gmail.com>
+Ivan Sharavuev <shpiwan@gmail.com>
 Ivan Ukhov <ivan.ukhov@gmail.com>
+Ivy Evans <ivy@ivyevans.net>
 Jaana Burcu Dogan <jbd@google.com> <jbd@golang.org> <burcujdogan@gmail.com>
 Jack Britton <jackxbritton@gmail.com>
 Jack Lindamood <jlindamo@justin.tv>
@@ -753,6 +841,7 @@
 Jacob H. Haven <jacob@cloudflare.com>
 Jacob Hoffman-Andrews <github@hoffman-andrews.com>
 Jae Kwon <jae@tendermint.com>
+Jake B <doogie1012@gmail.com>
 Jakob Borg <jakob@nym.se>
 Jakob Weisblat <jakobw@mit.edu>
 Jakub Čajka <jcajka@redhat.com>
@@ -762,6 +851,7 @@
 James Chacon <jchacon@google.com>
 James Clarke <jrtc27@jrtc27.com>
 James Cowgill <James.Cowgill@imgtec.com>
+James Craig Burley <james-github@burleyarch.com>
 James David Chalfant <james.chalfant@gmail.com>
 James Fysh <james.fysh@gmail.com>
 James Gray <james@james4k.com>
@@ -804,12 +894,15 @@
 Jason Chu <jasonchujc@gmail.com>
 Jason Del Ponte <delpontej@gmail.com>
 Jason Hall <jasonhall@google.com>
+Jason Keene <jasonkeene@gmail.com>
+Jason LeBrun <jblebrun@gmail.com>
 Jason Smale <jsmale@zendesk.com>
 Jason Travis <infomaniac7@gmail.com>
 Jason Wangsadinata <jwangsadinata@gmail.com>
 Javier Kohen <jkohen@google.com>
 Javier Segura <javism@gmail.com>
 Jay Conrod <jayconrod@google.com>
+Jay Taylor <outtatime@gmail.com>
 Jay Weisskopf <jay@jayschwa.net>
 Jean de Klerk <deklerk@google.com>
 Jean-André Santoni <jean.andre.santoni@gmail.com>
@@ -831,6 +924,8 @@
 Jelte Fennema <github-tech@jeltef.nl>
 Jens Frederich <jfrederich@gmail.com>
 Jeremiah Harmsen <jeremiah@google.com>
+Jeremy Banks <_@jeremy.ca>
+Jeremy Canady <jcanady@gmail.com>
 Jeremy Jackins <jeremyjackins@gmail.com>
 Jeremy Schlatter <jeremy.schlatter@gmail.com>
 Jeroen Bobbeldijk <jerbob92@gmail.com>
@@ -854,6 +949,7 @@
 Jirka Daněk <dnk@mail.muni.cz>
 Jiulong Wang <jiulongw@gmail.com>
 Joakim Sernbrant <serbaut@gmail.com>
+Joe Bowbeer <joe.bowbeer@gmail.com>
 Joe Cortopassi <joe@joecortopassi.com>
 Joe Farrell <joe2farrell@gmail.com>
 Joe Harrison <joehazzers@gmail.com>
@@ -877,6 +973,7 @@
 John DeNero <denero@google.com>
 John Dethridge <jcd@golang.org>
 John Gibb <johngibb@gmail.com>
+John Gilik <john@jgilik.com>
 John Graham-Cumming <jgc@jgc.org> <jgrahamc@gmail.com>
 John Howard Palevich <jack.palevich@gmail.com>
 John Jeffery <jjeffery@sp.com.au>
@@ -910,6 +1007,7 @@
 Joop Kiefte <ikojba@gmail.com> <joop@kiefte.net>
 Jordan Krage <jmank88@gmail.com>
 Jordan Lewis <jordanthelewis@gmail.com>
+Jordan Rhee <jordanrh@microsoft.com>
 Jos Visser <josv@google.com>
 Jose Luis Vázquez González <josvazg@gmail.com>
 Joseph Bonneau <jcb@google.com>
@@ -930,12 +1028,15 @@
 JP Sugarbroad <jpsugar@google.com>
 JT Olds <jtolds@xnet5.com>
 Juan Carlos <juanjcsr@gmail.com>
+Juan Pablo Civile <elementohb@gmail.com>
 Jude Pereira <judebpereira@gmail.com>
 Jukka-Pekka Kekkonen <karatepekka@gmail.com>
 Julia Hansbrough <flowerhack@google.com>
 Julian Kornberger <jk+github@digineo.de>
 Julian Pastarmov <pastarmovj@google.com>
 Julian Phillips <julian@quantumfyre.co.uk>
+Julie Qiu <julie@golang.org>
+Julien Kauffmann <julien.kauffmann@freelan.org>
 Julien Salleyron <julien.salleyron@gmail.com>
 Julien Schmidt <google@julienschmidt.com>
 Julio Montes <julio.montes@intel.com>
@@ -961,10 +1062,12 @@
 Karsten Köhler <karsten.koehler95@gmail.com>
 Kashav Madan <kshvmdn@gmail.com>
 Kate Manson <kate.manson@izettle.com>
+Katie Hockman <katie@golang.org>
 Kato Kazuyoshi <kato.kazuyoshi@gmail.com>
 Katrina Owen <katrina.owen@gmail.com>
 Kaviraj Kanagaraj <kavirajkanagaraj@gmail.com>
 Kay Zhu <kayzhu@google.com>
+Kazuhiro Sera <seratch@gmail.com>
 KB Sriram <kbsriram@google.com>
 Keegan Carruthers-Smith <keegan.csmith@gmail.com>
 Kei Son <hey.calmdown@gmail.com>
@@ -989,6 +1092,7 @@
 Kevin Malachowski <chowski@google.com>
 Kevin Ruffin <kruffin@gmail.com>
 Kevin Vu <kevin.m.vu@gmail.com>
+Kevin Zita <bleedgreenandgold@gmail.com>
 Kieran Colford <kieran@kcolford.com>
 Kim Shrier <kshrier@racktopsystems.com>
 Kim Yongbin <kybinz@gmail.com>
@@ -1000,6 +1104,7 @@
 Kodie Goodwin <kodiegoodwin@gmail.com>
 Koichi Shiraishi <zchee.io@gmail.com>
 Koki Ide <niconegoto@yahoo.co.jp>
+Komu Wairagu <komuw05@gmail.com>
 Konstantin <konstantin8105@gmail.com>
 Konstantin Shaposhnikov <k.shaposhnikov@gmail.com>
 Kris Kwiatkowski <kris@cloudflare.com>
@@ -1015,13 +1120,16 @@
 Kyle Lemons <kyle@kylelemons.net> <kevlar@google.com>
 Kyle Shannon <kyle@pobox.com>
 Kyle Spiers <eiais@google.com>
+Kyle Wood <kyle@kylewood.cc>
 Kyohei Kadota <lufia@lufia.org>
 Kyrylo Silin <silin@kyrylo.org>
 L Campbell <unpantsu@gmail.com>
 Lai Jiangshan <eag0628@gmail.com>
+Lajos Papp <lalyos@yahoo.com>
 Lakshay Garg <lakshay.garg.1996@gmail.com>
 Lann Martin <lannm@google.com>
 Lanre Adelowo <yo@lanre.wtf>
+Larry Clapp <larry@theclapp.org>
 Larry Hosken <lahosken@golang.org>
 Lars Jeppesen <jeppesen.lars@gmail.com>
 Lars Lehtonen <lars.lehtonen@gmail.com>
@@ -1066,9 +1174,11 @@
 Lyle Franklin <lylejfranklin@gmail.com>
 Lynn Boger <laboger@linux.vnet.ibm.com>
 Ma Peiqi <mapeiqi2017@gmail.com>
+Maarten Bezemer <maarten.bezemer@gmail.com>
 Maciej Dębski <maciejd@google.com>
 Magnus Hiie <magnus.hiie@gmail.com>
 Maicon Costa <maiconscosta@gmail.com>
+Mak Kolybabi <mak@kolybabi.com>
 Maksym Trykur <maksym.trykur@gmail.com>
 Mal Curtis <mal@mal.co.nz>
 Manfred Touron <m@42.am>
@@ -1086,6 +1196,7 @@
 Marcelo Cantos <marcelo.cantos@gmail.com>
 Marcelo E. Magallon <marcelo.magallon@gmail.com>
 Marco Hennings <marco.hennings@freiheit.com>
+Marcus Willock <crazcalm@gmail.com>
 Marga Manterola <marga@google.com>
 Marin Bašić <marin.basic02@gmail.com>
 Mario Arranz <marioarranzr@gmail.com>
@@ -1102,12 +1213,14 @@
 Mark Wolfe <mark@wolfe.id.au>
 Mark Zavislak <zavislak@google.com>
 Marko Juhani Silokunnas <marko.silokunnas@gmail.com>
+Marko Kevac <marko@kevac.org>
 Marko Mikulicic <mkm@google.com>
 Marko Mudrinic <mudrinic.mare@gmail.com>
 Marko Tiikkaja <marko@joh.to>
 Markus Duft <markus.duft@salomon.at>
 Markus Sonderegger <marraison@gmail.com>
 Markus Zimmermann <zimmski@gmail.com>
+Marten Seemann <martenseemann@gmail.com>
 Martin Bertschler <mbertschler@gmail.com>
 Martin Garton <garton@gmail.com>
 Martin Habbecke <marhab@google.com>
@@ -1122,6 +1235,7 @@
 Martin Olsson <martin@minimum.se>
 Martin Probst <martin@probst.io>
 Martin Sucha <anty.sk+git@gmail.com>
+Martin Tournoij <martin@arp242.net>
 Martins Sipenko <martins.sipenko@gmail.com>
 Martynas Budriūnas <mabu@google.com>
 Marvin Stenger <marvin.stenger94@gmail.com>
@@ -1165,31 +1279,37 @@
 Matthew Denton <mdenton@skyportsystems.com>
 Matthew Holt <Matthew.Holt+git@gmail.com>
 Matthew Horsnell <matthew.horsnell@gmail.com>
+Matthew Waters <mwwaters@gmail.com>
 Matthieu Hauglustaine <matt.hauglustaine@gmail.com>
 Matthieu Olivier <olivier.matthieu@gmail.com>
 Matthijs Kooijman <matthijs@stdin.nl>
 Max Riveiro <kavu13@gmail.com>
 Max Schmitt <max@schmitt.mx>
+Max Ushakov <ushmax@gmail.com>
 Maxim Khitrov <max@mxcrypt.com>
 Maxim Pimenov <mpimenov@google.com>
 Maxim Ushakov <ushakov@google.com>
 Maxime de Roucy <maxime.deroucy@gmail.com>
 Máximo Cuadros Ortiz <mcuadros@gmail.com>
 Maxwell Krohn <themax@gmail.com>
+Maya Rashish <maya@NetBSD.org>
 Mayank Kumar <krmayankk@gmail.com>
 Meir Fischer <meirfischer@gmail.com>
 Meng Zhuo <mengzhuo1203@gmail.com>
 Mhd Sulhan <m.shulhan@gmail.com>
 Micah Stetson <micah.stetson@gmail.com>
+Michael Anthony Knyszek <mknyszek@google.com>
 Michael Brandenburg <mbrandenburg@bolste.com>
 Michael Chaten <mchaten@gmail.com>
 Michael Darakananda <pongad@google.com>
 Michael Dorner <mail@michaeldorner.de>
 Michael Edwards <medwards@walledcity.ca>
 Michael Elkins <michael.elkins@gmail.com>
+Michael Ellis <micellis@justin.tv>
 Michael Fraenkel <michael.fraenkel@gmail.com>
 Michael Fromberger <michael.j.fromberger@gmail.com>
 Michael Gehring <mg@ebfe.org> <gnirheg.leahcim@gmail.com>
+Michael Henderson <mdhender@users.noreply.github.com>
 Michael Hendricks <michael@ndrix.org>
 Michael Hoisie <hoisie@gmail.com>
 Michael Hudson-Doyle <michael.hudson@linaro.org>
@@ -1214,18 +1334,21 @@
 Michael Steinert <mike.steinert@gmail.com>
 Michael T. Jones <mtj@google.com> <michael.jones@gmail.com>
 Michael Teichgräber <mteichgraeber@gmx.de> <mt4swm@googlemail.com>
+Michael Traver <mtraver@google.com>
 Michael Vetter <g.bluehut@gmail.com>
 Michal Bohuslávek <mbohuslavek@gmail.com>
 Michal Cierniak <cierniak@google.com>
 Michał Derkacz <ziutek@lnet.pl>
 Michal Franc <lam.michal.franc@gmail.com>
 Michal Pristas <michal.pristas@gmail.com>
+Michal Rostecki <mrostecki@suse.de>
 Michalis Kargakis <michaliskargakis@gmail.com>
 Michel Lespinasse <walken@google.com>
 Miek Gieben <miek@miek.nl> <remigius.gieben@gmail.com>
 Miguel Mendez <stxmendez@gmail.com>
 Miguel Molina <hi@mvader.me>
 Mihai Borobocea <MihaiBorobocea@gmail.com>
+Mihai Todor <todormihai@gmail.com>
 Mihail Minaev <minaev.mike@gmail.com>
 Mikael Tillenius <mikti42@gmail.com>
 Mike Andrews <mra@xoba.com>
@@ -1244,6 +1367,7 @@
 Miki Tebeka <miki.tebeka@gmail.com>
 Mikio Hara <mikioh.mikioh@gmail.com>
 Mikkel Krautz <mikkel@krautz.dk> <krautz@gmail.com>
+Mikołaj Baranowski <mikolajb@gmail.com>
 Milan Knezevic <milan.knezevic@mips.com>
 Milutin Jovanović <jovanovic.milutin@gmail.com>
 MinJae Kwon <mingrammer@gmail.com>
@@ -1286,6 +1410,7 @@
 Nic Day <nic.day@me.com>
 Nicholas Katsaros <nick@nickkatsaros.com>
 Nicholas Maniscalco <nicholas@maniscalco.com>
+Nicholas Ng <nickng@nickng.io>
 Nicholas Presta <nick@nickpresta.ca> <nick1presta@gmail.com>
 Nicholas Sullivan <nicholas.sullivan@gmail.com>
 Nicholas Waples <nwaples@gmail.com>
@@ -1326,12 +1451,15 @@
 Oleku Konko <oleku.konko@gmail.com>
 Oling Cat <olingcat@gmail.com>
 Oliver Hookins <ohookins@gmail.com>
+Oliver Stenbom <ostenbom@pivotal.io>
 Oliver Tonnhofer <olt@bogosoft.com>
 Olivier Antoine <olivier.antoine@gmail.com>
 Olivier Duperray <duperray.olivier@gmail.com>
 Olivier Poitrey <rs@dailymotion.com>
 Olivier Saingre <osaingre@gmail.com>
 Omar Jarjur <ojarjur@google.com>
+Oryan Moshe <iamoryanmoshe@gmail.com>
+Osamu TONOMORI <osamingo@gmail.com>
 Özgür Kesim <oec-go@kesim.org>
 Pablo Lalloni <plalloni@gmail.com>
 Pablo Rozas Larraondo <pablo.larraondo@anu.edu.au>
@@ -1341,6 +1469,7 @@
 Paolo Giarrusso <p.giarrusso@gmail.com>
 Paolo Martini <mrtnpaolo@gmail.com>
 Parker Moore <parkrmoore@gmail.com>
+Parminder Singh <parmsingh101@gmail.com>
 Pascal S. de Kloe <pascal@quies.net>
 Pat Moroney <pat@pat.email>
 Patrick Crosby <patrick@stathat.com>
@@ -1360,6 +1489,7 @@
 Paul Hankin <paulhankin@google.com>
 Paul Jolly <paul@myitcv.org.uk>
 Paul Lalonde <paul.a.lalonde@gmail.com>
+Paul M Furley <paul@paulfurley.com>
 Paul Marks <pmarks@google.com>
 Paul Meyer <paul.meyer@microsoft.com>
 Paul Nasrat <pnasrat@google.com>
@@ -1386,8 +1516,10 @@
 Peter Bourgon <peter@bourgon.org>
 Peter Collingbourne <pcc@google.com>
 Peter Conerly <pconerly@gmail.com>
+Peter Dotchev <dotchev@gmail.com>
 Peter Froehlich <peter.hans.froehlich@gmail.com>
 Peter Gonda <pgonda@google.com>
+Peter Hoyes <pahoyes@gmail.com>
 Peter Kleiweg <pkleiweg@xs4all.nl>
 Peter McKenzie <petermck@google.com>
 Peter Moody <pmoody@uber.com>
@@ -1421,11 +1553,13 @@
 Pieter Droogendijk <pieter@binky.org.uk>
 Pietro Gagliardi <pietro10@mac.com>
 Piyush Mishra <piyush@codeitout.com>
+Plekhanov Maxim <kishtatix@gmail.com>
 Pontus Leitzler <leitzler@gmail.com>
 Prasanna Swaminathan <prasanna@mediamath.com>
 Prashant Varanasi <prashant@prashantv.com>
 Pravendra Singh <hackpravj@gmail.com>
 Preetam Jinka <pj@preet.am>
+Qais Patankar <qaisjp@gmail.com>
 Qiuxuan Zhu <ilsh1022@gmail.com>
 Quan Tran <qeed.quan@gmail.com>
 Quan Yong Zhai <qyzhai@gmail.com>
@@ -1433,10 +1567,12 @@
 Quentin Renard <contact@asticode.com>
 Quentin Smith <quentin@golang.org>
 Quinn Slack <sqs@sourcegraph.com>
+Quinten Yearsley <qyearsley@chromium.org>
 Quoc-Viet Nguyen <afelion@gmail.com>
 Radek Sohlich <sohlich@gmail.com>
 Radu Berinde <radu@cockroachlabs.com>
 Rafal Jeczalik <rjeczalik@gmail.com>
+Raghavendra Nagaraj <jamdagni86@gmail.com>
 Rahul Chaudhry <rahulchaudhry@chromium.org>
 Raif S. Naffah <go@naffah-raif.name>
 Rajat Goel <rajat.goel2010@gmail.com>
@@ -1470,6 +1606,7 @@
 Rick Arnold <rickarnoldjr@gmail.com>
 Rick Hudson <rlh@golang.org>
 Rick Sayre <whorfin@gmail.com>
+Rijnard van Tonder <rvantonder@gmail.com>
 Riku Voipio <riku.voipio@linaro.org>
 Risto Jaakko Saarelma <rsaarelm@gmail.com>
 Rob Earhart <earhart@google.com>
@@ -1488,22 +1625,28 @@
 Robert Stepanek <robert.stepanek@gmail.com>
 Robert-André Mauchin <zebob.m@gmail.com>
 Roberto Clapis <robclap8@gmail.com>
+Roberto Selbach <roberto@selbach.ca>
 Robin Eklind <r.eklind.87@gmail.com>
 Rodolfo Carvalho <rhcarvalho@gmail.com>
+Rodolfo Rodriguez <rodolfobgibson@gmail.com>
 Rodrigo Moraes de Oliveira <rodrigo.moraes@gmail.com>
 Rodrigo Rafael Monti Kochenburger <divoxx@gmail.com>
 Roger Pau Monné <royger@gmail.com>
 Roger Peppe <rogpeppe@gmail.com>
+Roland Illig <roland.illig@gmx.de>
 Roland Shoemaker <rolandshoemaker@gmail.com>
 Roman Budnikov <romanyx90@yandex.ru>
+Roman Shchekin <mrqtros@gmail.com>
 Ron Hashimoto <mail@h2so5.net>
 Ron Minnich <rminnich@gmail.com>
 Ross Chater <rdchater@gmail.com>
 Ross Light <light@google.com> <rlight2@gmail.com>
+Ross Smith II <ross@smithii.com>
 Rowan Marshall <rowanajmarshall@gmail.com>
 Rowan Worth <sqweek@gmail.com>
 Rudi Kramer <rudi.kramer@gmail.com>
 Rui Ueyama <ruiu@google.com>
+Ruslan Nigmatullin <elessar@dropbox.com>
 Russ Cox <rsc@golang.org>
 Russell Haering <russellhaering@gmail.com>
 Ryan Bagwell <ryanbagwell@outlook.com>
@@ -1511,6 +1654,7 @@
 Ryan Boehning <ryan.boehning@apcera.com>
 Ryan Brown <ribrdb@google.com>
 Ryan Canty <jrcanty@gmail.com>
+Ryan Dahl <ry@tinyclouds.org>
 Ryan Hitchman <hitchmanr@gmail.com>
 Ryan Lower <rpjlower@gmail.com>
 Ryan Roden-Corrent <ryan@rcorre.net>
@@ -1534,9 +1678,11 @@
 Sameer Ajmani <sameer@golang.org> <ajmani@gmail.com>
 Sami Commerot <samic@google.com>
 Sami Pönkänen <sami.ponkanen@gmail.com>
+Samuel Kelemen <SCKelemen@users.noreply.github.com>
 Samuel Tan <samueltan@google.com>
 Samuele Pedroni <pedronis@lucediurna.net>
 Sanjay Menakuru <balasanjay@gmail.com>
+Santhosh Kumar Tekuri <santhosh.tekuri@gmail.com>
 Sarah Adams <shadams@google.com>
 Sascha Brawer <sascha@brawer.ch>
 Sasha Lionheart <lionhearts@google.com>
@@ -1550,13 +1696,17 @@
 Scott Schwartz <scotts@golang.org>
 Scott Van Woudenberg <scottvw@google.com>
 Sean Burford <sburford@google.com>
+Sean Chen <oohcode@gmail.com>
 Sean Chittenden <seanc@joyent.com>
 Sean Christopherson <sean.j.christopherson@intel.com>
 Sean Dolphin <Sean.Dolphin@kpcompass.com>
 Sean Harger <sharger@google.com>
 Sean Rees <sean@erifax.org>
+Sebastiaan van Stijn <github@gone.nl>
+Sebastian Schmidt <yath@google.com>
 Sebastien Binet <seb.binet@gmail.com>
 Sébastien Paolacci <sebastien.paolacci@gmail.com>
+Sebastien Williams-Wynn <sebastien@cytora.com>
 Seiji Takahashi <timaki.st@gmail.com>
 Sergei Skorobogatov <skorobo@rambler.ru>
 Sergey 'SnakE' Gromov <snake.scaly@gmail.com>
@@ -1568,6 +1718,7 @@
 Sergey Semin <gray12511@gmail.com>
 Sergio Luis O. B. Correia <sergio@correia.cc>
 Sergiusz Bazanski <bazanski@gmail.com>
+Serhii Aheienko <serhii.aheienko@gmail.com>
 Seth Hoenig <seth.a.hoenig@gmail.com>
 Seth Vargo <sethvargo@gmail.com>
 Shahar Kohanim <skohanim@gmail.com>
@@ -1581,9 +1732,11 @@
 Shenghou Ma <minux@golang.org> <minux.ma@gmail.com>
 Shengyu Zhang <shengyu.zhang@chaitin.com>
 Shi Han Ng <shihanng@gmail.com>
+Shijie Hao <haormj@gmail.com>
 Shinji Tanaka <shinji.tanaka@gmail.com>
 Shintaro Kaneko <kaneshin0120@gmail.com>
 Shivakumar GN <shivakumar.gn@gmail.com>
+Shivansh Rai <shivansh@freebsd.org>
 Shun Fan <sfan@google.com>
 Silvan Jegen <s.jegen@gmail.com>
 Simon Jefford <simon.jefford@gmail.com>
@@ -1603,6 +1756,7 @@
 Stanislav Afanasev <php.progger@gmail.com>
 Steeve Morin <steeve.morin@gmail.com>
 Stefan Nilsson <snilsson@nada.kth.se> <trolleriprofessorn@gmail.com>
+Stepan Shabalin <neverliberty@gmail.com>
 Stephan Renatus <srenatus@chef.io>
 Stéphane Travostino <stephane.travostino@gmail.com>
 Stephen Lewis <stephen@sock.org.uk>
@@ -1613,6 +1767,7 @@
 Stephen Weinberg <stephen@q5comm.com>
 Steve Francia <spf@golang.org>
 Steve Gilbert <stevegilbert23@gmail.com>
+Steve LoFurno <slofurno@gmail.com>
 Steve McCoy <mccoyst@gmail.com>
 Steve Newman <snewman@google.com>
 Steve Phillips <elimisteve@gmail.com>
@@ -1621,7 +1776,10 @@
 Steven Elliot Harris <seharris@gmail.com>
 Steven Erenst <stevenerenst@gmail.com>
 Steven Hartland <steven.hartland@multiplay.co.uk>
+Steven Littiebrant <imgroxx@gmail.com>
 Steven Wilkin <stevenwilkin@gmail.com>
+Stuart Jansen <sjansen@buscaluz.org>
+Sue Spence <virtuallysue@gmail.com>
 Sugu Sougoumarane <ssougou@gmail.com>
 Suharsh Sivakumar <suharshs@google.com>
 Sukrit Handa <sukrit.handa@utoronto.ca>
@@ -1634,8 +1792,11 @@
 Sylvain Zimmer <sylvain@sylvainzimmer.com>
 Syohei YOSHIDA <syohex@gmail.com>
 Szabolcs Nagy <nsz@port70.net>
+Taavi Kivisik <taavi.kivisik@gmail.com>
 Tad Fisher <tadfisher@gmail.com>
 Tad Glines <tad.glines@gmail.com>
+Tadas Valiukas <tadovas@gmail.com>
+Taesu Pyo <pyotaesu@gmail.com>
 Taj Khattra <taj.khattra@gmail.com>
 Takashi Matsuo <tmatsuo@google.com>
 Takayoshi Nishida <takayoshi.nishida@gmail.com>
@@ -1644,11 +1805,14 @@
 Takuya Ueda <uedatakuya@gmail.com>
 Tal Shprecher <tshprecher@gmail.com>
 Tamir Duberstein <tamird@gmail.com>
+Tao Shen <shentaoskyking@gmail.com>
 Tao Wang <twang2218@gmail.com>
 Tarmigan Casebolt <tarmigan@gmail.com>
 Taro Aoki <aizu.s1230022@gmail.com>
 Taru Karttunen <taruti@taruti.net>
 Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
+Tatsuya Kaneko <m.ddotx.f@gmail.com>
+Taufiq Rahman <taufiqrx8@gmail.com>
 Teague Cole <tnc1443@gmail.com>
 Ted Kornish <golang@tedkornish.com>
 Tejasvi Nareddy <tejunareddy@gmail.com>
@@ -1664,6 +1828,7 @@
 Thomas Bonfort <thomas.bonfort@gmail.com>
 Thomas Bouldin <inlined@google.com>
 Thomas Bruyelle <thomas.bruyelle@gmail.com>
+Thomas Bushnell, BSG <tbushnell@google.com>
 Thomas de Zeeuw <thomasdezeeuw@gmail.com>
 Thomas Desrosiers <thomasdesr@gmail.com>
 Thomas Habets <habets@google.com>
@@ -1682,6 +1847,7 @@
 Tim Hockin <thockin@google.com>
 Tim Swast <swast@google.com>
 Tim Wright <tenortim@gmail.com>
+Tim Xu <xiaoxubeii@gmail.com>
 Timo Savola <timo.savola@gmail.com>
 Timo Truyts <alkaloid.btx@gmail.com>
 Timothy Studd <tim@timstudd.com>
@@ -1705,6 +1871,7 @@
 Tommy Schaefer <tommy.schaefer@teecom.com>
 Tomoya Ishizaki <zaq1tomo@gmail.com>
 Tonis Tiigi <tonistiigi@gmail.com>
+Tony Reix <tony.reix@bull.net>
 Tony Walker <walkert.uk@gmail.com>
 Tor Andersson <tor.andersson@gmail.com>
 Tormod Erevik Lea <tormodlea@gmail.com>
@@ -1732,13 +1899,17 @@
 Ugorji Nwoke <ugorji@gmail.com>
 Ulf Holm Nielsen <doktor@dyregod.dk>
 Ulrich Kunitz <uli.kunitz@gmail.com>
+Umang Parmar <umangjparmar@gmail.com>
 Uriel Mangado <uriel@berlinblue.org>
+Urvil Patel <patelurvil38@gmail.com>
 Uttam C Pawar <uttam.c.pawar@intel.com>
 Vadim Grek <vadimprog@gmail.com>
 Vadim Vygonets <unixdj@gmail.com>
 Val Polouchkine <vpolouch@justin.tv>
 Vega Garcia Luis Alfonso <vegacom@gmail.com>
+Venil Noronha <veniln@vmware.com>
 Veselkov Konstantin <kostozyb@gmail.com>
+Viacheslav Poturaev <vearutop@gmail.com>
 Victor Chudnovsky <vchudnov@google.com>
 Victor Vrantchan <vrancean+github@gmail.com>
 Vignesh Ramachandra <vickyramachandra@gmail.com>
@@ -1749,8 +1920,10 @@
 Vinu Rajashekhar <vinutheraj@gmail.com>
 Vish Subramanian <vish@google.com>
 Vishvananda Ishaya <vishvananda@gmail.com>
+Visweswara R <r.visweswara@gmail.com>
 Vitor De Mario <vitordemario@gmail.com>
 Vlad Krasnov <vlad@cloudflare.com>
+Vladimir Kovpak <cn007b@gmail.com>
 Vladimir Kuzmin <vkuzmin@uber.com>
 Vladimir Mihailenco <vladimir.webdev@gmail.com>
 Vladimir Nikishenko <vova616@gmail.com>
@@ -1762,17 +1935,22 @@
 Wade Simmons <wade@wades.im>
 Walter Poupore <wpoupore@google.com>
 Wander Lairson Costa <wcosta@mozilla.com>
+Warren Fernandes <warren.f.fernandes@gmail.com>
 Wayne Ashley Berry <wayneashleyberry@gmail.com>
 Wedson Almeida Filho <wedsonaf@google.com>
+Weerasak Chongnguluam <singpor@gmail.com>
 Wèi Cōngruì <crvv.mail@gmail.com>
 Wei Fu <fhfuwei@163.com>
 Wei Guangjing <vcc.163@gmail.com>
 Wei Xiao <wei.xiao@arm.com>
 Weichao Tang <tevic.tt@gmail.com>
 Wembley G. Leach, Jr <wembley.gl@gmail.com>
+Wil Selwood <wselwood@gmail.com>
 Wilfried Teiken <wteiken@google.com>
+Will Beason <willbeason@gmail.com>
 Will Chan <willchan@google.com>
 Will Faught <will.faught@gmail.com>
+Will Morrow <wmorrow.qdt@qualcommdatacenter.com>
 Will Norris <willnorris@google.com>
 Will Storey <will@summercat.com>
 Willem van der Schyff <willemvds@gmail.com>
@@ -1805,6 +1983,7 @@
 Yesudeep Mangalapilly <yesudeep@google.com>
 Yissakhar Z. Beck <yissakhar.beck@gmail.com>
 Yo-An Lin <yoanlin93@gmail.com>
+Yohei Takeda <yo.tak0812@gmail.com>
 Yongjian Xu <i3dmaster@gmail.com>
 Yorman Arias <cixtords@gmail.com>
 Yoshiyuki Kanno <nekotaroh@gmail.com> <yoshiyuki.kanno@stoic.co.jp>
@@ -1813,6 +1992,7 @@
 Yu Heng Zhang <annita.zhang@cn.ibm.com>
 Yu Xuan Zhang <zyxsh@cn.ibm.com>
 Yuji Yaginuma <yuuji.yaginuma@gmail.com>
+Yuki OKUSHI <huyuumi.dev@gmail.com>
 Yuki Yugui Sonoda <yugui@google.com>
 Yukihiro Nishinaka <6elpinal@gmail.com>
 Yury Smolsky <yury@smolsky.by>
@@ -1823,12 +2003,14 @@
 Zac Bergquist <zbergquist99@gmail.com>
 Zach Bintliff <zbintliff@gmail.com>
 Zach Gershman <zachgersh@gmail.com>
+Zachary Amsden <zach@thundertoken.com>
 Zachary Gershman <zgershman@pivotal.io>
 Zak <zrjknill@gmail.com>
 Zakatell Kanda <hi@zkanda.io>
 Zellyn Hunter <zellyn@squareup.com> <zellyn@gmail.com>
 Zev Goldstein <zev.goldstein@gmail.com>
 Zheng Dayu <davidzheng23@gmail.com>
+Zheng Xu <zheng.xu@arm.com>
 Zhengyu He <hzy@google.com>
 Zhongpeng Lin <zplin@uber.com>
 Zhongtao Chen <chenzhongtao@126.com>
diff --git a/VERSION b/VERSION
index f3220fb..e7d096f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-go1.11
+go1.12.1
\ No newline at end of file
diff --git a/api/except.txt b/api/except.txt
index 46dbb45..637be18 100644
--- a/api/except.txt
+++ b/api/except.txt
@@ -3,8 +3,11 @@
 pkg math/big, type Word uintptr
 pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
 pkg os, const ModeType = 2399141888
+pkg os, const ModeType = 2399666176
 pkg os (linux-arm), const O_SYNC = 4096
 pkg os (linux-arm-cgo), const O_SYNC = 4096
+pkg os (linux-arm), const O_SYNC = 1052672
+pkg os (linux-arm-cgo), const O_SYNC = 1052672
 pkg syscall (darwin-386), const ImplementsGetwd = false
 pkg syscall (darwin-386), func Fchflags(string, int) error
 pkg syscall (darwin-386-cgo), const ImplementsGetwd = false
@@ -370,6 +373,7 @@
 pkg syscall (windows-386), type CertRevocationInfo struct, CrlInfo uintptr
 pkg syscall (windows-386), type CertRevocationInfo struct, OidSpecificInfo uintptr
 pkg syscall (windows-386), type CertSimpleChain struct, TrustListInfo uintptr
+pkg syscall (windows-386), type RawSockaddrAny struct, Pad [96]int8
 pkg syscall (windows-amd64), const TOKEN_ALL_ACCESS = 983295
 pkg syscall (windows-amd64), type AddrinfoW struct, Addr uintptr
 pkg syscall (windows-amd64), type CertChainPolicyPara struct, ExtraPolicyPara uintptr
@@ -378,3 +382,78 @@
 pkg syscall (windows-amd64), type CertRevocationInfo struct, CrlInfo uintptr
 pkg syscall (windows-amd64), type CertRevocationInfo struct, OidSpecificInfo uintptr
 pkg syscall (windows-amd64), type CertSimpleChain struct, TrustListInfo uintptr
+pkg syscall (windows-amd64), type RawSockaddrAny struct, Pad [96]int8
+pkg syscall (freebsd-386), func Mknod(string, uint32, int) error
+pkg syscall (freebsd-386), type Dirent struct, Fileno uint32
+pkg syscall (freebsd-386), type Dirent struct, Namlen uint8
+pkg syscall (freebsd-386), type Stat_t struct, Blksize uint32
+pkg syscall (freebsd-386), type Stat_t struct, Dev uint32
+pkg syscall (freebsd-386), type Stat_t struct, Gen uint32
+pkg syscall (freebsd-386), type Stat_t struct, Ino uint32
+pkg syscall (freebsd-386), type Stat_t struct, Lspare int32
+pkg syscall (freebsd-386), type Stat_t struct, Nlink uint16
+pkg syscall (freebsd-386), type Stat_t struct, Pad_cgo_0 [8]uint8
+pkg syscall (freebsd-386), type Stat_t struct, Rdev uint32
+pkg syscall (freebsd-386), type Statfs_t struct, Mntfromname [88]int8
+pkg syscall (freebsd-386), type Statfs_t struct, Mntonname [88]int8
+pkg syscall (freebsd-386-cgo), func Mknod(string, uint32, int) error
+pkg syscall (freebsd-386-cgo), type Dirent struct, Fileno uint32
+pkg syscall (freebsd-386-cgo), type Dirent struct, Namlen uint8
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Blksize uint32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Dev uint32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Gen uint32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Ino uint32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Lspare int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Nlink uint16
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Pad_cgo_0 [8]uint8
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Rdev uint32
+pkg syscall (freebsd-386-cgo), type Statfs_t struct, Mntfromname [88]int8
+pkg syscall (freebsd-386-cgo), type Statfs_t struct, Mntonname [88]int8
+pkg syscall (freebsd-amd64), func Mknod(string, uint32, int) error
+pkg syscall (freebsd-amd64), type Dirent struct, Fileno uint32
+pkg syscall (freebsd-amd64), type Dirent struct, Namlen uint8
+pkg syscall (freebsd-amd64), type Stat_t struct, Blksize uint32
+pkg syscall (freebsd-amd64), type Stat_t struct, Dev uint32
+pkg syscall (freebsd-amd64), type Stat_t struct, Gen uint32
+pkg syscall (freebsd-amd64), type Stat_t struct, Ino uint32
+pkg syscall (freebsd-amd64), type Stat_t struct, Lspare int32
+pkg syscall (freebsd-amd64), type Stat_t struct, Nlink uint16
+pkg syscall (freebsd-amd64), type Stat_t struct, Rdev uint32
+pkg syscall (freebsd-amd64), type Statfs_t struct, Mntfromname [88]int8
+pkg syscall (freebsd-amd64), type Statfs_t struct, Mntonname [88]int8
+pkg syscall (freebsd-amd64-cgo), func Mknod(string, uint32, int) error
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Fileno uint32
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Namlen uint8
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Blksize uint32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Dev uint32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Gen uint32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Ino uint32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Lspare int32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Nlink uint16
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Rdev uint32
+pkg syscall (freebsd-amd64-cgo), type Statfs_t struct, Mntfromname [88]int8
+pkg syscall (freebsd-amd64-cgo), type Statfs_t struct, Mntonname [88]int8
+pkg syscall (freebsd-arm), func Mknod(string, uint32, int) error
+pkg syscall (freebsd-arm), type Dirent struct, Fileno uint32
+pkg syscall (freebsd-arm), type Dirent struct, Namlen uint8
+pkg syscall (freebsd-arm), type Stat_t struct, Blksize uint32
+pkg syscall (freebsd-arm), type Stat_t struct, Dev uint32
+pkg syscall (freebsd-arm), type Stat_t struct, Gen uint32
+pkg syscall (freebsd-arm), type Stat_t struct, Ino uint32
+pkg syscall (freebsd-arm), type Stat_t struct, Lspare int32
+pkg syscall (freebsd-arm), type Stat_t struct, Nlink uint16
+pkg syscall (freebsd-arm), type Stat_t struct, Rdev uint32
+pkg syscall (freebsd-arm), type Statfs_t struct, Mntfromname [88]int8
+pkg syscall (freebsd-arm), type Statfs_t struct, Mntonname [88]int8
+pkg syscall (freebsd-arm-cgo), func Mknod(string, uint32, int) error
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Fileno uint32
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Namlen uint8
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Blksize uint32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Dev uint32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Gen uint32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Ino uint32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Lspare int32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Nlink uint16
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Rdev uint32
+pkg syscall (freebsd-arm-cgo), type Statfs_t struct, Mntfromname [88]int8
+pkg syscall (freebsd-arm-cgo), type Statfs_t struct, Mntonname [88]int8
diff --git a/api/go1.12.txt b/api/go1.12.txt
new file mode 100644
index 0000000..7d525cb
--- /dev/null
+++ b/api/go1.12.txt
@@ -0,0 +1,228 @@
+pkg bytes, func ReplaceAll([]uint8, []uint8, []uint8) []uint8
+pkg crypto/tls, const TLS_AES_128_GCM_SHA256 = 4865
+pkg crypto/tls, const TLS_AES_128_GCM_SHA256 uint16
+pkg crypto/tls, const TLS_AES_256_GCM_SHA384 = 4866
+pkg crypto/tls, const TLS_AES_256_GCM_SHA384 uint16
+pkg crypto/tls, const TLS_CHACHA20_POLY1305_SHA256 = 4867
+pkg crypto/tls, const TLS_CHACHA20_POLY1305_SHA256 uint16
+pkg crypto/tls, const VersionTLS13 = 772
+pkg crypto/tls, const VersionTLS13 ideal-int
+pkg crypto/tls, type RecordHeaderError struct, Conn net.Conn
+pkg debug/elf, const R_RISCV_32_PCREL = 57
+pkg debug/elf, const R_RISCV_32_PCREL R_RISCV
+pkg debug/pe, const IMAGE_FILE_MACHINE_ARMNT = 452
+pkg debug/pe, const IMAGE_FILE_MACHINE_ARMNT ideal-int
+pkg expvar, method (*Map) Delete(string)
+pkg go/doc, const PreserveAST = 4
+pkg go/doc, const PreserveAST Mode
+pkg go/importer, func ForCompiler(*token.FileSet, string, Lookup) types.Importer
+pkg go/token, method (*File) LineStart(int) Pos
+pkg io, type StringWriter interface { WriteString }
+pkg io, type StringWriter interface, WriteString(string) (int, error)
+pkg log, method (*Logger) Writer() io.Writer
+pkg math/bits, func Add(uint, uint, uint) (uint, uint)
+pkg math/bits, func Add32(uint32, uint32, uint32) (uint32, uint32)
+pkg math/bits, func Add64(uint64, uint64, uint64) (uint64, uint64)
+pkg math/bits, func Div(uint, uint, uint) (uint, uint)
+pkg math/bits, func Div32(uint32, uint32, uint32) (uint32, uint32)
+pkg math/bits, func Div64(uint64, uint64, uint64) (uint64, uint64)
+pkg math/bits, func Mul(uint, uint) (uint, uint)
+pkg math/bits, func Mul32(uint32, uint32) (uint32, uint32)
+pkg math/bits, func Mul64(uint64, uint64) (uint64, uint64)
+pkg math/bits, func Sub(uint, uint, uint) (uint, uint)
+pkg math/bits, func Sub32(uint32, uint32, uint32) (uint32, uint32)
+pkg math/bits, func Sub64(uint64, uint64, uint64) (uint64, uint64)
+pkg net/http, const StatusTooEarly = 425
+pkg net/http, const StatusTooEarly ideal-int
+pkg net/http, method (*Client) CloseIdleConnections()
+pkg os, const ModeType = 2401763328
+pkg os, func UserHomeDir() (string, error)
+pkg os, method (*File) SyscallConn() (syscall.RawConn, error)
+pkg os, method (*ProcessState) ExitCode() int
+pkg os/exec, method (ExitError) ExitCode() int
+pkg reflect, method (*MapIter) Key() Value
+pkg reflect, method (*MapIter) Next() bool
+pkg reflect, method (*MapIter) Value() Value
+pkg reflect, method (Value) MapRange() *MapIter
+pkg reflect, type MapIter struct
+pkg runtime/debug, func ReadBuildInfo() (*BuildInfo, bool)
+pkg runtime/debug, type BuildInfo struct
+pkg runtime/debug, type BuildInfo struct, Deps []*Module
+pkg runtime/debug, type BuildInfo struct, Main Module
+pkg runtime/debug, type BuildInfo struct, Path string
+pkg runtime/debug, type Module struct
+pkg runtime/debug, type Module struct, Path string
+pkg runtime/debug, type Module struct, Replace *Module
+pkg runtime/debug, type Module struct, Sum string
+pkg runtime/debug, type Module struct, Version string
+pkg strings, func ReplaceAll(string, string, string) string
+pkg strings, method (*Builder) Cap() int
+pkg syscall (freebsd-386), const S_IRWXG = 56
+pkg syscall (freebsd-386), const S_IRWXG ideal-int
+pkg syscall (freebsd-386), const S_IRWXO = 7
+pkg syscall (freebsd-386), const S_IRWXO ideal-int
+pkg syscall (freebsd-386), func Fstatat(int, string, *Stat_t, int) error
+pkg syscall (freebsd-386), func Mknod(string, uint32, uint64) error
+pkg syscall (freebsd-386), type Dirent struct, Fileno uint64
+pkg syscall (freebsd-386), type Dirent struct, Namlen uint16
+pkg syscall (freebsd-386), type Dirent struct, Off int64
+pkg syscall (freebsd-386), type Dirent struct, Pad0 uint8
+pkg syscall (freebsd-386), type Dirent struct, Pad1 uint16
+pkg syscall (freebsd-386), type Stat_t struct, Atim_ext int32
+pkg syscall (freebsd-386), type Stat_t struct, Blksize int32
+pkg syscall (freebsd-386), type Stat_t struct, Btim_ext int32
+pkg syscall (freebsd-386), type Stat_t struct, Ctim_ext int32
+pkg syscall (freebsd-386), type Stat_t struct, Dev uint64
+pkg syscall (freebsd-386), type Stat_t struct, Gen uint64
+pkg syscall (freebsd-386), type Stat_t struct, Ino uint64
+pkg syscall (freebsd-386), type Stat_t struct, Mtim_ext int32
+pkg syscall (freebsd-386), type Stat_t struct, Nlink uint64
+pkg syscall (freebsd-386), type Stat_t struct, Padding0 int16
+pkg syscall (freebsd-386), type Stat_t struct, Padding1 int32
+pkg syscall (freebsd-386), type Stat_t struct, Rdev uint64
+pkg syscall (freebsd-386), type Stat_t struct, Spare [10]uint64
+pkg syscall (freebsd-386), type Statfs_t struct, Mntfromname [1024]int8
+pkg syscall (freebsd-386), type Statfs_t struct, Mntonname [1024]int8
+pkg syscall (freebsd-386-cgo), const S_IRWXG = 56
+pkg syscall (freebsd-386-cgo), const S_IRWXG ideal-int
+pkg syscall (freebsd-386-cgo), const S_IRWXO = 7
+pkg syscall (freebsd-386-cgo), const S_IRWXO ideal-int
+pkg syscall (freebsd-386-cgo), func Fstatat(int, string, *Stat_t, int) error
+pkg syscall (freebsd-386-cgo), func Mknod(string, uint32, uint64) error
+pkg syscall (freebsd-386-cgo), type Dirent struct, Fileno uint64
+pkg syscall (freebsd-386-cgo), type Dirent struct, Namlen uint16
+pkg syscall (freebsd-386-cgo), type Dirent struct, Off int64
+pkg syscall (freebsd-386-cgo), type Dirent struct, Pad0 uint8
+pkg syscall (freebsd-386-cgo), type Dirent struct, Pad1 uint16
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Atim_ext int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Blksize int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Btim_ext int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Ctim_ext int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Dev uint64
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Gen uint64
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Ino uint64
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Mtim_ext int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Nlink uint64
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Padding0 int16
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Padding1 int32
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Rdev uint64
+pkg syscall (freebsd-386-cgo), type Stat_t struct, Spare [10]uint64
+pkg syscall (freebsd-386-cgo), type Statfs_t struct, Mntfromname [1024]int8
+pkg syscall (freebsd-386-cgo), type Statfs_t struct, Mntonname [1024]int8
+pkg syscall (freebsd-amd64), const S_IRWXG = 56
+pkg syscall (freebsd-amd64), const S_IRWXG ideal-int
+pkg syscall (freebsd-amd64), const S_IRWXO = 7
+pkg syscall (freebsd-amd64), const S_IRWXO ideal-int
+pkg syscall (freebsd-amd64), func Fstatat(int, string, *Stat_t, int) error
+pkg syscall (freebsd-amd64), func Mknod(string, uint32, uint64) error
+pkg syscall (freebsd-amd64), type Dirent struct, Fileno uint64
+pkg syscall (freebsd-amd64), type Dirent struct, Namlen uint16
+pkg syscall (freebsd-amd64), type Dirent struct, Off int64
+pkg syscall (freebsd-amd64), type Dirent struct, Pad0 uint8
+pkg syscall (freebsd-amd64), type Dirent struct, Pad1 uint16
+pkg syscall (freebsd-amd64), type Stat_t struct, Blksize int32
+pkg syscall (freebsd-amd64), type Stat_t struct, Dev uint64
+pkg syscall (freebsd-amd64), type Stat_t struct, Gen uint64
+pkg syscall (freebsd-amd64), type Stat_t struct, Ino uint64
+pkg syscall (freebsd-amd64), type Stat_t struct, Nlink uint64
+pkg syscall (freebsd-amd64), type Stat_t struct, Padding0 int16
+pkg syscall (freebsd-amd64), type Stat_t struct, Padding1 int32
+pkg syscall (freebsd-amd64), type Stat_t struct, Rdev uint64
+pkg syscall (freebsd-amd64), type Stat_t struct, Spare [10]uint64
+pkg syscall (freebsd-amd64), type Statfs_t struct, Mntfromname [1024]int8
+pkg syscall (freebsd-amd64), type Statfs_t struct, Mntonname [1024]int8
+pkg syscall (freebsd-amd64-cgo), const S_IRWXG = 56
+pkg syscall (freebsd-amd64-cgo), const S_IRWXG ideal-int
+pkg syscall (freebsd-amd64-cgo), const S_IRWXO = 7
+pkg syscall (freebsd-amd64-cgo), const S_IRWXO ideal-int
+pkg syscall (freebsd-amd64-cgo), func Fstatat(int, string, *Stat_t, int) error
+pkg syscall (freebsd-amd64-cgo), func Mknod(string, uint32, uint64) error
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Fileno uint64
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Namlen uint16
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Off int64
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Pad0 uint8
+pkg syscall (freebsd-amd64-cgo), type Dirent struct, Pad1 uint16
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Blksize int32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Dev uint64
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Gen uint64
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Ino uint64
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Nlink uint64
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Padding0 int16
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Padding1 int32
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Rdev uint64
+pkg syscall (freebsd-amd64-cgo), type Stat_t struct, Spare [10]uint64
+pkg syscall (freebsd-amd64-cgo), type Statfs_t struct, Mntfromname [1024]int8
+pkg syscall (freebsd-amd64-cgo), type Statfs_t struct, Mntonname [1024]int8
+pkg syscall (freebsd-arm), const S_IRWXG = 56
+pkg syscall (freebsd-arm), const S_IRWXG ideal-int
+pkg syscall (freebsd-arm), const S_IRWXO = 7
+pkg syscall (freebsd-arm), const S_IRWXO ideal-int
+pkg syscall (freebsd-arm), func Fstatat(int, string, *Stat_t, int) error
+pkg syscall (freebsd-arm), func Mknod(string, uint32, uint64) error
+pkg syscall (freebsd-arm), type Dirent struct, Fileno uint64
+pkg syscall (freebsd-arm), type Dirent struct, Namlen uint16
+pkg syscall (freebsd-arm), type Dirent struct, Off int64
+pkg syscall (freebsd-arm), type Dirent struct, Pad0 uint8
+pkg syscall (freebsd-arm), type Dirent struct, Pad1 uint16
+pkg syscall (freebsd-arm), type Stat_t struct, Blksize int32
+pkg syscall (freebsd-arm), type Stat_t struct, Dev uint64
+pkg syscall (freebsd-arm), type Stat_t struct, Gen uint64
+pkg syscall (freebsd-arm), type Stat_t struct, Ino uint64
+pkg syscall (freebsd-arm), type Stat_t struct, Nlink uint64
+pkg syscall (freebsd-arm), type Stat_t struct, Padding0 int16
+pkg syscall (freebsd-arm), type Stat_t struct, Padding1 int32
+pkg syscall (freebsd-arm), type Stat_t struct, Rdev uint64
+pkg syscall (freebsd-arm), type Stat_t struct, Spare [10]uint64
+pkg syscall (freebsd-arm), type Statfs_t struct, Mntfromname [1024]int8
+pkg syscall (freebsd-arm), type Statfs_t struct, Mntonname [1024]int8
+pkg syscall (freebsd-arm-cgo), const S_IRWXG = 56
+pkg syscall (freebsd-arm-cgo), const S_IRWXG ideal-int
+pkg syscall (freebsd-arm-cgo), const S_IRWXO = 7
+pkg syscall (freebsd-arm-cgo), const S_IRWXO ideal-int
+pkg syscall (freebsd-arm-cgo), func Fstatat(int, string, *Stat_t, int) error
+pkg syscall (freebsd-arm-cgo), func Mknod(string, uint32, uint64) error
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Fileno uint64
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Namlen uint16
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Off int64
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Pad0 uint8
+pkg syscall (freebsd-arm-cgo), type Dirent struct, Pad1 uint16
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Blksize int32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Dev uint64
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Gen uint64
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Ino uint64
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Nlink uint64
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Padding0 int16
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Padding1 int32
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Rdev uint64
+pkg syscall (freebsd-arm-cgo), type Stat_t struct, Spare [10]uint64
+pkg syscall (freebsd-arm-cgo), type Statfs_t struct, Mntfromname [1024]int8
+pkg syscall (freebsd-arm-cgo), type Statfs_t struct, Mntonname [1024]int8
+pkg syscall (openbsd-386), const S_IRWXG = 56
+pkg syscall (openbsd-386), const S_IRWXG ideal-int
+pkg syscall (openbsd-386), const S_IRWXO = 7
+pkg syscall (openbsd-386), const S_IRWXO ideal-int
+pkg syscall (openbsd-386-cgo), const S_IRWXG = 56
+pkg syscall (openbsd-386-cgo), const S_IRWXG ideal-int
+pkg syscall (openbsd-386-cgo), const S_IRWXO = 7
+pkg syscall (openbsd-386-cgo), const S_IRWXO ideal-int
+pkg syscall (openbsd-amd64), const S_IRWXG = 56
+pkg syscall (openbsd-amd64), const S_IRWXG ideal-int
+pkg syscall (openbsd-amd64), const S_IRWXO = 7
+pkg syscall (openbsd-amd64), const S_IRWXO ideal-int
+pkg syscall (openbsd-amd64-cgo), const S_IRWXG = 56
+pkg syscall (openbsd-amd64-cgo), const S_IRWXG ideal-int
+pkg syscall (openbsd-amd64-cgo), const S_IRWXO = 7
+pkg syscall (openbsd-amd64-cgo), const S_IRWXO ideal-int
+pkg syscall (windows-386), const UNIX_PATH_MAX = 108
+pkg syscall (windows-386), const UNIX_PATH_MAX ideal-int
+pkg syscall (windows-386), func Syscall18(uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) (uintptr, uintptr, Errno)
+pkg syscall (windows-386), type RawSockaddrAny struct, Pad [100]int8
+pkg syscall (windows-386), type RawSockaddrUnix struct, Family uint16
+pkg syscall (windows-386), type RawSockaddrUnix struct, Path [108]int8
+pkg syscall (windows-amd64), const UNIX_PATH_MAX = 108
+pkg syscall (windows-amd64), const UNIX_PATH_MAX ideal-int
+pkg syscall (windows-amd64), func Syscall18(uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) (uintptr, uintptr, Errno)
+pkg syscall (windows-amd64), type RawSockaddrAny struct, Pad [100]int8
+pkg syscall (windows-amd64), type RawSockaddrUnix struct, Family uint16
+pkg syscall (windows-amd64), type RawSockaddrUnix struct, Path [108]int8
+pkg syscall, type RawSockaddrUnix struct
diff --git a/doc/asm.html b/doc/asm.html
index f2f8fad..debb1e2 100644
--- a/doc/asm.html
+++ b/doc/asm.html
@@ -740,6 +740,7 @@
 
 <p>
 <code>R18</code> is the "platform register", reserved on the Apple platform.
+To prevent accidental misuse, the register is named <code>R18_PLATFORM</code>.
 <code>R27</code> and <code>R28</code> are reserved by the compiler and linker.
 <code>R29</code> is the frame pointer.
 <code>R30</code> is the link register.
diff --git a/doc/cmd.html b/doc/cmd.html
index c590f4d..e306847 100644
--- a/doc/cmd.html
+++ b/doc/cmd.html
@@ -18,10 +18,8 @@
 
 <p>
 The programs can also be run as stand-alone binaries, with unmodified arguments,
-using the go <code>tool</code> subcommand, such as <code>go tool vet</code>.
-This style of invocation allows, for instance, checking a single source file
-rather than an entire package: <code>go tool vet myprogram.go</code> as
-compared to <code>go vet mypackage</code>.
+using the go <code>tool</code> subcommand, such as <code>go tool cgo</code>.
+For most commands this is mainly useful for debugging.
 Some of the commands, such as <code>pprof</code>, are accessible only through
 the go <code>tool</code> subcommand.
 </p>
@@ -76,7 +74,7 @@
 </tr>
 
 <tr>
-<td><a href="/cmd/go/">fmt</a></td>
+<td><a href="/cmd/gofmt/">fmt</a></td>
 <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 <td>Fmt formats Go packages, it is also available as an independent <a href="/cmd/gofmt/">
 gofmt</a> command with more general options.</td>
diff --git a/doc/codewalk/codewalk.js b/doc/codewalk/codewalk.js
index abc5937..4f59a8f 100644
--- a/doc/codewalk/codewalk.js
+++ b/doc/codewalk/codewalk.js
@@ -276,7 +276,7 @@
   }
 
   // Force original file even if user hasn't changed comments since they may
-  // have nagivated away from it within the iframe without us knowing.
+  // have navigated away from it within the iframe without us knowing.
   this.navigateToCode(currentFile);
 };
 
diff --git a/doc/contrib.html b/doc/contrib.html
index df53d48..fc853a9 100644
--- a/doc/contrib.html
+++ b/doc/contrib.html
@@ -34,6 +34,8 @@
 <p>A <a href="/doc/devel/release.html">summary</a> of the changes between Go releases. Notes for the major releases:</p>
 
 <ul>
+	<li><a href="/doc/go1.12">Go 1.12</a> <small>(February 2019)</small></li>
+	<li><a href="/doc/go1.11">Go 1.11</a> <small>(August 2018)</small></li>
 	<li><a href="/doc/go1.10">Go 1.10</a> <small>(February 2018)</small></li>
 	<li><a href="/doc/go1.9">Go 1.9</a> <small>(August 2017)</small></li>
 	<li><a href="/doc/go1.8">Go 1.8</a> <small>(February 2017)</small></li>
@@ -59,6 +61,15 @@
 <h3 id="source"><a href="https://golang.org/change">Source Code</a></h3>
 <p>Check out the Go source code.</p>
 
+<h3 id="discuss"><a href="//groups.google.com/group/golang-nuts">Discussion Mailing List</a></h3>
+<p>
+A mailing list for general discussion of Go programming.
+</p>
+<p>
+Questions about using Go or announcements relevant to other Go users should be sent to
+<a href="//groups.google.com/group/golang-nuts">golang-nuts</a>.
+</p>
+
 <h3 id="golang-dev"><a href="https://groups.google.com/group/golang-dev">Developer</a> and
 <a href="https://groups.google.com/group/golang-codereviews">Code Review Mailing List</a></h3>
 <p>The <a href="https://groups.google.com/group/golang-dev">golang-dev</a>
@@ -66,9 +77,6 @@
 The <a href="https://groups.google.com/group/golang-codereviews">golang-codereviews</a>
 mailing list is for actual reviewing of the code changes (CLs).</p>
 
-<p>For general discussion of Go programming, see <a
-href="https://groups.google.com/group/golang-nuts">golang-nuts</a>.</p>
-
 <h3 id="golang-checkins"><a href="https://groups.google.com/group/golang-checkins">Checkins Mailing List</a></h3>
 <p>A mailing list that receives a message summarizing each checkin to the Go repository.</p>
 
@@ -116,7 +124,7 @@
 guidelines</a> for information on design, testing, and our code review process.
 </p>
 <p>
-Check <a href="//golang.org/issue">the tracker</a> for 
+Check <a href="//golang.org/issue">the tracker</a> for
 open issues that interest you. Those labeled
 <a href="https://github.com/golang/go/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22">help wanted</a>
 are particularly in need of outside help.
diff --git a/doc/contribute.html b/doc/contribute.html
index 5dc8a00..68b2387 100644
--- a/doc/contribute.html
+++ b/doc/contribute.html
@@ -393,8 +393,8 @@
 <p>
 It is not possible to fully sync Gerrit and GitHub, at least at the moment,
 so we recommend learning Gerrit.
-It's different but powerful and familiarity
-with help you understand the flow.
+It's different but powerful and familiarity with it will help you understand
+the flow.
 </p>
 
 <h3>Overview</h3>
@@ -405,7 +405,7 @@
 
 <ul>
 <li>
-<b>Step 1:</b> Clone the Go source code from go.googlesource.com
+<b>Step 1:</b> Clone the Go source code from <code>go.googlesource.com</code>
 and make sure it's stable by compiling and testing it once:
 <pre>
 $ git clone https://go.googlesource.com/go
@@ -469,12 +469,11 @@
 checked out from the correct repository.
 You can check out the Go source repo onto your local file system anywhere
 you want as long as it's outside your <code>GOPATH</code>.
-Either clone from
-<code>go.googlesource.com</code> or from GitHub:
+Clone from <code>go.googlesource.com</code> (not GitHub):
 </p>
 
 <pre>
-$ git clone https://github.com/golang/go   # or https://go.googlesource.com/go
+$ git clone https://go.googlesource.com/go
 $ cd go
 </pre>
 
@@ -697,7 +696,7 @@
 <p>
 Add any relevant information, such as benchmark data if the change
 affects performance.
-The <a href="https://godoc.org/golang.org/x/tools/cmd/benchcmp">benchcmp</a>
+The <a href="https://godoc.org/golang.org/x/perf/cmd/benchstat">benchstat</a>
 tool is conventionally used to format
 benchmark data for change descriptions.
 </p>
@@ -923,13 +922,13 @@
 </p>
 
 <pre>
-// Copyright 2018 The Go Authors. All rights reserved.
+// Copyright 2019 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 </pre>
 
 <p>
-(Use the current year if you're reading this in 2019 or beyond.)
+(Use the current year if you're reading this in 2020 or beyond.)
 Files in the repository are copyrighted the year they are added.
 Do not update the copyright year on files that you change.
 </p>
diff --git a/doc/debugging_with_gdb.html b/doc/debugging_with_gdb.html
index f3b4e37..3899ac9 100644
--- a/doc/debugging_with_gdb.html
+++ b/doc/debugging_with_gdb.html
@@ -179,7 +179,15 @@
 <code>"fmt.Print"</code> as an unstructured literal with a <code>"."</code>
 that needs to be quoted.  It objects even more strongly to method names of
 the form <code>pkg.(*MyType).Meth</code>.
-<li>All global variables are lumped into package <code>"main"</code>.</li>
+<li>As of Go 1.11, debug information is compressed by default.
+Older versions of gdb, such as the one available by default on MacOS,
+do not understand the compression.
+You can generate uncompressed debug information by using <code>go
+build -ldflags=-compressdwarf=false</code>.
+(For convenience you can put the <code>-ldflags</code> option in
+the <a href="/cmd/go/#hdr-Environment_variables"><code>GOFLAGS</code>
+environment variable</a> so that you don't have to specify it each time.)
+</li>
 </ol>
 
 <h2 id="Tutorial">Tutorial</h2>
@@ -248,7 +256,7 @@
 </pre>
 
 <p>
-List a specific part of the source parametrizing <code>"list"</code> with a
+List a specific part of the source parameterizing <code>"list"</code> with a
 function name (it must be qualified with its package name).
 </p>
 
diff --git a/doc/devel/release.html b/doc/devel/release.html
index e5d834e..7a036db 100644
--- a/doc/devel/release.html
+++ b/doc/devel/release.html
@@ -23,6 +23,79 @@
 (for example, Go 1.6.1, Go 1.6.2, and so on).
 </p>
 
+<h2 id="go1.12">go1.12 (released 2019/02/25)</h2>
+
+<p>
+Go 1.12 is a major release of Go.
+Read the <a href="/doc/go1.12">Go 1.12 Release Notes</a> for more information.
+</p>
+
+<p>
+go1.12.1 (released 2019/03/14) includes fixes to cgo, the compiler, the go
+command, and the <code>fmt</code>, <code>net/smtp</code>, <code>os</code>,
+<code>path/filepath</code>, <code>sync</code>, and <code>text/template</code>
+packages. See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.12.1">Go
+1.12.1 milestone</a> on our issue tracker for details.
+</p>
+
+<h2 id="go1.11">go1.11 (released 2018/08/24)</h2>
+
+<p>
+Go 1.11 is a major release of Go.
+Read the <a href="/doc/go1.11">Go 1.11 Release Notes</a> for more information.
+</p>
+
+<h3 id="go1.11.minor">Minor revisions</h3>
+
+<p>
+go1.11.1 (released 2018/10/01) includes fixes to the compiler, documentation, go
+command, runtime, and the <code>crypto/x509</code>, <code>encoding/json</code>,
+<code>go/types</code>, <code>net</code>, <code>net/http</code>, and
+<code>reflect</code> packages.
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.11.1">Go
+1.11.1 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.11.2 (released 2018/11/02) includes fixes to the compiler, linker,
+documentation, go command, and the <code>database/sql</code> and
+<code>go/types</code> packages.
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.11.2">Go
+1.11.2 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.11.3 (released 2018/12/12) includes three security fixes to "go get" and
+the <code>crypto/x509</code> package.
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.11.3">Go
+1.11.3 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.11.4 (released 2018/12/14) includes fixes to cgo, the compiler, linker,
+runtime, documentation, go command, and the <code>net/http</code> and
+<code>go/types</code> packages.
+It includes a fix to a bug introduced in Go 1.11.3 that broke <code>go</code>
+<code>get</code> for import path patterns containing "<code>...</code>".
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.11.4+label%3ACherryPickApproved">Go
+1.11.4 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.11.5 (released 2019/01/23) includes a security fix to the
+<code>crypto/elliptic</code> package.  See
+the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.11.5">Go
+1.11.5 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.11.6 (released 2019/03/14) includes fixes to cgo, the compiler, linker,
+runtime, go command, and the <code>crypto/x509</code>, <code>encoding/json</code>,
+<code>net</code>, and <code>net/url</code> packages. See the
+<a href="https://github.com/golang/go/issues?q=milestone%3AGo1.11.6">Go
+1.11.6 milestone</a> on our issue tracker for details.
+</p>
+
 <h2 id="go1.10">go1.10 (released 2018/02/16)</h2>
 
 <p>
@@ -65,6 +138,36 @@
 1.10.4 milestone</a> on our issue tracker for details.
 </p>
 
+<p>
+go1.10.5 (released 2018/11/02) includes fixes to the go command, linker, runtime
+and the <code>database/sql</code> package.
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.10.5">Go
+1.10.5 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.10.6 (released 2018/12/12) includes three security fixes to "go get" and
+the <code>crypto/x509</code> package.
+It contains the same fixes as Go 1.11.3 and was released at the same time.
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.10.6">Go
+1.10.6 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.10.7 (released 2018/12/14) includes a fix to a bug introduced in Go 1.10.6
+that broke <code>go</code> <code>get</code> for import path patterns containing
+"<code>...</code>".
+See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.10.7+label%3ACherryPickApproved">
+Go 1.10.7 milestone</a> on our issue tracker for details.
+</p>
+
+<p>
+go1.10.8 (released 2019/01/23) includes a security fix to the
+<code>crypto/elliptic</code> package.  See
+the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.10.8">Go
+1.10.8 milestone</a> on our issue tracker for details.
+</p>
+
 <h2 id="go1.9">go1.9 (released 2017/08/24)</h2>
 
 <p>
diff --git a/doc/diagnostics.html b/doc/diagnostics.html
index 0a78477..478611c 100644
--- a/doc/diagnostics.html
+++ b/doc/diagnostics.html
@@ -456,3 +456,15 @@
 and the length of the pause.</li>
 <li>GODEBUG=schedtrace=X prints scheduling events every X milliseconds.</li>
 </ul>
+
+<p>The GODEBUG environmental variable can be used to disable use of
+instruction set extensions in the standard library and runtime.</p>
+
+<ul>
+<li>GODEBUG=cpu.all=off disables the use of all optional
+instruction set extensions.</li>
+<li>GODEBUG=cpu.<em>extension</em>=off disables use of instructions from the
+specified instruction set extension.<br>
+<em>extension</em> is the lower case name for the instruction set extension
+such as <em>sse41</em> or <em>avx</em>.</li>
+</ul>
diff --git a/doc/docs.html b/doc/docs.html
index 955eb30..8f79d3a 100644
--- a/doc/docs.html
+++ b/doc/docs.html
@@ -50,10 +50,10 @@
 online</a> or{{end}} install it locally with:
 </p>
 <pre>
-$ go get golang.org/x/tour/gotour
+$ go get golang.org/x/tour
 </pre>
 <p>
-This will place the <code>gotour</code> binary in your workspace's <code>bin</code> directory.
+This will place the <code>tour</code> binary in your workspace's <code>bin</code> directory.
 </p>
 
 <h3 id="code"><a href="code.html">How to write Go code</a></h3>
diff --git a/doc/editors.html b/doc/editors.html
index 6f78786..4ff35a5 100644
--- a/doc/editors.html
+++ b/doc/editors.html
@@ -28,7 +28,7 @@
 </ul>
 
 <p>
-Note that these are only a few top solutions; a more comphensive
+Note that these are only a few top solutions; a more comprehensive
 community-maintained list of
 <a href="https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins">IDEs and text editor plugins</a>
 is available at the Wiki.
diff --git a/doc/effective_go.html b/doc/effective_go.html
index 89c1d08..3413186 100644
--- a/doc/effective_go.html
+++ b/doc/effective_go.html
@@ -246,14 +246,16 @@
 
 <p>
 If every doc comment begins with the name of the item it describes,
-the output of <code>godoc</code> can usefully be run through <code>grep</code>.
+you can use the <a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol">doc</a>
+subcommand of the <a href="/cmd/go/">go</a> tool
+and run the output through <code>grep</code>.
 Imagine you couldn't remember the name "Compile" but were looking for
 the parsing function for regular expressions, so you ran
 the command,
 </p>
 
 <pre>
-$ godoc regexp | grep -i parse
+$ go doc -all regexp | grep -i parse
 </pre>
 
 <p>
@@ -264,10 +266,10 @@
 </p>
 
 <pre>
-$ godoc regexp | grep parse
+$ go doc -all regexp | grep -i parse
     Compile parses a regular expression and returns, if successful, a Regexp
+    MustCompile is like Compile but panics if the expression cannot be parsed.
     parsed. It simplifies safe initialization of global variables holding
-    cannot be parsed. It simplifies safe initialization of global variables
 $
 </pre>
 
@@ -1402,11 +1404,11 @@
     var err error
     for i := 0; i &lt; 32; i++ {
         nbytes, e := f.Read(buf[i:i+1])  // Read one byte.
+        n += nbytes
         if nbytes == 0 || e != nil {
             err = e
             break
         }
-        n += nbytes
     }
 </pre>
 <p>
@@ -1708,7 +1710,7 @@
 &amp;{7 -2.35 abc   def}
 &amp;{a:7 b:-2.35 c:abc     def}
 &amp;main.T{a:7, b:-2.35, c:"abc\tdef"}
-map[string] int{"CST":-21600, "PST":-28800, "EST":-18000, "UTC":0, "MST":-25200}
+map[string]int{"CST":-21600, "PST":-28800, "EST":-18000, "UTC":0, "MST":-25200}
 </pre>
 <p>
 (Note the ampersands.)
@@ -1731,7 +1733,7 @@
 prints
 </p>
 <pre>
-map[string] int
+map[string]int
 </pre>
 <p>
 If you want to control the default format for a custom type, all that's required is to define
@@ -2104,12 +2106,14 @@
 
 <p>
 The <code>String</code> method of <code>Sequence</code> is recreating the
-work that <code>Sprint</code> already does for slices.  We can share the
-effort if we convert the <code>Sequence</code> to a plain
+work that <code>Sprint</code> already does for slices.
+(It also has complexity O(N²), which is poor.) We can share the
+effort (and also speed it up) if we convert the <code>Sequence</code> to a plain
 <code>[]int</code> before calling <code>Sprint</code>.
 </p>
 <pre>
 func (s Sequence) String() string {
+    s = s.Copy()
     sort.Sort(s)
     return fmt.Sprint([]int(s))
 }
@@ -2136,6 +2140,7 @@
 
 // Method for printing - sorts the elements before printing
 func (s Sequence) String() string {
+    s = s.Copy()
     sort.IntSlice(s).Sort()
     return fmt.Sprint([]int(s))
 }
@@ -2762,7 +2767,7 @@
 }
 </pre>
 <p>
-The <code>Job</code> type now has the <code>Log</code>, <code>Logf</code>
+The <code>Job</code> type now has the <code>Print</code>, <code>Printf</code>, <code>Println</code>
 and other
 methods of <code>*log.Logger</code>.  We could have given the <code>Logger</code>
 a field name, of course, but it's not necessary to do so.  And now, once
@@ -2770,7 +2775,7 @@
 log to the <code>Job</code>:
 </p>
 <pre>
-job.Log("starting now...")
+job.Println("starting now...")
 </pre>
 <p>
 The <code>Logger</code> is a regular field of the <code>Job</code> struct,
@@ -2797,8 +2802,8 @@
 which would be useful if we wanted to refine the methods of <code>Logger</code>.
 </p>
 <pre>
-func (job *Job) Logf(format string, args ...interface{}) {
-    job.Logger.Logf("%q: %s", job.Command, fmt.Sprintf(format, args...))
+func (job *Job) Printf(format string, args ...interface{}) {
+    job.Logger.Printf("%q: %s", job.Command, fmt.Sprintf(format, args...))
 }
 </pre>
 <p>
diff --git a/doc/go1.11.html b/doc/go1.11.html
index 469e111..1d85be9 100644
--- a/doc/go1.11.html
+++ b/doc/go1.11.html
@@ -348,6 +348,20 @@
 details. <!-- CL 126275, CL 127156, CL 122217, CL 122575, CL 123177 -->
 </p>
 
+<h3 id="go_command">Go command</h3>
+
+<p><!-- CL 126656 -->
+  The environment variable <code>GOFLAGS</code> may now be used
+  to set default flags for the <code>go</code> command.
+  This is useful in certain situations.
+  Linking can be noticeably slower on underpowered systems due to DWARF,
+  and users may want to set <code>-ldflags=-w</code> by default.
+  For modules, some users and CI systems will want vendoring always,
+  so they should set <code>-mod=vendor</code> by default.
+  For more information, see the <a href="/cmd/go/#hdr-Environment_variables"><code>go</code>
+  command documentation</a>.
+</p>
+
 <h3 id="godoc">Godoc</h3>
 
 <p>
@@ -386,6 +400,16 @@
   information.
 </p>
 
+<h3 id="run">Run</h3>
+
+<p>
+  <!-- CL 109341 -->
+  The <a href="/cmd/go/"><code>go</code>&nbsp;<code>run</code></a>
+  command now allows a single import path, a directory name or a
+  pattern matching a single package.
+  This allows <code>go</code>&nbsp;<code>run</code>&nbsp;<code>pkg</code> or <code>go</code>&nbsp;<code>run</code>&nbsp;<code>dir</code>, most importantly <code>go</code>&nbsp;<code>run</code>&nbsp;<code>.</code>
+</p>
+
 <h2 id="runtime">Runtime</h2>
 
 <p><!-- CL 85887 -->
@@ -396,7 +420,7 @@
 </p>
 
 <p><!-- CL 108679, CL 106156 -->
-  On macOS and iOS, the runtime now uses <code>libSystem.so</code> instead of
+  On macOS and iOS, the runtime now uses <code>libSystem.dylib</code> instead of
   calling the kernel directly. This should make Go binaries more
   compatible with future versions of macOS and iOS.
   The <a href="/pkg/syscall">syscall</a> package still makes direct
diff --git a/doc/go1.12.html b/doc/go1.12.html
new file mode 100644
index 0000000..2945eb1
--- /dev/null
+++ b/doc/go1.12.html
@@ -0,0 +1,945 @@
+<!--{
+        "Title": "Go 1.12 Release Notes",
+        "Path":  "/doc/go1.12",
+        "Template": true
+}-->
+
+<!--
+NOTE: In this document and others in this directory, the convention is to
+set fixed-width phrases with non-fixed-width spaces, as in
+<code>hello</code> <code>world</code>.
+Do not send CLs removing the interior tags from such phrases.
+-->
+
+<style>
+  ul li { margin: 0.5em 0; }
+</style>
+
+<h2 id="introduction">Introduction to Go 1.12</h2>
+
+<p>
+  The latest Go release, version 1.12, arrives six months after <a href="go1.11">Go 1.11</a>.
+  Most of its changes are in the implementation of the toolchain, runtime, and libraries.
+  As always, the release maintains the Go 1 <a href="/doc/go1compat">promise of compatibility</a>.
+  We expect almost all Go programs to continue to compile and run as before.
+</p>
+
+<h2 id="language">Changes to the language</h2>
+
+<p>
+  There are no changes to the language specification.
+</p>
+
+<h2 id="ports">Ports</h2>
+
+<p><!-- CL 138675 -->
+  The race detector is now supported on <code>linux/arm64</code>.
+</p>
+
+<p id="freebsd">
+  Go 1.12 is the last release that is supported on FreeBSD 10.x, which has
+  already reached end-of-life. Go 1.13 will require FreeBSD 11.2+ or FreeBSD
+  12.0+.
+  FreeBSD 12.0+ requires a kernel with the COMPAT_FREEBSD11 option set (this is the default).
+</p>
+
+<p><!-- CL 146898 -->
+  cgo is now supported on <code>linux/ppc64</code>.
+</p>
+
+<p id="hurd"><!-- CL 146023 -->
+  <code>hurd</code> is now a recognized value for <code>GOOS</code>, reserved
+  for the GNU/Hurd system for use with <code>gccgo</code>.
+</p>
+
+<h3 id="windows">Windows</h3>
+
+<p>
+  Go's new <code>windows/arm</code> port supports running Go on Windows 10
+  IoT Core on 32-bit ARM chips such as the Raspberry Pi 3.
+</p>
+
+<h3 id="aix">AIX</h3>
+
+<p>
+  Go now supports AIX 7.2 and later on POWER8 architectures (<code>aix/ppc64</code>). External linking, cgo, pprof and the race detector aren't yet supported.
+</p>
+
+<h3 id="darwin">Darwin</h3>
+
+<p>
+  Go 1.12 is the last release that will run on macOS 10.10 Yosemite.
+  Go 1.13 will require macOS 10.11 El Capitan or later.
+</p>
+
+<p><!-- CL 141639 -->
+  <code>libSystem</code> is now used when making syscalls on Darwin,
+  ensuring forward-compatibility with future versions of macOS and iOS.
+  <!-- CL 153338 -->
+  The switch to <code>libSystem</code> triggered additional App Store
+  checks for private API usage. Since it is considered private,
+  <code>syscall.Getdirentries</code> now always fails with
+  <code>ENOSYS</code> on iOS.
+</p>
+
+<h2 id="tools">Tools</h2>
+
+<h3 id="vet"><code>go tool vet</code> no longer supported</h3>
+
+<p>
+  The <code>go vet</code> command has been rewritten to serve as the
+  base for a range of different source code analysis tools. See
+  the <a href="https://godoc.org/golang.org/x/tools/go/analysis">golang.org/x/tools/go/analysis</a>
+  package for details. A side-effect is that <code>go tool vet</code>
+  is no longer supported. External tools that use <code>go tool
+  vet</code> must be changed to use <code>go
+  vet</code>. Using <code>go vet</code> instead of <code>go tool
+  vet</code> should work with all supported versions of Go.
+</p>
+
+<p>
+  As part of this change, the experimental <code>-shadow</code> option
+  is no longer available with <code>go vet</code>. Checking for
+  variable shadowing may now be done using
+<pre>
+go get -u golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
+go vet -vettool=$(which shadow)
+</pre>
+</p>
+
+<h3 id="tour">Tour</h3>
+
+<p> <!-- CL 152657 -->
+The Go tour is no longer included in the main binary distribution. To
+run the tour locally, instead of running <code>go</code> <code>tool</code> <code>tour</code>,
+manually install it:
+<pre>
+go get -u golang.org/x/tour
+tour
+</pre>
+</p>
+
+<h3 id="gocache">Build cache requirement</h3>
+
+<p>
+  The <a href="/cmd/go/#hdr-Build_and_test_caching">build cache</a> is now
+  required as a step toward eliminating
+  <code>$GOPATH/pkg</code>. Setting the environment variable
+  <code>GOCACHE=off</code> will cause <code>go</code> commands that write to the
+  cache to fail.
+</p>
+
+<h3 id="binary-only">Binary-only packages</h3>
+
+<p>
+  Go 1.12 is the last release that will support binary-only packages.
+</p>
+
+<h3 id="cgo">Cgo</h3>
+
+<p>
+	Go 1.12 will translate the C type <code>EGLDisplay</code> to the Go type <code>uintptr</code>.
+	This change is similar to how Go 1.10 and newer treats Darwin's CoreFoundation
+	and Java's JNI types. See the
+	<a href="/cmd/cgo/#hdr-Special_cases">cgo documentation</a>
+	for more information.
+</p>
+
+<p><!-- CL 152657 -->
+  Mangled C names are no longer accepted in packages that use Cgo. Use the Cgo
+  names instead. For example, use the documented cgo name <code>C.char</code>
+  rather than the mangled name <code>_Ctype_char</code> that cgo generates.
+</p>
+
+<h3 id="modules">Modules</h3>
+
+<p><!-- CL 148517 -->
+  When <code>GO111MODULE</code> is set to <code>on</code>, the <code>go</code>
+  command now supports module-aware operations outside of a module directory,
+  provided that those operations do not need to resolve import paths relative to
+  the current directory or explicitly edit the <code>go.mod</code> file.
+  Commands such as <code>go</code> <code>get</code>,
+  <code>go</code> <code>list</code>, and
+  <code>go</code> <code>mod</code> <code>download</code> behave as if in a
+  module with initially-empty requirements.
+  In this mode, <code>go</code> <code>env</code> <code>GOMOD</code> reports
+  the system's null device (<code>/dev/null</code> or <code>NUL</code>).
+</p>
+
+<p><!-- CL 146382 -->
+  <code>go</code> commands that download and extract modules are now safe to
+  invoke concurrently.
+  The module cache (<code>GOPATH/pkg/mod</code>) must reside in a filesystem that
+  supports file locking.
+</p>
+
+<p><!-- CL 147282, 147281 -->
+  The <code>go</code> directive in a <code>go.mod</code> file now indicates the
+  version of the language used by the files within that module.
+  It will be set to the current release
+  (<code>go</code> <code>1.12</code>) if no existing version is
+  present.
+  If the <code>go</code> directive for a module specifies a
+  version <em>newer</em> than the toolchain in use, the <code>go</code> command
+  will attempt to build the packages regardless, and will note the mismatch only if
+  that build fails.
+</p>
+
+<p><!-- CL 147282, 147281 -->
+  This changed use of the <code>go</code> directive means that if you
+  use Go 1.12 to build a module, thus recording <code>go 1.12</code>
+  in the <code>go.mod</code> file, you will get an error when
+  attempting to build the same module with Go 1.11 through Go 1.11.3.
+  Go 1.11.4 or later will work fine, as will releases older than Go 1.11.
+  If you must use Go 1.11 through 1.11.3, you can avoid the problem by
+  setting the language version to 1.11, using the Go 1.12 go tool,
+  via <code>go mod edit -go=1.11</code>.
+</p>
+
+<p><!-- CL 152739 -->
+  When an import cannot be resolved using the active modules,
+  the <code>go</code> command will now try to use the modules mentioned in the
+  main module's <code>replace</code> directives before consulting the module
+  cache and the usual network sources.
+  If a matching replacement is found but the <code>replace</code> directive does
+  not specify a version, the <code>go</code> command uses a pseudo-version
+  derived from the zero <code>time.Time</code> (such
+  as <code>v0.0.0-00010101000000-000000000000</code>).
+</p>
+
+<h3 id="compiler">Compiler toolchain</h3>
+
+<p><!-- CL 134155, 134156 -->
+  The compiler's live variable analysis has improved. This may mean that
+  finalizers will be executed sooner in this release than in previous
+  releases. If that is a problem, consider the appropriate addition of a
+  <a href="/pkg/runtime/#KeepAlive"><code>runtime.KeepAlive</code></a> call.
+</p>
+
+<p><!-- CL 147361 -->
+  More functions are now eligible for inlining by default, including
+  functions that do nothing but call another function.
+  This extra inlining makes it additionally important to use
+  <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
+  instead of iterating over the result of
+  <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a> directly.
+<pre>
+// Old code which no longer works correctly (it will miss inlined call frames).
+var pcs [10]uintptr
+n := runtime.Callers(1, pcs[:])
+for _, pc := range pcs[:n] {
+	f := runtime.FuncForPC(pc)
+	if f != nil {
+		fmt.Println(f.Name())
+	}
+}
+</pre>
+<pre>
+// New code which will work correctly.
+var pcs [10]uintptr
+n := runtime.Callers(1, pcs[:])
+frames := runtime.CallersFrames(pcs[:n])
+for {
+	frame, more := frames.Next()
+	fmt.Println(frame.Function)
+	if !more {
+		break
+	}
+}
+</pre>
+</p>
+
+<p><!-- CL 153477 -->
+  Wrappers generated by the compiler to implement method expressions
+  are no longer reported
+  by <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
+  and <a href="/pkg/runtime/#Stack"><code>runtime.Stack</code></a>. They
+  are also not printed in panic stack traces.
+
+  This change aligns the <code>gc</code> toolchain to match
+  the <code>gccgo</code> toolchain, which already elided such wrappers
+  from stack traces.
+
+  Clients of these APIs might need to adjust for the missing
+  frames. For code that must interoperate between 1.11 and 1.12
+  releases, you can replace the method expression <code>x.M</code>
+  with the function literal <code>func (...) { x.M(...) } </code>.
+</p>
+
+<p><!-- CL 144340 -->
+  The compiler now accepts a <code>-lang</code> flag to set the Go language
+  version to use. For example, <code>-lang=go1.8</code> causes the compiler to
+  emit an error if the program uses type aliases, which were added in Go 1.9.
+  Language changes made before Go 1.12 are not consistently enforced.
+</p>
+
+<p><!-- CL 147160 -->
+  The compiler toolchain now uses different conventions to call Go
+  functions and assembly functions. This should be invisible to users,
+  except for calls that simultaneously cross between Go and
+  assembly <em>and</em> cross a package boundary. If linking results
+  in an error like "relocation target not defined for ABIInternal (but
+  is defined for ABI0)", please refer to the
+  <a href="https://github.com/golang/proposal/blob/master/design/27539-internal-abi.md#compatibility">compatibility section</a>
+  of the ABI design document.
+</p>
+
+<p><!-- CL 145179 -->
+  There have been many improvements to the DWARF debug information
+  produced by the compiler, including improvements to argument
+  printing and variable location information.
+</p>
+
+<p><!-- CL 61511 -->
+  Go programs now also maintain stack frame pointers on <code>linux/arm64</code>
+  for the benefit of profiling tools like <code>perf</code>. The frame pointer
+  maintenance has a small run-time overhead that varies but averages around 3%.
+  To build a toolchain that does not use frame pointers, set
+  <code>GOEXPERIMENT=noframepointer</code> when running <code>make.bash</code>.
+</p>
+
+<p><!-- CL 142717 -->
+  The obsolete "safe" compiler mode (enabled by the <code>-u</code> gcflag) has been removed.
+</p>
+
+<h3 id="godoc"><code>godoc</code> and <code>go</code> <code>doc</code></h3>
+
+<p>
+  In Go 1.12, <code>godoc</code> no longer has a command-line interface and
+  is only a web server. Users should use <code>go</code> <code>doc</code>
+  for command-line help output instead. Go 1.12 is the last release that will
+  include the <code>godoc</code> webserver; in Go 1.13 it will be available
+  via <code>go</code> <code>get</code>.
+</p>
+
+<p><!-- CL 141977 -->
+  <code>go</code> <code>doc</code> now supports the <code>-all</code> flag,
+  which will cause it to print all exported APIs and their documentation,
+  as the <code>godoc</code> command line used to do.
+</p>
+
+<p><!-- CL 140959 -->
+  <code>go</code> <code>doc</code> also now includes the <code>-src</code> flag,
+  which will show the target's source code.
+</p>
+
+<h3 id="trace">Trace</h3>
+
+<p><!-- CL 60790 -->
+  The trace tool now supports plotting mutator utilization curves,
+  including cross-references to the execution trace. These are useful
+  for analyzing the impact of the garbage collector on application
+  latency and throughput.
+</p>
+
+<h3 id="assembler">Assembler</h3>
+
+<p><!-- CL 147218 -->
+  On <code>arm64</code>, the platform register was renamed from
+  <code>R18</code> to <code>R18_PLATFORM</code> to prevent accidental
+  use, as the OS could choose to reserve this register.
+</p>
+
+<h2 id="runtime">Runtime</h2>
+
+<p><!-- CL 138959 -->
+  Go 1.12 significantly improves the performance of sweeping when a
+  large fraction of the heap remains live. This reduces allocation
+  latency immediately following a garbage collection.
+</p>
+
+<p><!-- CL 139719 -->
+  The Go runtime now releases memory back to the operating system more
+  aggressively, particularly in response to large allocations that
+  can't reuse existing heap space.
+</p>
+
+<p><!-- CL 146342, CL 146340, CL 146345, CL 146339, CL 146343, CL 146337, CL 146341, CL 146338 -->
+  The Go runtime's timer and deadline code is faster and scales better
+  with higher numbers of CPUs. In particular, this improves the
+  performance of manipulating network connection deadlines.
+</p>
+
+<p><!-- CL 135395 -->
+  On Linux, the runtime now uses <code>MADV_FREE</code> to release unused
+  memory. This is more efficient but may result in higher reported
+  RSS. The kernel will reclaim the unused data when it is needed.
+  To revert to the Go 1.11 behavior (<code>MADV_DONTNEED</code>), set the
+  environment variable <code>GODEBUG=madvdontneed=1</code>.
+</p>
+
+<p><!-- CL 149578 -->
+  Adding cpu.<em>extension</em>=off to the
+  <a href="/doc/diagnostics.html#godebug">GODEBUG</a> environment
+  variable now disables the use of optional CPU instruction
+  set extensions in the standard library and runtime. This is not
+  yet supported on Windows.
+</p>
+
+<p><!-- CL 158337 -->
+  Go 1.12 improves the accuracy of memory profiles by fixing
+  overcounting of large heap allocations.
+</p>
+
+<p><!-- CL 159717 -->
+  Tracebacks, <code>runtime.Caller</code>,
+  and <code>runtime.Callers</code> no longer include
+  compiler-generated initialization functions.  Doing a traceback
+  during the initialization of a global variable will now show a
+  function named <code>PKG.init.ializers</code>.
+</p>
+
+<h2 id="library">Core library</h2>
+
+<h3 id="tls_1_3">TLS 1.3</h3>
+
+<p>
+  Go 1.12 adds opt-in support for TLS 1.3 in the <code>crypto/tls</code> package as
+  specified by <a href="https://www.rfc-editor.org/info/rfc8446">RFC 8446</a>. It can
+  be enabled by adding the value <code>tls13=1</code> to the <code>GODEBUG</code>
+  environment variable. It will be enabled by default in Go 1.13.
+</p>
+
+<p>
+  To negotiate TLS 1.3, make sure you do not set an explicit <code>MaxVersion</code> in
+  <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> and run your program with
+  the environment variable <code>GODEBUG=tls13=1</code> set.
+</p>
+
+<p>
+  All TLS 1.2 features except <code>TLSUnique</code> in
+  <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a>
+  and renegotiation are available in TLS 1.3 and provide equivalent or
+  better security and performance. Note that even though TLS 1.3 is backwards
+  compatible with previous versions, certain legacy systems might not work
+  correctly when attempting to negotiate it. RSA certificate keys too small
+  to be secure (including 512-bit keys) will not work with TLS 1.3.
+</p>
+
+<p>
+  TLS 1.3 cipher suites are not configurable. All supported cipher suites are
+  safe, and if <code>PreferServerCipherSuites</code> is set in
+  <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> the preference order
+  is based on the available hardware.
+</p>
+
+<p>
+  Early data (also called "0-RTT mode") is not currently supported as a
+  client or server. Additionally, a Go 1.12 server does not support skipping
+  unexpected early data if a client sends it. Since TLS 1.3 0-RTT mode
+  involves clients keeping state regarding which servers support 0-RTT,
+  a Go 1.12 server cannot be part of a load-balancing pool where some other
+  servers do support 0-RTT. If switching a domain from a server that supported
+  0-RTT to a Go 1.12 server, 0-RTT would have to be disabled for at least the
+  lifetime of the issued session tickets before the switch to ensure
+  uninterrupted operation.
+</p>
+
+<p>
+  In TLS 1.3 the client is the last one to speak in the handshake, so if it causes
+  an error to occur on the server, it will be returned on the client by the first
+  <a href="/pkg/crypto/tls/#Conn.Read"><code>Read</code></a>, not by
+  <a href="/pkg/crypto/tls/#Conn.Handshake"><code>Handshake</code></a>. For
+  example, that will be the case if the server rejects the client certificate.
+  Similarly, session tickets are now post-handshake messages, so are only
+  received by the client upon its first
+  <a href="/pkg/crypto/tls/#Conn.Read"><code>Read</code></a>.
+</p>
+
+<h3 id="minor_library_changes">Minor changes to the library</h3>
+
+<p>
+  As always, there are various minor changes and updates to the library,
+  made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
+  in mind.
+</p>
+
+<!-- TODO: CL 115677: https://golang.org/cl/115677: cmd/vet: check embedded field tags too -->
+
+<dl id="bufio"><dt><a href="/pkg/bufio/">bufio</a></dt>
+  <dd>
+    <p><!-- CL 149297 -->
+      <code>Reader</code>'s <a href="/pkg/bufio/#Reader.UnreadRune"><code>UnreadRune</code></a> and
+      <a href="/pkg/bufio/#Reader.UnreadByte"><code>UnreadByte</code></a> methods will now return an error
+      if they are called after <a href="/pkg/bufio/#Reader.Peek"><code>Peek</code></a>.
+    </p>
+
+</dl><!-- bufio -->
+
+<dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
+  <dd>
+    <p><!-- CL 137855 -->
+      The new function <a href="/pkg/bytes/#ReplaceAll"><code>ReplaceAll</code></a> returns a copy of
+      a byte slice with all non-overlapping instances of a value replaced by another.
+    </p>
+
+    <p><!-- CL 145098 -->
+      A pointer to a zero-value <a href="/pkg/bytes/#Reader"><code>Reader</code></a> is now
+      functionally equivalent to <a href="/pkg/bytes/#NewReader"><code>NewReader</code></a><code>(nil)</code>.
+      Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
+    </p>
+
+</dl><!-- bytes -->
+
+<dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
+  <dd>
+    <p><!-- CL 139419 -->
+      A warning will now be printed to standard error the first time
+      <code>Reader.Read</code> is blocked for more than 60 seconds waiting
+      to read entropy from the kernel.
+    </p>
+
+    <p><!-- CL 120055 -->
+      On FreeBSD, <code>Reader</code> now uses the <code>getrandom</code>
+      system call if available, <code>/dev/urandom</code> otherwise.
+    </p>
+
+</dl><!-- crypto/rand -->
+
+<dl id="crypto/rc4"><dt><a href="/pkg/crypto/rc4/">crypto/rc4</a></dt>
+  <dd>
+    <p><!-- CL 130397 -->
+      This release removes the assembly implementations, leaving only
+      the pure Go version. The Go compiler generates code that is
+      either slightly better or slightly worse, depending on the exact
+      CPU. RC4 is insecure and should only be used for compatibility
+      with legacy systems.
+    </p>
+
+</dl><!-- crypto/rc4 -->
+
+<dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
+  <dd>
+    <p><!-- CL 143177 -->
+      If a client sends an initial message that does not look like TLS, the server
+      will no longer reply with an alert, and it will expose the underlying
+      <code>net.Conn</code> in the new field <code>Conn</code> of
+      <a href="/pkg/crypto/tls/#RecordHeaderError"><code>RecordHeaderError</code></a>.
+    </p>
+
+</dl><!-- crypto/tls -->
+
+<dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
+  <dd>
+    <p><!-- CL 145738 -->
+      A query cursor can now be obtained by passing a
+      <a href="/pkg/database/sql/#Rows"><code>*Rows</code></a>
+      value to the <a href="/pkg/database/sql/#Row.Scan"><code>Row.Scan</code></a> method.
+    </p>
+
+</dl><!-- database/sql -->
+
+<dl id="expvar"><dt><a href="/pkg/expvar/">expvar</a></dt>
+  <dd>
+    <p><!-- CL 139537 -->
+      The new <a href="/pkg/expvar/#Map.Delete"><code>Delete</code></a> method allows
+      for deletion of key/value pairs from a <a href="/pkg/expvar/#Map"><code>Map</code></a>.
+    </p>
+
+</dl><!-- expvar -->
+
+<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
+  <dd>
+    <p><!-- CL 142737 -->
+      Maps are now printed in key-sorted order to ease testing. The ordering rules are:
+      <ul>
+        <li>When applicable, nil compares low
+        <li>ints, floats, and strings order by <
+        <li>NaN compares less than non-NaN floats
+        <li>bool compares false before true
+        <li>Complex compares real, then imaginary
+        <li>Pointers compare by machine address
+        <li>Channel values compare by machine address
+        <li>Structs compare each field in turn
+        <li>Arrays compare each element in turn
+        <li>Interface values compare first by <code>reflect.Type</code> describing the concrete type
+            and then by concrete value as described in the previous rules.
+      </ul>
+    </p>
+
+    <p><!-- CL 129777 -->
+      When printing maps, non-reflexive key values like <code>NaN</code> were previously
+      displayed as <code>&lt;nil&gt;</code>. As of this release, the correct values are printed.
+    </p>
+
+</dl><!-- fmt -->
+
+<dl id="go/doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt>
+  <dd>
+    <p><!-- CL 140958 -->
+      To address some outstanding issues in <a href="/cmd/doc/"><code>cmd/doc</code></a>,
+      this package has a new <a href="/pkg/go/doc/#Mode"><code>Mode</code></a> bit,
+      <code>PreserveAST</code>, which controls whether AST data is cleared.
+    </p>
+
+</dl><!-- go/doc -->
+
+<dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
+  <dd>
+    <p><!-- CL 134075 -->
+      The <a href="/pkg/go/token#File"><code>File</code></a> type has a new
+      <a href="/pkg/go/token#File.LineStart"><code>LineStart</code></a> field,
+      which returns the position of the start of a given line. This is especially useful
+      in programs that occasionally handle non-Go files, such as assembly, but wish to use
+      the <code>token.Pos</code> mechanism to identify file positions.
+    </p>
+
+</dl><!-- go/token -->
+
+<dl id="image"><dt><a href="/pkg/image/">image</a></dt>
+  <dd>
+    <p><!-- CL 118755 -->
+      The <a href="/pkg/image/#RegisterFormat"><code>RegisterFormat</code></a> function is now safe for concurrent use.
+    </p>
+
+</dl><!-- image -->
+
+<dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt>
+  <dd>
+    <p><!-- CL 134235 -->
+      Paletted images with fewer than 16 colors now encode to smaller outputs.
+    </p>
+
+</dl><!-- image/png -->
+
+<dl id="io"><dt><a href="/pkg/io/">io</a></dt>
+  <dd>
+    <p><!-- CL 139457 -->
+      The new <a href="/pkg/io#StringWriter"><code>StringWriter</code></a> interface wraps the
+      <a href="/pkg/io/#WriteString"><code>WriteString</code></a> function.
+    </p>
+
+</dl><!-- io -->
+
+<dl id="math"><dt><a href="/pkg/math/">math</a></dt>
+  <dd>
+    <p><!-- CL 153059 -->
+      The functions
+      <a href="/pkg/math/#Sin"><code>Sin</code></a>,
+      <a href="/pkg/math/#Cos"><code>Cos</code></a>,
+      <a href="/pkg/math/#Tan"><code>Tan</code></a>,
+      and <a href="/pkg/math/#Sincos"><code>Sincos</code></a> now
+      apply Payne-Hanek range reduction to huge arguments. This
+      produces more accurate answers, but they will not be bit-for-bit
+      identical with the results in earlier releases.
+    </p>
+</dl><!-- math -->
+
+<dl id="math/bits"><dt><a href="/pkg/math/bits/">math/bits</a></dt>
+  <dd>
+    <p><!-- CL 123157 -->
+    New extended precision operations <a href="/pkg/math/bits/#Add"><code>Add</code></a>, <a href="/pkg/math/bits/#Sub"><code>Sub</code></a>, <a href="/pkg/math/bits/#Mul"><code>Mul</code></a>, and <a href="/pkg/math/bits/#Div"><code>Div</code></a> are available in <code>uint</code>, <code>uint32</code>, and <code>uint64</code> versions.
+    </p>
+
+</dl><!-- math/bits -->
+
+<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
+  <dd>
+    <p><!-- CL 146659 -->
+      The
+      <a href="/pkg/net/#Dialer.DualStack"><code>Dialer.DualStack</code></a> setting is now ignored and deprecated;
+      RFC 6555 Fast Fallback ("Happy Eyeballs") is now enabled by default. To disable, set
+      <a href="/pkg/net/#Dialer.FallbackDelay"><code>Dialer.FallbackDelay</code></a> to a negative value.
+    </p>
+
+    <p><!-- CL 107196 -->
+      Similarly, TCP keep-alives are now enabled by default if
+      <a href="/pkg/net/#Dialer.KeepAlive"><code>Dialer.KeepAlive</code></a> is zero.
+      To disable, set it to a negative value.
+    </p>
+
+    <p><!-- CL 113997 -->
+      On Linux, the <a href="http://man7.org/linux/man-pages/man2/splice.2.html"><code>splice</code> system call</a> is now used when copying from a
+      <a href="/pkg/net/#UnixConn"><code>UnixConn</code></a> to a
+      <a href="/pkg/net/#TCPConn"><code>TCPConn</code></a>.
+    </p>
+</dl><!-- net -->
+
+<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
+  <dd>
+    <p><!-- CL 143177 -->
+      The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext "400 Bad Request" response.
+    </p>
+
+    <p><!-- CL 130115 -->
+      The new <a href="/pkg/net/http/#Client.CloseIdleConnections"><code>Client.CloseIdleConnections</code></a>
+      method calls the <code>Client</code>'s underlying <code>Transport</code>'s <code>CloseIdleConnections</code>
+      if it has one.
+    </p>
+
+    <p><!-- CL 145398 -->
+      The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer rejects HTTP responses which declare
+      HTTP Trailers but don't use chunked encoding. Instead, the declared trailers are now just ignored.
+    </p>
+
+    <p><!-- CL 152080 --> <!-- CL 151857 -->
+      The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer handles <code>MAX_CONCURRENT_STREAMS</code> values
+      advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back
+      to how it was in Go 1.9: each connection to a server can have up to <code>MAX_CONCURRENT_STREAMS</code> requests
+      active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the <code>http2</code> package
+      would block and wait for requests to finish instead of creating new connections.
+      To get the stricter behavior back, import the
+      <a href="https://godoc.org/golang.org/x/net/http2"><code>golang.org/x/net/http2</code></a> package
+      directly and set
+      <a href="https://godoc.org/golang.org/x/net/http2#Transport.StrictMaxConcurrentStreams"><code>Transport.StrictMaxConcurrentStreams</code></a> to
+      <code>true</code>.
+    </p>
+
+</dl><!-- net/http -->
+
+<dl id="net/url"><dt><a href="/pkg/net/url/">net/url</a></dt>
+  <dd>
+    <p><!-- CL 159157, CL 160178 -->
+      <a href="/pkg/net/url/#Parse"><code>Parse</code></a>,
+      <a href="/pkg/net/url/#ParseRequestURI"><code>ParseRequestURI</code></a>,
+      and
+      <a href="/pkg/net/url/#URL.Parse"><code>URL.Parse</code></a>
+      now return an
+      error for URLs containing ASCII control characters, which includes NULL,
+      tab, and newlines.
+    </p>
+
+</dl><!-- net/url -->
+
+<dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
+  <dd>
+    <p><!-- CL 146437 -->
+      The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> now automatically
+      proxies WebSocket requests.
+    </p>
+
+</dl><!-- net/http/httputil -->
+
+<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
+  <dd>
+    <p><!-- CL 125443 -->
+      The new <a href="/pkg/os/#ProcessState.ExitCode"><code>ProcessState.ExitCode</code></a> method
+      returns the process's exit code.
+    </p>
+
+    <p><!-- CL 135075 -->
+      <code>ModeCharDevice</code> has been added to the <code>ModeType</code> bitmask, allowing for
+      <code>ModeDevice | ModeCharDevice</code> to be recovered when masking a
+      <a href="/pkg/os/#FileMode"><code>FileMode</code></a> with <code>ModeType</code>.
+    </p>
+
+    <p><!-- CL 139418 -->
+      The new function <a href="/pkg/os/#UserHomeDir"><code>UserHomeDir</code></a> returns the
+      current user's home directory.
+    </p>
+
+    <p><!-- CL 146020 -->
+      <a href="/pkg/os/#RemoveAll"><code>RemoveAll</code></a> now supports paths longer than 4096 characters
+      on most Unix systems.
+    </p>
+
+    <p><!-- CL 130676 -->
+      <a href="/pkg/os/#File.Sync"><code>File.Sync</code></a> now uses <code>F_FULLFSYNC</code> on macOS
+      to correctly flush the file contents to permanent storage.
+      This may cause the method to run more slowly than in previous releases.
+    </p>
+
+    <p><!--CL 155517 -->
+      <a href="/pkg/os/#File"><code>File</code></a> now supports
+      a <a href="/pkg/os/#File.SyscallConn"><code>SyscallConn</code></a>
+      method returning
+      a <a href="/pkg/syscall/#RawConn"><code>syscall.RawConn</code></a>
+      interface value. This may be used to invoke system-specific
+      operations on the underlying file descriptor.
+    </p>
+
+</dl><!-- os -->
+
+<dl id="path/filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
+  <dd>
+    <p><!-- CL 145220 -->
+      The <a href="/pkg/path/filepath/#IsAbs"><code>IsAbs</code></a> function now returns true when passed
+      a reserved filename on Windows such as <code>NUL</code>.
+      <a href="https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions">List of reserved names.</a>
+    </p>
+
+</dl><!-- path/filepath -->
+
+<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
+  <dd>
+    <p><!-- CL 33572 -->
+      A new <a href="/pkg/reflect#MapIter"><code>MapIter</code></a> type is
+      an iterator for ranging over a map. This type is exposed through the
+      <a href="/pkg/reflect#Value"><code>Value</code></a> type's new
+      <a href="/pkg/reflect#Value.MapRange"><code>MapRange</code></a> method.
+      This follows the same iteration semantics as a range statement, with <code>Next</code>
+      to advance the iterator, and <code>Key</code>/<code>Value</code> to access each entry.
+    </p>
+
+</dl><!-- reflect -->
+
+<dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
+  <dd>
+    <p><!-- CL 139784 -->
+      <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a> is no longer necessary
+      to avoid lock contention, so it has been given a partial deprecation comment.
+      <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a>
+      may still be appropriate if the reason for its use is to make two copies with
+      different <a href="/pkg/regexp/#Regexp.Longest"><code>Longest</code></a> settings.
+    </p>
+
+</dl><!-- regexp -->
+
+<dl id="runtime/debug"><dt><a href="/pkg/runtime/debug/">runtime/debug</a></dt>
+  <dd>
+    <p><!-- CL 144220 -->
+      A new <a href="/pkg/runtime/debug/#BuildInfo"><code>BuildInfo</code></a> type
+      exposes the build information read from the running binary, available only in
+      binaries built with module support. This includes the main package path, main
+      module information, and the module dependencies. This type is given though the
+      <a href="/pkg/runtime/debug/#ReadBuildInfo"><code>ReadBuildInfo</code></a> function
+      on <a href="/pkg/runtime/debug/#BuildInfo"><code>BuildInfo</code></a>.
+    </p>
+
+</dl><!-- runtime/debug -->
+
+<dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
+  <dd>
+    <p><!-- CL 137855 -->
+      The new function <a href="/pkg/strings/#ReplaceAll"><code>ReplaceAll</code></a> returns a copy of
+      a string with all non-overlapping instances of a value replaced by another.
+    </p>
+
+    <p><!-- CL 145098 -->
+      A pointer to a zero-value <a href="/pkg/strings/#Reader"><code>Reader</code></a> is now
+      functionally equivalent to <a href="/pkg/strings/#NewReader"><code>NewReader</code></a><code>(nil)</code>.
+      Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
+    </p>
+
+    <p><!-- CL 122835 -->
+      The new <a href="/pkg/strings/#Builder.Cap"><code>Builder.Cap</code></a> method returns the capacity of the builder's underlying byte slice.
+    </p>
+
+    <p><!-- CL 131495 -->
+      The character mapping functions <a href="/pkg/strings/#Map"><code>Map</code></a>,
+      <a href="/pkg/strings/#Title"><code>Title</code></a>,
+      <a href="/pkg/strings/#ToLower"><code>ToLower</code></a>,
+      <a href="/pkg/strings/#ToLowerSpecial"><code>ToLowerSpecial</code></a>,
+      <a href="/pkg/strings/#ToTitle"><code>ToTitle</code></a>,
+      <a href="/pkg/strings/#ToTitleSpecial"><code>ToTitleSpecial</code></a>,
+      <a href="/pkg/strings/#ToUpper"><code>ToUpper</code></a>, and
+      <a href="/pkg/strings/#ToUpperSpecial"><code>ToUpperSpecial</code></a>
+      now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements
+      needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified.
+    </p>
+
+</dl><!-- strings -->
+
+<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
+  <dd>
+    <p><!-- CL 138595 -->
+      64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly.
+    </p>
+
+    <p><!-- CL 125456 -->
+      The Unix socket
+      (<a href="https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/"><code>AF_UNIX</code></a>)
+      address family is now supported for compatible versions of Windows.
+    </p>
+
+    <p><!-- CL 147117 -->
+      The new function  <a href="/pkg/syscall/?GOOS=windows&GOARCH=amd64#Syscall18"><code>Syscall18</code></a>
+      has been introduced for Windows, allowing for calls with up to 18 arguments.
+    </p>
+
+</dl><!-- syscall -->
+
+<dl id="syscall/js"><dt><a href="/pkg/syscall/js/">syscall/js</a></dt>
+  <dd>
+    <p><!-- CL 153559 -->
+    <p>
+      The <code>Callback</code> type and <code>NewCallback</code> function have been renamed;
+      they are now called
+      <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Func"><code>Func</code></a> and
+      <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#FuncOf"><code>FuncOf</code></a>, respectively.
+      This is a breaking change, but WebAssembly support is still experimental
+      and not yet subject to the
+      <a href="/doc/go1compat">Go 1 compatibility promise</a>. Any code using the
+      old names will need to be updated.
+    </p>
+
+    <p><!-- CL 141644 -->
+      If a type implements the new
+      <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Wrapper"><code>Wrapper</code></a>
+      interface,
+      <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#ValueOf"><code>ValueOf</code></a>
+      will use it to return the JavaScript value for that type.
+    </p>
+
+    <p><!-- CL 143137 -->
+      The meaning of the zero
+      <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value"><code>Value</code></a>
+      has changed. It now represents the JavaScript <code>undefined</code> value
+      instead of the number zero.
+      This is a breaking change, but WebAssembly support is still experimental
+      and not yet subject to the
+      <a href="/doc/go1compat">Go 1 compatibility promise</a>. Any code relying on
+      the zero <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value"><code>Value</code></a>
+      to mean the number zero will need to be updated.
+    </p>
+
+    <p><!-- CL 144384 -->
+      The new
+      <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value.Truthy"><code>Value.Truthy</code></a>
+      method reports the
+      <a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">JavaScript "truthiness"</a>
+      of a given value.
+    </p>
+
+</dl><!-- syscall/js -->
+
+<dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
+  <dd>
+    <p><!-- CL 139258 -->
+    The <a href="/cmd/go/#hdr-Testing_flags"><code>-benchtime</code></a> flag now supports setting an explicit iteration count instead of a time when the value ends with an "<code>x</code>". For example, <code>-benchtime=100x</code> runs the benchmark 100 times.
+    </p>
+
+</dl><!-- testing -->
+
+<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
+  <dd>
+    <p><!-- CL 142217 -->
+      When executing a template, long context values are no longer truncated in errors.
+    </p>
+    <p>
+      <code>executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent"</code>
+    </p>
+    <p>
+      is now
+    </p>
+    <p>
+      <code>executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent"</code>
+    </p>
+
+  <dd>
+    <p><!-- CL 143097 -->
+      If a user-defined function called by a template panics, the
+      panic is now caught and returned as an error by
+      the <code>Execute</code> or <code>ExecuteTemplate</code> method.
+    </p>
+</dl><!-- text/template -->
+
+<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
+  <dd>
+    <p><!-- CL 151299 -->
+      The time zone database in <code>$GOROOT/lib/time/zoneinfo.zip</code>
+      has been updated to version 2018i. Note that this ZIP file is
+      only used if a time zone database is not provided by the operating
+      system.
+    </p>
+
+</dl><!-- time -->
+
+<dl id="unsafe"><dt><a href="/pkg/unsafe/">unsafe</a></dt>
+  <dd>
+    <p><!-- CL 146058 -->
+      It is invalid to convert a nil <code>unsafe.Pointer</code> to <code>uintptr</code> and back with arithmetic.
+      (This was already invalid, but will now cause the compiler to misbehave.)
+    </p>
+
+</dl><!-- unsafe -->
diff --git a/doc/go1.3.html b/doc/go1.3.html
index 18c638a..feed648 100644
--- a/doc/go1.3.html
+++ b/doc/go1.3.html
@@ -525,7 +525,7 @@
 The <a href="/pkg/net/http/"><code>net/http</code></a> package's
 <a href="/pkg/net/http/#Request.ParseMultipartForm"><code>Request.ParseMultipartForm</code></a>
 method will now return an error if the body's <code>Content-Type</code>
-is not <code>mutipart/form-data</code>.
+is not <code>multipart/form-data</code>.
 Prior to Go 1.3 it would silently fail and return <code>nil</code>.
 Code that relies on the previous behavior should be updated.
 </li>
diff --git a/doc/go_faq.html b/doc/go_faq.html
index b1c1529..305878f 100644
--- a/doc/go_faq.html
+++ b/doc/go_faq.html
@@ -108,6 +108,26 @@
 He has unique features; he's the <em>Go gopher</em>, not just any old gopher.
 </p>
 
+<h3 id="go_or_golang">
+Is the language called Go or Golang?</h3>
+
+<p>
+The language is called Go.
+The "golang" moniker arose because the web site is
+<a href="https://golang.org">golang.org</a>, not
+go.org, which was not available to us.
+Many use the golang name, though, and it is handy as
+a label.
+For instance, the Twitter tag for the language is "#golang".
+The language's name is just plain Go, regardless.
+</p>
+
+<p>
+A side note: Although the
+<a href="https://blog.golang.org/go-brand">official logo</a>
+has two capital letters, the language name is written Go, not GO.
+</p>
+
 <h3 id="creating_a_new_language">
 Why did you create a new language?</h3>
 
@@ -784,7 +804,7 @@
 <p>
 A type must then implement the <code>ImplementsFooer</code> method to be a
 <code>Fooer</code>, clearly documenting the fact and announcing it in
-<a href="/cmd/godoc/">godoc</a>'s output.
+<a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol">go doc</a>'s output.
 </p>
 
 <pre>
@@ -1749,7 +1769,7 @@
 type <code>*T</code> consists of all methods with receiver <code>*T</code> or
 <code>T</code>.
 That means the method set of <code>*T</code>
-includes that of <code>T</code>),
+includes that of <code>T</code>,
 but not the reverse.
 </p>
 
@@ -2438,7 +2458,7 @@
 Work continues to refine the algorithm, reduce overhead and
 latency further, and to explore new approaches.
 The 2018
-<a href="https://talks.golang.org/2018/ismmkeynote">ISMM keynote</a>
+<a href="https://blog.golang.org/ismmkeynote">ISMM keynote</a>
 by Rick Hudson of the Go team
 describes the progress so far and suggests some future approaches.
 </p>
diff --git a/doc/go_mem.html b/doc/go_mem.html
index 143f3b2..d355beb 100644
--- a/doc/go_mem.html
+++ b/doc/go_mem.html
@@ -418,8 +418,12 @@
 </pre>
 
 <p>
-calling <code>twoprint</code> causes <code>"hello, world"</code> to be printed twice.
-The first call to <code>doprint</code> runs <code>setup</code> once.
+calling <code>twoprint</code> will call <code>setup</code> exactly
+once.
+The <code>setup</code> function will complete before either call
+of <code>print</code>.
+The result will be that <code>"hello, world"</code> will be printed
+twice.
 </p>
 
 <h2>Incorrect synchronization</h2>
diff --git a/doc/go_spec.html b/doc/go_spec.html
index f70ff7a..dcc81ed 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
 <!--{
 	"Title": "The Go Programming Language Specification",
-	"Subtitle": "Version of May 9, 2018",
+	"Subtitle": "Version of November 16, 2018",
 	"Path": "/ref/spec"
 }-->
 
@@ -811,7 +811,7 @@
 types</a> and thus distinct except
 <code>byte</code>, which is an <a href="#Alias_declarations">alias</a> for <code>uint8</code>, and
 <code>rune</code>, which is an alias for <code>int32</code>.
-Conversions
+Explicit conversions
 are required when different numeric types are mixed in an expression
 or assignment. For instance, <code>int32</code> and <code>int</code>
 are not the same type even though they may have the same size on a
@@ -823,6 +823,7 @@
 <p>
 A <i>string type</i> represents the set of string values.
 A string value is a (possibly empty) sequence of bytes.
+The number of bytes is called the length of the string and is never negative.
 Strings are immutable: once created,
 it is impossible to change the contents of a string.
 The predeclared string type is <code>string</code>;
@@ -830,7 +831,7 @@
 </p>
 
 <p>
-The length of a string <code>s</code> (its size in bytes) can be discovered using
+The length of a string <code>s</code> can be discovered using
 the built-in function <a href="#Length_and_capacity"><code>len</code></a>.
 The length is a compile-time constant if the string is a constant.
 A string's bytes can be accessed by integer <a href="#Index_expressions">indices</a>
@@ -846,8 +847,7 @@
 <p>
 An array is a numbered sequence of elements of a single
 type, called the element type.
-The number of elements is called the length and is never
-negative.
+The number of elements is called the length of the array and is never negative.
 </p>
 
 <pre class="ebnf">
@@ -883,6 +883,7 @@
 A slice is a descriptor for a contiguous segment of an <i>underlying array</i> and
 provides access to a numbered sequence of elements from that array.
 A slice type denotes the set of all slices of arrays of its element type.
+The number of elements is called the length of the slice and is never negative.
 The value of an uninitialized slice is <code>nil</code>.
 </p>
 
@@ -891,8 +892,7 @@
 </pre>
 
 <p>
-Like arrays, slices are indexable and have a length.  The length of a
-slice <code>s</code> can be discovered by the built-in function
+The length of a slice <code>s</code> can be discovered by the built-in function
 <a href="#Length_and_capacity"><code>len</code></a>; unlike with arrays it may change during
 execution.  The elements can be addressed by integer <a href="#Index_expressions">indices</a>
 0 through <code>len(s)-1</code>.  The slice index of a
@@ -1349,7 +1349,8 @@
 <i>send</i> or <i>receive</i>. If no direction is given, the channel is
 <i>bidirectional</i>.
 A channel may be constrained only to send or only to receive by
-<a href="#Conversions">conversion</a> or <a href="#Assignments">assignment</a>.
+<a href="#Assignments">assignment</a> or
+explicit <a href="#Conversions">conversion</a>.
 </p>
 
 <pre>
@@ -2069,9 +2070,9 @@
 If a type is present, each variable is given that type.
 Otherwise, each variable is given the type of the corresponding
 initialization value in the assignment.
-If that value is an untyped constant, it is first
+If that value is an untyped constant, it is first implicitly
 <a href="#Conversions">converted</a> to its <a href="#Constants">default type</a>;
-if it is an untyped boolean value, it is first converted to type <code>bool</code>.
+if it is an untyped boolean value, it is first implicitly converted to type <code>bool</code>.
 The predeclared value <code>nil</code> cannot be used to initialize a variable
 with no explicit type.
 </p>
@@ -2112,8 +2113,8 @@
 i, j := 0, 10
 f := func() int { return 7 }
 ch := make(chan int)
-r, w := os.Pipe(fd)  // os.Pipe() returns two values
-_, y, _ := coord(p)  // coord() returns three values; only interested in y coordinate
+r, w, _ := os.Pipe()  // os.Pipe() returns a connected pair of Files and an error, if any
+_, y, _ := coord(p)   // coord() returns three values; only interested in y coordinate
 </pre>
 
 <p>
@@ -2202,11 +2203,11 @@
 <p>
 The receiver is specified via an extra parameter section preceding the method
 name. That parameter section must declare a single non-variadic parameter, the receiver.
-Its type must be of the form <code>T</code> or <code>*T</code> (possibly using
-parentheses) where <code>T</code> is a type name. The type denoted by <code>T</code> is called
-the receiver <i>base type</i>; it must not be a pointer or interface type and
-it must be <a href="#Type_definitions">defined</a> in the same package as the method.
-The method is said to be <i>bound</i> to the base type and the method name
+Its type must be a <a href="#Type_definitions">defined</a> type <code>T</code> or a
+pointer to a defined type <code>T</code>. <code>T</code> is called the receiver
+<i>base type</i>. A receiver base type cannot be a pointer or interface type and
+it must be defined in the same package as the method.
+The method is said to be <i>bound</i> to its receiver base type and the method name
 is visible only within <a href="#Selectors">selectors</a> for type <code>T</code>
 or <code>*T</code>.
 </p>
@@ -2226,7 +2227,7 @@
 </p>
 
 <p>
-Given type <code>Point</code>, the declarations
+Given defined type <code>Point</code>, the declarations
 </p>
 
 <pre>
@@ -3260,7 +3261,7 @@
 yields an additional untyped boolean value. The value of <code>ok</code> is <code>true</code>
 if the assertion holds. Otherwise it is <code>false</code> and the value of <code>v</code> is
 the <a href="#The_zero_value">zero value</a> for type <code>T</code>.
-No run-time panic occurs in this case.
+No <a href="#Run_time_panics">run-time panic</a> occurs in this case.
 </p>
 
 
@@ -3433,7 +3434,7 @@
 
 <p>
 Except for shift operations, if one operand is an untyped <a href="#Constants">constant</a>
-and the other operand is not, the constant is <a href="#Conversions">converted</a>
+and the other operand is not, the constant is implicitly <a href="#Conversions">converted</a>
 to the type of the other operand.
 </p>
 
@@ -3442,7 +3443,7 @@
 or be an untyped constant <a href="#Representability">representable</a> by a
 value of type <code>uint</code>.
 If the left operand of a non-constant shift expression is an untyped constant,
-it is first converted to the type it would assume if the shift expression were
+it is first implicitly converted to the type it would assume if the shift expression were
 replaced by its left operand alone.
 </p>
 
@@ -3624,7 +3625,7 @@
 <code>-</code>, <code>*</code>, <code>/</code>, and <code>&lt;&lt;</code> may legally
 overflow and the resulting value exists and is deterministically defined
 by the signed integer representation, the operation, and its operands.
-No exception is raised as a result of overflow.
+Overflow does not cause a <a href="#Run_time_panics">run-time panic</a>.
 A compiler may not optimize code under the assumption that overflow does
 not occur. For instance, it may not assume that <code>x &lt; x + 1</code> is always true.
 </p>
@@ -3645,7 +3646,7 @@
 An implementation may combine multiple floating-point operations into a single
 fused operation, possibly across statements, and produce a result that differs
 from the value obtained by executing and rounding the instructions individually.
-A floating-point type <a href="#Conversions">conversion</a> explicitly rounds to
+An explicit floating-point type <a href="#Conversions">conversion</a> rounds to
 the precision of the target type, preventing fusion that would discard that rounding.
 </p>
 
@@ -3907,7 +3908,14 @@
 <h3 id="Conversions">Conversions</h3>
 
 <p>
-Conversions are expressions of the form <code>T(x)</code>
+A conversion changes the <a href="#Types">type</a> of an expression
+to the type specified by the conversion.
+A conversion may appear literally in the source, or it may be <i>implied</i>
+by the context in which an expression appears.
+</p>
+
+<p>
+An <i>explicit</i> conversion is an expression of the form <code>T(x)</code>
 where <code>T</code> is a type and <code>x</code> is an expression
 that can be converted to type <code>T</code>.
 </p>
@@ -3938,7 +3946,7 @@
 A <a href="#Constants">constant</a> value <code>x</code> can be converted to
 type <code>T</code> if <code>x</code> is <a href="#Representability">representable</a>
 by a value of <code>T</code>.
-As a special case, an integer constant <code>x</code> can be converted to a
+As a special case, an integer constant <code>x</code> can be explicitly converted to a
 <a href="#String_types">string type</a> using the
 <a href="#Conversions_to_and_from_a_string_type">same rule</a>
 as for non-constant <code>x</code>.
@@ -4672,13 +4680,13 @@
 <li>
 	If an untyped constant
 	is assigned to a variable of interface type or the blank identifier,
-	the constant is first <a href="#Conversions">converted</a> to its
+	the constant is first implicitly <a href="#Conversions">converted</a> to its
 	 <a href="#Constants">default type</a>.
 </li>
 
 <li>
 	If an untyped boolean value is assigned to a variable of interface type or
-	the blank identifier, it is first converted to type <code>bool</code>.
+	the blank identifier, it is first implicitly converted to type <code>bool</code>.
 </li>
 </ol>
 
@@ -4764,14 +4772,14 @@
 </pre>
 
 <p>
-If the switch expression evaluates to an untyped constant, it is first
+If the switch expression evaluates to an untyped constant, it is first implicitly
 <a href="#Conversions">converted</a> to its <a href="#Constants">default type</a>;
-if it is an untyped boolean value, it is first converted to type <code>bool</code>.
+if it is an untyped boolean value, it is first implicitly converted to type <code>bool</code>.
 The predeclared untyped value <code>nil</code> cannot be used as a switch expression.
 </p>
 
 <p>
-If a case expression is untyped, it is first <a href="#Conversions">converted</a>
+If a case expression is untyped, it is first implicitly <a href="#Conversions">converted</a>
 to the type of the switch expression.
 For each (possibly converted) case expression <code>x</code> and the value <code>t</code>
 of the switch expression, <code>x == t</code> must be a valid <a href="#Comparison_operators">comparison</a>.
@@ -5546,7 +5554,10 @@
 and saved anew but the actual function is not invoked.
 Instead, deferred functions are invoked immediately before
 the surrounding function returns, in the reverse order
-they were deferred.
+they were deferred. That is, if the surrounding function
+returns through an explicit <a href="#Return_statements">return statement</a>,
+deferred functions are executed <i>after</i> any result parameters are set
+by that return statement but <i>before</i> the function returns to its caller.
 If a deferred function value evaluates
 to <code>nil</code>, execution <a href="#Handling_panics">panics</a>
 when the function is invoked, not when the "defer" statement is executed.
@@ -5572,12 +5583,13 @@
 	defer fmt.Print(i)
 }
 
-// f returns 1
+// f returns 42
 func f() (result int) {
 	defer func() {
-		result++
+		// result is accessed after it was set to 6 by the return statement
+		result *= 7
 	}()
-	return 0
+	return 6
 }
 </pre>
 
@@ -5877,7 +5889,7 @@
 with the corresponding floating-point constituents:
 <code>complex64</code> for <code>float32</code> arguments, and
 <code>complex128</code> for <code>float64</code> arguments.
-If one of the arguments evaluates to an untyped constant, it is first
+If one of the arguments evaluates to an untyped constant, it is first implicitly
 <a href="#Conversions">converted</a> to the type of the other argument.
 If both arguments evaluate to untyped constants, they must be non-complex
 numbers or their imaginary parts must be zero, and the return value of
diff --git a/doc/help.html b/doc/help.html
index f668196..f11e286 100644
--- a/doc/help.html
+++ b/doc/help.html
@@ -27,6 +27,11 @@
 forum for Go programmers.
 </p>
 
+<h3 id="discord"><a href="https://discord.gg/64C346U">Gophers Discord</a></h3>
+<p>
+Get live support and talk with other gophers on the Go Discord.
+</p>
+
 <h3 id="slack"><a href="https://blog.gopheracademy.com/gophers-slack-community/">Gopher Slack</a></h3>
 <p>Get live support from other users in the Go slack channel.</p>
 
diff --git a/doc/install-source.html b/doc/install-source.html
index f6d9473..bbe7cdf 100644
--- a/doc/install-source.html
+++ b/doc/install-source.html
@@ -349,15 +349,7 @@
 <p>
 The source code for several Go tools (including <a href="/cmd/godoc/">godoc</a>)
 is kept in <a href="https://golang.org/x/tools">the go.tools repository</a>.
-To install all of them, run the <code>go</code> <code>get</code> command:
-</p>
-
-<pre>
-$ go get golang.org/x/tools/cmd/...
-</pre>
-
-<p>
-Or if you just want to install a specific command (<code>godoc</code> in this case):
+To install one of the tools (<code>godoc</code> in this case):
 </p>
 
 <pre>
@@ -374,16 +366,6 @@
 see <a href="/doc/code.html">How to Write Go Code</a> for the details.
 </p>
 
-<p>
-<b>Note</b>: The <code>go</code> command will install the <code>godoc</code>
-binary to <code>$GOROOT/bin</code> (or <code>$GOBIN</code>) and the
-<code>cover</code> and <code>vet</code> binaries to
-<code>$GOROOT/pkg/tool/$GOOS_$GOARCH</code>.
-You can access the latter commands with
-"<code>go</code> <code>tool</code> <code>cover</code>" and
-"<code>go</code> <code>tool</code> <code>vet</code>".
-</p>
-
 <h2 id="community">Community resources</h2>
 
 <p>
@@ -639,14 +621,10 @@
 </p>
 </li>
 
-<li><code>$GOMIPS</code> (for <code>mips</code> and <code>mipsle</code> only)
+<li><code>$GOMIPS</code> (for <code>mips</code> and <code>mipsle</code> only) <br> <code>$GOMIPS64</code> (for <code>mips64</code> and <code>mips64le</code> only)
 <p>
-This sets whether to use floating point instructions.
+	These variables set whether to use floating point instructions. Set to "<code>hardfloat</code>" to use floating point instructions; this is the default.  Set to "<code>softfloat</code>" to use soft floating point.
 </p>
-<ul>
-	<li><code>GOMIPS=hardfloat</code>: use floating point instructions (the default)</li>
-	<li><code>GOMIPS=softfloat</code>: use soft floating point</li>
-</ul>
 </li>
 
 </ul>
@@ -670,7 +648,6 @@
 </p>
 
 <pre>
-export GOROOT=$HOME/go1.X
 export GOARCH=amd64
 export GOOS=linux
 </pre>
diff --git a/doc/install.html b/doc/install.html
index 2e0c7f8..a41c60b 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -172,11 +172,6 @@
 </p>
 
 <p>
-If you chose a directory other than <code>c:\Go</code>,
-you must set the <code>GOROOT</code> environment variable to your chosen path.
-</p>
-
-<p>
 Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to your <code>PATH</code> environment variable.
 </p>
 
@@ -271,6 +266,39 @@
 </p>
 
 
+<h2 id="extra_versions">Installing extra Go versions</h2>
+
+<p>
+It may be useful to have multiple Go versions installed on the same machine, for
+example, to ensure that a package's tests pass on multiple Go versions.
+Once you have one Go version installed, you can install another (such as 1.10.7)
+as follows:
+</p>
+
+<pre>
+$ go get golang.org/dl/go1.10.7
+$ go1.10.7 download
+</pre>
+
+<p>
+The newly downloaded version can be used like <code>go</code>:
+</p>
+
+<pre>
+$ go1.10.7 version
+go version go1.10.7 linux/amd64
+</pre>
+
+<p>
+All Go versions available via this method are listed on
+<a href="https://godoc.org/golang.org/dl#pkg-subdirectories">the download page</a>.
+You can find where each of these extra Go versions is installed by looking
+at its <code>GOROOT</code>; for example, <code>go1.10.7 env GOROOT</code>.
+To uninstall a downloaded version, just remove its <code>GOROOT</code> directory
+and the <code>goX.Y.Z</code> binary.
+</p>
+
+
 <h2 id="uninstall">Uninstalling Go</h2>
 
 <p>
diff --git a/doc/progs/eff_sequence.go b/doc/progs/eff_sequence.go
index 11c885a..ab1826b 100644
--- a/doc/progs/eff_sequence.go
+++ b/doc/progs/eff_sequence.go
@@ -28,11 +28,18 @@
 	s[i], s[j] = s[j], s[i]
 }
 
+// Copy returns a copy of the Sequence.
+func (s Sequence) Copy() Sequence {
+	copy := make(Sequence, 0, len(s))
+	return append(copy, s...)
+}
+
 // Method for printing - sorts the elements before printing.
 func (s Sequence) String() string {
+	s = s.Copy() // Make a copy; don't overwrite argument.
 	sort.Sort(s)
 	str := "["
-	for i, elem := range s {
+	for i, elem := range s { // Loop is O(N²); will fix that in next example.
 		if i > 0 {
 			str += " "
 		}
diff --git a/doc/security.html b/doc/security.html
index c305ae0..b334963 100644
--- a/doc/security.html
+++ b/doc/security.html
@@ -70,7 +70,7 @@
 <li>Code is audited to find any potential similar problems.</li>
 <li>If it is determined, in consultation with the submitter, that a CVE-ID is
 required, the primary handler obtains one via email to
-<a href="http://oss-security.openwall.org/wiki/mailing-lists/distros">oss-distros</a>.</li>
+<a href="https://oss-security.openwall.org/wiki/mailing-lists/distros">oss-distros</a>.</li>
 <li>Fixes are prepared for the two most recent major releases and the head/master
 revision. These fixes are not yet committed to the public repository.</li>
 <li>A notification is sent to the
diff --git a/lib/time/update.bash b/lib/time/update.bash
index 629e74f..8d6785b 100755
--- a/lib/time/update.bash
+++ b/lib/time/update.bash
@@ -8,8 +8,8 @@
 # Consult https://www.iana.org/time-zones for the latest versions.
 
 # Versions to use.
-CODE=2018e
-DATA=2018e
+CODE=2018i
+DATA=2018i
 
 set -e
 rm -rf work
diff --git a/lib/time/zoneinfo.zip b/lib/time/zoneinfo.zip
index 08dca21..bacb724 100644
--- a/lib/time/zoneinfo.zip
+++ b/lib/time/zoneinfo.zip
Binary files differ
diff --git a/misc/cgo/errors/errors_test.go b/misc/cgo/errors/errors_test.go
index 118187f..59054f4 100644
--- a/misc/cgo/errors/errors_test.go
+++ b/misc/cgo/errors/errors_test.go
@@ -121,12 +121,19 @@
 		"issue16591.go",
 		"issue18452.go",
 		"issue18889.go",
+		"issue26745.go",
+		"issue28721.go",
 	} {
 		check(t, file)
 	}
 
 	if sizeofLongDouble(t) > 8 {
-		check(t, "err4.go")
+		for _, file := range []string{
+			"err4.go",
+			"issue28069.go",
+		} {
+			check(t, file)
+		}
 	}
 }
 
diff --git a/misc/cgo/errors/ptr_test.go b/misc/cgo/errors/ptr_test.go
index fe8dfff..254671f 100644
--- a/misc/cgo/errors/ptr_test.go
+++ b/misc/cgo/errors/ptr_test.go
@@ -357,6 +357,73 @@
 		body:    `r, _, _ := os.Pipe(); r.SetDeadline(time.Now().Add(C.US * time.Microsecond))`,
 		fail:    false,
 	},
+	{
+		// Test for double evaluation of channel receive.
+		name:    "chan-recv",
+		c:       `void f(char** p) {}`,
+		imports: []string{"time"},
+		body:    `c := make(chan []*C.char, 2); c <- make([]*C.char, 1); go func() { time.Sleep(10 * time.Second); panic("received twice from chan") }(); C.f(&(<-c)[0]);`,
+		fail:    false,
+	},
+	{
+		// Test that converting the address of a struct field
+		// to unsafe.Pointer still just checks that field.
+		// Issue #25941.
+		name:    "struct-field",
+		c:       `void f(void* p) {}`,
+		imports: []string{"unsafe"},
+		support: `type S struct { p *int; a [8]byte; u uintptr }`,
+		body:    `s := &S{p: new(int)}; C.f(unsafe.Pointer(&s.a))`,
+		fail:    false,
+	},
+	{
+		// Test that converting multiple struct field
+		// addresses to unsafe.Pointer still just checks those
+		// fields. Issue #25941.
+		name:    "struct-field-2",
+		c:       `void f(void* p, int r, void* s) {}`,
+		imports: []string{"unsafe"},
+		support: `type S struct { a [8]byte; p *int; b int64; }`,
+		body:    `s := &S{p: new(int)}; C.f(unsafe.Pointer(&s.a), 32, unsafe.Pointer(&s.b))`,
+		fail:    false,
+	},
+	{
+		// Test that second argument to cgoCheckPointer is
+		// evaluated when a deferred function is deferred, not
+		// when it is run.
+		name:    "defer2",
+		c:       `void f(char **pc) {}`,
+		support: `type S1 struct { s []*C.char }; type S2 struct { ps *S1 }`,
+		body:    `p := &S2{&S1{[]*C.char{nil}}}; defer C.f(&p.ps.s[0]); p.ps = nil`,
+		fail:    false,
+	},
+	{
+		// Test that indexing into a function call still
+		// examines only the slice being indexed.
+		name:    "buffer",
+		c:       `void f(void *p) {}`,
+		imports: []string{"bytes", "unsafe"},
+		body:    `var b bytes.Buffer; b.WriteString("a"); C.f(unsafe.Pointer(&b.Bytes()[0]))`,
+		fail:    false,
+	},
+	{
+		// Test that bgsweep releasing a finalizer is OK.
+		name:    "finalizer",
+		c:       `// Nothing to declare.`,
+		imports: []string{"os"},
+		support: `func open() { os.Open(os.Args[0]) }; var G [][]byte`,
+		body:    `for i := 0; i < 10000; i++ { G = append(G, make([]byte, 4096)); if i % 100 == 0 { G = nil; open() } }`,
+		fail:    false,
+	},
+	{
+		// Test that converting generated struct to interface is OK.
+		name:    "structof",
+		c:       `// Nothing to declare.`,
+		imports: []string{"reflect"},
+		support: `type MyInt int; func (i MyInt) Get() int { return int(i) }; type Getter interface { Get() int }`,
+		body:    `t := reflect.StructOf([]reflect.StructField{{Name: "MyInt", Type: reflect.TypeOf(MyInt(0)), Anonymous: true}}); v := reflect.New(t).Elem(); v.Interface().(Getter).Get()`,
+		fail:    false,
+	},
 }
 
 func TestPointerChecks(t *testing.T) {
@@ -429,7 +496,7 @@
 
 	cmd := exec.Command("go", "build")
 	cmd.Dir = src
-	cmd.Env = addEnv("GOPATH", gopath)
+	cmd.Env = append(os.Environ(), "GOPATH="+gopath)
 	buf, err := cmd.CombinedOutput()
 	if err != nil {
 		t.Logf("%#q:\n%s", args(cmd), buf)
@@ -501,16 +568,5 @@
 }
 
 func cgocheckEnv(val string) []string {
-	return addEnv("GODEBUG", "cgocheck="+val)
-}
-
-func addEnv(key, val string) []string {
-	env := []string{key + "=" + val}
-	look := key + "="
-	for _, e := range os.Environ() {
-		if !strings.HasPrefix(e, look) {
-			env = append(env, e)
-		}
-	}
-	return env
+	return append(os.Environ(), "GODEBUG=cgocheck="+val)
 }
diff --git a/misc/cgo/errors/src/issue26745.go b/misc/cgo/errors/src/issue26745.go
new file mode 100644
index 0000000..0e22453
--- /dev/null
+++ b/misc/cgo/errors/src/issue26745.go
@@ -0,0 +1,17 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// int a;
+// void CF(int i) {}
+import "C"
+
+func F1(i int) int {
+	return C.a + 1 // ERROR HERE: :13
+}
+
+func F2(i int) {
+	C.CF(i) // ERROR HERE: :6
+}
diff --git a/misc/cgo/errors/src/issue28069.go b/misc/cgo/errors/src/issue28069.go
new file mode 100644
index 0000000..e19a3b4
--- /dev/null
+++ b/misc/cgo/errors/src/issue28069.go
@@ -0,0 +1,26 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that the error message for an unrepresentable typedef in a
+// union appears on the right line. This test is only run if the size
+// of long double is larger than 64.
+
+package main
+
+/*
+typedef long double             Float128;
+
+typedef struct SV {
+    union {
+        Float128         float128;
+    } value;
+} SV;
+*/
+import "C"
+
+type ts struct {
+	tv *C.SV // ERROR HERE
+}
+
+func main() {}
diff --git a/misc/cgo/errors/src/issue28721.go b/misc/cgo/errors/src/issue28721.go
new file mode 100644
index 0000000..0eb2a92
--- /dev/null
+++ b/misc/cgo/errors/src/issue28721.go
@@ -0,0 +1,29 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// cgo should reject the use of mangled C names.
+
+package main
+
+/*
+typedef struct a {
+	int i;
+} a;
+void fn(void) {}
+*/
+import "C"
+
+type B _Ctype_struct_a // ERROR HERE
+
+var a _Ctype_struct_a // ERROR HERE
+
+type A struct {
+	a *_Ctype_struct_a // ERROR HERE
+}
+
+var notExist _Ctype_NotExist // ERROR HERE
+
+func main() {
+	_Cfunc_fn() // ERROR HERE
+}
diff --git a/misc/cgo/test/callback.go b/misc/cgo/test/callback.go
index b88bf13..4fc6b39 100644
--- a/misc/cgo/test/callback.go
+++ b/misc/cgo/test/callback.go
@@ -179,7 +179,6 @@
 	pc := make([]uintptr, 100)
 	n := 0
 	name := []string{
-		"runtime.call16",
 		"runtime.cgocallbackg1",
 		"runtime.cgocallbackg",
 		"runtime.cgocallback_gofunc",
@@ -193,9 +192,6 @@
 		"testing.tRunner",
 		"runtime.goexit",
 	}
-	if unsafe.Sizeof((*byte)(nil)) == 8 {
-		name[0] = "runtime.call32"
-	}
 	nestedCall(func() {
 		n = runtime.Callers(4, pc)
 	})
@@ -295,7 +291,7 @@
 }
 
 func testCallbackStack(t *testing.T) {
-	// Make cgo call and callback with different amount of stack stack available.
+	// Make cgo call and callback with different amount of stack available.
 	// We do not do any explicit checks, just ensure that it does not crash.
 	for _, f := range splitTests {
 		f()
diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go
index ccacc50..2cb93d9 100644
--- a/misc/cgo/test/cgo_test.go
+++ b/misc/cgo/test/cgo_test.go
@@ -92,6 +92,9 @@
 func Test23356(t *testing.T)                 { test23356(t) }
 func Test26066(t *testing.T)                 { test26066(t) }
 func Test26213(t *testing.T)                 { test26213(t) }
+func Test27660(t *testing.T)                 { test27660(t) }
+func Test28896(t *testing.T)                 { test28896(t) }
+func Test30065(t *testing.T)                 { test30065(t) }
 
 func BenchmarkCgoCall(b *testing.B)  { benchCgoCall(b) }
 func BenchmarkGoString(b *testing.B) { benchGoString(b) }
diff --git a/misc/cgo/test/issue27054/egl.h b/misc/cgo/test/issue27054/egl.h
new file mode 100644
index 0000000..33a759e
--- /dev/null
+++ b/misc/cgo/test/issue27054/egl.h
@@ -0,0 +1,7 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This is the relevant part of EGL/egl.h.
+
+typedef void *EGLDisplay;
diff --git a/misc/cgo/test/issue27054/test27054.go b/misc/cgo/test/issue27054/test27054.go
new file mode 100644
index 0000000..186f5bd
--- /dev/null
+++ b/misc/cgo/test/issue27054/test27054.go
@@ -0,0 +1,17 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package issue27054
+
+/*
+#include "egl.h"
+*/
+import "C"
+import (
+	"testing"
+)
+
+func Test27054(t *testing.T) {
+	var _ C.EGLDisplay = 0 // Note: 0, not nil. That makes sure we use uintptr for this type.
+}
diff --git a/misc/cgo/test/issue27340.go b/misc/cgo/test/issue27340.go
new file mode 100644
index 0000000..f8c8a87
--- /dev/null
+++ b/misc/cgo/test/issue27340.go
@@ -0,0 +1,12 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Failed to resolve typedefs consistently.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import "./issue27340"
+
+var issue27340Var = issue27340.Issue27340GoFunc
diff --git a/misc/cgo/test/issue27340/a.go b/misc/cgo/test/issue27340/a.go
new file mode 100644
index 0000000..f5b120c
--- /dev/null
+++ b/misc/cgo/test/issue27340/a.go
@@ -0,0 +1,42 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Failed to resolve typedefs consistently.
+// No runtime test; just make sure it compiles.
+// In separate directory to isolate #pragma GCC diagnostic.
+
+package issue27340
+
+// We use the #pragma to avoid a compiler warning about incompatible
+// pointer types, because we generate code passing a struct ptr rather
+// than using the typedef. This warning is expected and does not break
+// a normal build.
+// We can only disable -Wincompatible-pointer-types starting with GCC 5.
+
+// #if __GNU_MAJOR__ >= 5
+//
+// #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+//
+// typedef struct {
+// 	int a;
+// } issue27340Struct, *issue27340Ptr;
+//
+// static void issue27340CFunc(issue27340Ptr p) {}
+//
+// #else /* _GNU_MAJOR_ < 5 */
+//
+// typedef struct {
+// 	int a;
+// } issue27340Struct;
+//
+// static issue27340Struct* issue27340Ptr(issue27340Struct* p) { return p; }
+//
+// static void issue27340CFunc(issue27340Struct *p) {}
+// #endif /* _GNU_MAJOR_ < 5 */
+import "C"
+
+func Issue27340GoFunc() {
+	var s C.issue27340Struct
+	C.issue27340CFunc(C.issue27340Ptr(&s))
+}
diff --git a/misc/cgo/test/issue28545.go b/misc/cgo/test/issue28545.go
new file mode 100644
index 0000000..8419b89
--- /dev/null
+++ b/misc/cgo/test/issue28545.go
@@ -0,0 +1,26 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Failed to add type conversion for negative constant.
+// Issue 28772: Failed to add type conversion for Go constant set to C constant.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+/*
+#include <complex.h>
+
+#define issue28772Constant 1
+
+static void issue28545F(char **p, int n, complex double a) {}
+*/
+import "C"
+
+const issue28772Constant = C.issue28772Constant
+
+func issue28545G(p **C.char) {
+	C.issue28545F(p, -1, (0))
+	C.issue28545F(p, 2+3, complex(1, 1))
+	C.issue28545F(p, issue28772Constant, issue28772Constant2)
+}
diff --git a/misc/cgo/test/issue28772.go b/misc/cgo/test/issue28772.go
new file mode 100644
index 0000000..bed786b
--- /dev/null
+++ b/misc/cgo/test/issue28772.go
@@ -0,0 +1,12 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+// Constants didn't work if defined in different source file.
+
+// #define issue28772Constant2 2
+import "C"
+
+const issue28772Constant2 = C.issue28772Constant2
diff --git a/misc/cgo/test/issue28896.go b/misc/cgo/test/issue28896.go
new file mode 100644
index 0000000..8796040
--- /dev/null
+++ b/misc/cgo/test/issue28896.go
@@ -0,0 +1,83 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// cgo was incorrectly adding padding after a packed struct.
+
+package cgotest
+
+/*
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+typedef struct {
+	void *f1;
+	uint32_t f2;
+} __attribute__((__packed__)) innerPacked;
+
+typedef struct {
+	innerPacked g1;
+	uint64_t g2;
+} outerPacked;
+
+typedef struct {
+	void *f1;
+	uint32_t f2;
+} innerUnpacked;
+
+typedef struct {
+	innerUnpacked g1;
+	uint64_t g2;
+} outerUnpacked;
+
+size_t offset(int x) {
+	switch (x) {
+	case 0:
+		return offsetof(innerPacked, f2);
+	case 1:
+		return offsetof(outerPacked, g2);
+	case 2:
+		return offsetof(innerUnpacked, f2);
+	case 3:
+		return offsetof(outerUnpacked, g2);
+	default:
+		abort();
+	}
+}
+*/
+import "C"
+
+import (
+	"testing"
+	"unsafe"
+)
+
+func offset(i int) uintptr {
+	var pi C.innerPacked
+	var po C.outerPacked
+	var ui C.innerUnpacked
+	var uo C.outerUnpacked
+	switch i {
+	case 0:
+		return unsafe.Offsetof(pi.f2)
+	case 1:
+		return unsafe.Offsetof(po.g2)
+	case 2:
+		return unsafe.Offsetof(ui.f2)
+	case 3:
+		return unsafe.Offsetof(uo.g2)
+	default:
+		panic("can't happen")
+	}
+}
+
+func test28896(t *testing.T) {
+	for i := 0; i < 4; i++ {
+		c := uintptr(C.offset(C.int(i)))
+		g := offset(i)
+		if c != g {
+			t.Errorf("%d: C: %d != Go %d", i, c, g)
+		}
+	}
+}
diff --git a/misc/cgo/test/issue29383.go b/misc/cgo/test/issue29383.go
new file mode 100644
index 0000000..462c9a3
--- /dev/null
+++ b/misc/cgo/test/issue29383.go
@@ -0,0 +1,19 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// cgo's /*line*/ comments failed when inserted after '/',
+// because the result looked like a "//" comment.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+// #include <stddef.h>
+import "C"
+
+func Issue29383(n, size uint) int {
+	if ^C.size_t(0)/C.size_t(n) < C.size_t(size) {
+		return 0
+	}
+	return 0
+}
diff --git a/misc/cgo/test/issue29748.go b/misc/cgo/test/issue29748.go
new file mode 100644
index 0000000..8229b3b
--- /dev/null
+++ b/misc/cgo/test/issue29748.go
@@ -0,0 +1,22 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Error handling a struct initializer that requires pointer checking.
+// Compilation test only, nothing to run.
+
+package cgotest
+
+// typedef struct { char **p; } S29748;
+// static int f29748(S29748 *p) { return 0; }
+import "C"
+
+var Vissue29748 = C.f29748(&C.S29748{
+	nil,
+})
+
+func Fissue299748() {
+	C.f29748(&C.S29748{
+		nil,
+	})
+}
diff --git a/misc/cgo/test/issue29781.go b/misc/cgo/test/issue29781.go
new file mode 100644
index 0000000..0fd8c08
--- /dev/null
+++ b/misc/cgo/test/issue29781.go
@@ -0,0 +1,17 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Error with newline inserted into constant expression.
+// Compilation test only, nothing to run.
+
+package cgotest
+
+// static void issue29781F(char **p, int n) {}
+// #define ISSUE29781C 0
+import "C"
+
+func issue29781G() {
+	var p *C.char
+	C.issue29781F(&p, C.ISSUE29781C+1)
+}
diff --git a/misc/cgo/test/issue30065.go b/misc/cgo/test/issue30065.go
new file mode 100644
index 0000000..396d437
--- /dev/null
+++ b/misc/cgo/test/issue30065.go
@@ -0,0 +1,38 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Don't make a private copy of an array when taking the address of an
+// element.
+
+package cgotest
+
+// #include <string.h>
+import "C"
+
+import (
+	"testing"
+	"unsafe"
+)
+
+func test30065(t *testing.T) {
+	var a [256]byte
+	b := []byte("a")
+	C.memcpy(unsafe.Pointer(&a), unsafe.Pointer(&b[0]), 1)
+	if a[0] != 'a' {
+		t.Errorf("&a failed: got %c, want %c", a[0], 'a')
+	}
+
+	b = []byte("b")
+	C.memcpy(unsafe.Pointer(&a[0]), unsafe.Pointer(&b[0]), 1)
+	if a[0] != 'b' {
+		t.Errorf("&a[0] failed: got %c, want %c", a[0], 'b')
+	}
+
+	d := make([]byte, 256)
+	b = []byte("c")
+	C.memcpy(unsafe.Pointer(&d[0]), unsafe.Pointer(&b[0]), 1)
+	if d[0] != 'c' {
+		t.Errorf("&d[0] failed: got %c, want %c", d[0], 'c')
+	}
+}
diff --git a/misc/cgo/test/issue4339.go b/misc/cgo/test/issue4339.go
index 4fa4b2b..3715fde5 100644
--- a/misc/cgo/test/issue4339.go
+++ b/misc/cgo/test/issue4339.go
@@ -5,7 +5,8 @@
 package cgotest
 
 /*
-#include "issue4339.h"
+// We've historically permitted #include <>, so test it here.  Issue 29333.
+#include <issue4339.h>
 */
 import "C"
 
diff --git a/misc/cgo/test/issue9026/issue9026.go b/misc/cgo/test/issue9026/issue9026.go
index 0af86e6..149c265 100644
--- a/misc/cgo/test/issue9026/issue9026.go
+++ b/misc/cgo/test/issue9026/issue9026.go
@@ -29,7 +29,7 @@
 	// Brittle: the assertion may fail spuriously when the algorithm
 	// changes, but should remain stable otherwise.
 	got := fmt.Sprintf("%T %T", in, opts)
-	want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1"
+	want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___0"
 	if got != want {
 		t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
 	}
diff --git a/misc/cgo/test/issue9400_linux.go b/misc/cgo/test/issue9400_linux.go
index 34eb498..7719535 100644
--- a/misc/cgo/test/issue9400_linux.go
+++ b/misc/cgo/test/issue9400_linux.go
@@ -41,7 +41,7 @@
 
 	// Grow the stack and put down a test pattern
 	const pattern = 0x123456789abcdef
-	var big [1024]uint64 // len must match assmebly
+	var big [1024]uint64 // len must match assembly
 	for i := range big {
 		big[i] = pattern
 	}
diff --git a/misc/cgo/test/test27660.go b/misc/cgo/test/test27660.go
new file mode 100644
index 0000000..8c23b7d
--- /dev/null
+++ b/misc/cgo/test/test27660.go
@@ -0,0 +1,54 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Stress the interaction between the race detector and cgo in an
+// attempt to reproduce the memory corruption described in #27660.
+// The bug was very timing sensitive; at the time of writing this
+// test would only trigger the bug about once out of every five runs.
+
+package cgotest
+
+// #include <unistd.h>
+import "C"
+
+import (
+	"context"
+	"math/rand"
+	"runtime"
+	"sync"
+	"testing"
+	"time"
+)
+
+func test27660(t *testing.T) {
+	ctx, cancel := context.WithCancel(context.Background())
+	defer cancel()
+	ints := make([]int, 100)
+	locks := make([]sync.Mutex, 100)
+	// Slowly create threads so that ThreadSanitizer is forced to
+	// frequently resize its SyncClocks.
+	for i := 0; i < 100; i++ {
+		go func() {
+			for ctx.Err() == nil {
+				// Sleep in C for long enough that it is likely that the runtime
+				// will retake this goroutine's currently wired P.
+				C.usleep(1000 /* 1ms */)
+				runtime.Gosched() // avoid starvation (see #28701)
+			}
+		}()
+		go func() {
+			// Trigger lots of synchronization and memory reads/writes to
+			// increase the likelihood that the race described in #27660
+			// results in corruption of ThreadSanitizer's internal state
+			// and thus an assertion failure or segfault.
+			for ctx.Err() == nil {
+				j := rand.Intn(100)
+				locks[j].Lock()
+				ints[j]++
+				locks[j].Unlock()
+			}
+		}()
+		time.Sleep(time.Millisecond)
+	}
+}
diff --git a/misc/cgo/test/testdata/issue30527.go b/misc/cgo/test/testdata/issue30527.go
new file mode 100644
index 0000000..4ea7d31
--- /dev/null
+++ b/misc/cgo/test/testdata/issue30527.go
@@ -0,0 +1,14 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 30527: function call rewriting casts untyped
+// constants to int because of ":=" usage.
+
+package cgotest
+
+import "cgotest/issue30527"
+
+func issue30527G() {
+	issue30527.G(nil)
+}
diff --git a/misc/cgo/test/testdata/issue30527/a.go b/misc/cgo/test/testdata/issue30527/a.go
new file mode 100644
index 0000000..eb50147
--- /dev/null
+++ b/misc/cgo/test/testdata/issue30527/a.go
@@ -0,0 +1,19 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package issue30527
+
+import "math"
+
+/*
+#include <inttypes.h>
+
+static void issue30527F(char **p, uint64_t mod, uint32_t unused) {}
+*/
+import "C"
+
+func G(p **C.char) {
+	C.issue30527F(p, math.MaxUint64, 1)
+	C.issue30527F(p, 1<<64-1, Z)
+}
diff --git a/misc/cgo/test/testdata/issue30527/b.go b/misc/cgo/test/testdata/issue30527/b.go
new file mode 100644
index 0000000..87e8255
--- /dev/null
+++ b/misc/cgo/test/testdata/issue30527/b.go
@@ -0,0 +1,11 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package issue30527
+
+const (
+	X = 1 << iota
+	Y
+	Z
+)
diff --git a/misc/cgo/test/twoargs.go b/misc/cgo/test/twoargs.go
new file mode 100644
index 0000000..ca0534c
--- /dev/null
+++ b/misc/cgo/test/twoargs.go
@@ -0,0 +1,22 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Crash from call with two arguments that need pointer checking.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+/*
+static void twoargs1(void *p, int n) {}
+static void *twoargs2() { return 0; }
+static int twoargs3(void * p) { return 0; }
+*/
+import "C"
+
+import "unsafe"
+
+func twoargsF() {
+	v := []string{}
+	C.twoargs1(C.twoargs2(), C.twoargs3(unsafe.Pointer(&v)))
+}
diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go
index 7123230..457ac0d 100644
--- a/misc/cgo/testcarchive/carchive_test.go
+++ b/misc/cgo/testcarchive/carchive_test.go
@@ -14,6 +14,7 @@
 	"os/exec"
 	"path/filepath"
 	"regexp"
+	"runtime"
 	"strings"
 	"syscall"
 	"testing"
@@ -83,13 +84,17 @@
 		cc = append(cc, []string{"-framework", "CoreFoundation", "-framework", "Foundation"}...)
 	}
 	libgodir = GOOS + "_" + GOARCH
-	switch GOOS {
-	case "darwin":
-		if GOARCH == "arm" || GOARCH == "arm64" {
+	if runtime.Compiler == "gccgo" {
+		libgodir = "gccgo_" + libgodir + "_fPIC"
+	} else {
+		switch GOOS {
+		case "darwin":
+			if GOARCH == "arm" || GOARCH == "arm64" {
+				libgodir += "_shared"
+			}
+		case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
 			libgodir += "_shared"
 		}
-	case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
-		libgodir += "_shared"
 	}
 	cc = append(cc, "-I", filepath.Join("pkg", libgodir))
 
@@ -155,6 +160,9 @@
 	} else {
 		ccArgs = append(ccArgs, "main_unix.c", libgoa)
 	}
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	t.Log(ccArgs)
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
@@ -163,7 +171,11 @@
 	defer os.Remove(exe)
 
 	binArgs := append(cmdToRun(exe), "arg1", "arg2")
-	if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
+	cmd = exec.Command(binArgs[0], binArgs[1:]...)
+	if runtime.Compiler == "gccgo" {
+		cmd.Env = append(os.Environ(), "GCCGO=1")
+	}
+	if out, err := cmd.CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
 	}
@@ -194,8 +206,13 @@
 func TestInstall(t *testing.T) {
 	defer os.RemoveAll("pkg")
 
+	libgoa := "libgo.a"
+	if runtime.Compiler == "gccgo" {
+		libgoa = "liblibgo.a"
+	}
+
 	testInstall(t, "./testp1"+exeSuffix,
-		filepath.Join("pkg", libgodir, "libgo.a"),
+		filepath.Join("pkg", libgodir, libgoa),
 		filepath.Join("pkg", libgodir, "libgo.h"),
 		"go", "install", "-i", "-buildmode=c-archive", "libgo")
 
@@ -235,6 +252,9 @@
 	checkLineComments(t, "libgo2.h")
 
 	ccArgs := append(cc, "-o", "testp"+exeSuffix, "main2.c", "libgo2.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
@@ -265,6 +285,9 @@
 	checkLineComments(t, "libgo2.h")
 
 	ccArgs := append(cc, "-o", "testp"+exeSuffix, "main5.c", "libgo2.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
@@ -306,6 +329,9 @@
 	checkLineComments(t, "libgo2.h")
 
 	ccArgs := append(cc, "-o", "testp"+exeSuffix, "main5.c", "libgo2.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
@@ -419,6 +445,9 @@
 	checkLineComments(t, "libgo3.h")
 
 	ccArgs := append(cc, "-o", "testp"+exeSuffix, "main3.c", "libgo3.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
@@ -452,6 +481,9 @@
 	checkLineComments(t, "libgo4.h")
 
 	ccArgs := append(cc, "-o", "testp"+exeSuffix, "main4.c", "libgo4.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
@@ -476,6 +508,9 @@
 	case "windows":
 		t.Skip("skipping signal test on Windows")
 	}
+	if runtime.Compiler == "gccgo" {
+		t.Skip("skipping -extar test when using gccgo")
+	}
 
 	defer func() {
 		os.Remove("libgo4.a")
@@ -530,14 +565,26 @@
 		t.Fatal(err)
 	}
 
-	ccArgs := append(cc, "-fPIE", "-pie", "-o", "testp"+exeSuffix, "main.c", "main_unix.c", filepath.Join("pkg", libgodir, "libgo.a"))
+	libgoa := "libgo.a"
+	if runtime.Compiler == "gccgo" {
+		libgoa = "liblibgo.a"
+	}
+
+	ccArgs := append(cc, "-fPIE", "-pie", "-o", "testp"+exeSuffix, "main.c", "main_unix.c", filepath.Join("pkg", libgodir, libgoa))
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
 	}
 
 	binArgs := append(bin, "arg1", "arg2")
-	if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
+	cmd = exec.Command(binArgs[0], binArgs[1:]...)
+	if runtime.Compiler == "gccgo" {
+		cmd.Env = append(os.Environ(), "GCCGO=1")
+	}
+	if out, err := cmd.CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
 	}
@@ -605,6 +652,9 @@
 	checkLineComments(t, "libgo6.h")
 
 	ccArgs := append(cc, "-o", "testp6"+exeSuffix, "main6.c", "libgo6.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
 		t.Logf("%s", out)
 		t.Fatal(err)
@@ -648,6 +698,9 @@
 	// In some cases, -no-pie is needed here, but not accepted everywhere. First try
 	// if -no-pie is accepted. See #22126.
 	ccArgs := append(cc, "-o", exe, "-no-pie", "main5.c", "libgo2.a")
+	if runtime.Compiler == "gccgo" {
+		ccArgs = append(ccArgs, "-lgo")
+	}
 	t.Log(ccArgs)
 	out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
 
diff --git a/misc/cgo/testcarchive/main_unix.c b/misc/cgo/testcarchive/main_unix.c
index 4d9d16f..b23ac1c 100644
--- a/misc/cgo/testcarchive/main_unix.c
+++ b/misc/cgo/testcarchive/main_unix.c
@@ -5,6 +5,7 @@
 #include <signal.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 struct sigaction sa;
@@ -30,7 +31,12 @@
 		perror("sigaction");
 		return 2;
 	}
-	if (osa.sa_handler == SIG_DFL || (osa.sa_flags&SA_ONSTACK) == 0) {
+	if (osa.sa_handler == SIG_DFL) {
+		fprintf(stderr, "Go runtime did not install signal handler\n");
+		return 2;
+	}
+	// gccgo does not set SA_ONSTACK for SIGSEGV.
+	if (getenv("GCCGO") == "" && (osa.sa_flags&SA_ONSTACK) == 0) {
 		fprintf(stderr, "Go runtime did not install signal handler\n");
 		return 2;
 	}
diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go
index 89b19d6..e5b90ff 100644
--- a/misc/cgo/testcshared/cshared_test.go
+++ b/misc/cgo/testcshared/cshared_test.go
@@ -602,3 +602,55 @@
 		t.Fatal(err)
 	}
 }
+
+func TestGo2C2Go(t *testing.T) {
+	switch GOOS {
+	case "darwin":
+		// Darwin shared libraries don't support the multiple
+		// copies of the runtime package implied by this test.
+		t.Skip("linking c-shared into Go programs not supported on Darwin; issue 29061")
+	case "android":
+		t.Skip("test fails on android; issue 29087")
+	}
+
+	t.Parallel()
+
+	tmpdir, err := ioutil.TempDir("", "cshared-TestGo2C2Go")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer os.RemoveAll(tmpdir)
+
+	shlib := filepath.Join(tmpdir, "libtestgo2c2go."+libSuffix)
+	run(t, gopathEnv, "go", "build", "-buildmode=c-shared", "-o", shlib, "go2c2go/go")
+
+	cgoCflags := os.Getenv("CGO_CFLAGS")
+	if cgoCflags != "" {
+		cgoCflags += " "
+	}
+	cgoCflags += "-I" + tmpdir
+
+	cgoLdflags := os.Getenv("CGO_LDFLAGS")
+	if cgoLdflags != "" {
+		cgoLdflags += " "
+	}
+	cgoLdflags += "-L" + tmpdir + " -ltestgo2c2go"
+
+	goenv := append(gopathEnv[:len(gopathEnv):len(gopathEnv)], "CGO_CFLAGS="+cgoCflags, "CGO_LDFLAGS="+cgoLdflags)
+
+	ldLibPath := os.Getenv("LD_LIBRARY_PATH")
+	if ldLibPath != "" {
+		ldLibPath += ":"
+	}
+	ldLibPath += tmpdir
+
+	runenv := append(gopathEnv[:len(gopathEnv):len(gopathEnv)], "LD_LIBRARY_PATH="+ldLibPath)
+
+	bin := filepath.Join(tmpdir, "m1") + exeSuffix
+	run(t, goenv, "go", "build", "-o", bin, "go2c2go/m1")
+	runExe(t, runenv, bin)
+
+	bin = filepath.Join(tmpdir, "m2") + exeSuffix
+	run(t, goenv, "go", "build", "-o", bin, "go2c2go/m2")
+	runExe(t, runenv, bin)
+}
diff --git a/misc/cgo/testcshared/src/go2c2go/go/shlib.go b/misc/cgo/testcshared/src/go2c2go/go/shlib.go
new file mode 100644
index 0000000..76a5323
--- /dev/null
+++ b/misc/cgo/testcshared/src/go2c2go/go/shlib.go
@@ -0,0 +1,12 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "C"
+
+//export GoFunc
+func GoFunc() int { return 1 }
+
+func main() {}
diff --git a/misc/cgo/testcshared/src/go2c2go/m1/c.c b/misc/cgo/testcshared/src/go2c2go/m1/c.c
new file mode 100644
index 0000000..0e8fac4
--- /dev/null
+++ b/misc/cgo/testcshared/src/go2c2go/m1/c.c
@@ -0,0 +1,9 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "libtestgo2c2go.h"
+
+int CFunc(void) {
+	return (GoFunc() << 8) + 2;
+}
diff --git a/misc/cgo/testcshared/src/go2c2go/m1/main.go b/misc/cgo/testcshared/src/go2c2go/m1/main.go
new file mode 100644
index 0000000..17ba1eb
--- /dev/null
+++ b/misc/cgo/testcshared/src/go2c2go/m1/main.go
@@ -0,0 +1,22 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// extern int CFunc(void);
+import "C"
+
+import (
+	"fmt"
+	"os"
+)
+
+func main() {
+	got := C.CFunc()
+	const want = (1 << 8) | 2
+	if got != want {
+		fmt.Printf("got %#x, want %#x\n", got, want)
+		os.Exit(1)
+	}
+}
diff --git a/misc/cgo/testcshared/src/go2c2go/m2/main.go b/misc/cgo/testcshared/src/go2c2go/m2/main.go
new file mode 100644
index 0000000..91bf308
--- /dev/null
+++ b/misc/cgo/testcshared/src/go2c2go/m2/main.go
@@ -0,0 +1,22 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// #include "libtestgo2c2go.h"
+import "C"
+
+import (
+	"fmt"
+	"os"
+)
+
+func main() {
+	got := C.GoFunc()
+	const want = 1
+	if got != want {
+		fmt.Printf("got %#x, want %#x\n", got, want)
+		os.Exit(1)
+	}
+}
diff --git a/misc/cgo/testplugin/src/checkdwarf/main.go b/misc/cgo/testplugin/src/checkdwarf/main.go
new file mode 100644
index 0000000..7886c83
--- /dev/null
+++ b/misc/cgo/testplugin/src/checkdwarf/main.go
@@ -0,0 +1,106 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Usage:
+//
+//  checkdwarf <exe> <suffix>
+//
+// Opens <exe>, which must be an executable or a library and checks that
+// there is an entry in .debug_info whose name ends in <suffix>
+
+package main
+
+import (
+	"debug/dwarf"
+	"debug/elf"
+	"debug/macho"
+	"debug/pe"
+	"fmt"
+	"os"
+	"strings"
+)
+
+func usage() {
+	fmt.Fprintf(os.Stderr, "checkdwarf executable-or-library DIE-suffix\n")
+}
+
+type dwarfer interface {
+	DWARF() (*dwarf.Data, error)
+}
+
+func openElf(path string) dwarfer {
+	exe, err := elf.Open(path)
+	if err != nil {
+		return nil
+	}
+	return exe
+}
+
+func openMacho(path string) dwarfer {
+	exe, err := macho.Open(path)
+	if err != nil {
+		return nil
+	}
+	return exe
+}
+
+func openPE(path string) dwarfer {
+	exe, err := pe.Open(path)
+	if err != nil {
+		return nil
+	}
+	return exe
+}
+
+func main() {
+	if len(os.Args) != 3 {
+		usage()
+	}
+
+	exePath := os.Args[1]
+	dieSuffix := os.Args[2]
+
+	var exe dwarfer
+
+	for _, openfn := range []func(string) dwarfer{openMacho, openPE, openElf} {
+		exe = openfn(exePath)
+		if exe != nil {
+			break
+		}
+	}
+
+	if exe == nil {
+		fmt.Fprintf(os.Stderr, "could not open %s\n", exePath)
+		os.Exit(1)
+	}
+
+	data, err := exe.DWARF()
+	if err != nil {
+		fmt.Fprintf(os.Stderr, "%s: error opening DWARF: %v\n", exePath, err)
+		os.Exit(1)
+	}
+
+	rdr := data.Reader()
+	for {
+		e, err := rdr.Next()
+		if err != nil {
+			fmt.Fprintf(os.Stderr, "%s: error reading DWARF: %v\n", exePath, err)
+			os.Exit(1)
+		}
+		if e == nil {
+			break
+		}
+		name, hasname := e.Val(dwarf.AttrName).(string)
+		if !hasname {
+			continue
+		}
+		if strings.HasSuffix(name, dieSuffix) {
+			// found
+			os.Exit(0)
+		}
+	}
+
+	fmt.Fprintf(os.Stderr, "%s: no entry with a name ending in %q was found\n", exePath, dieSuffix)
+	os.Exit(1)
+}
diff --git a/misc/cgo/testplugin/test.bash b/misc/cgo/testplugin/test.bash
index bf8ed3c..1b94bc4 100755
--- a/misc/cgo/testplugin/test.bash
+++ b/misc/cgo/testplugin/test.bash
@@ -32,6 +32,14 @@
 GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -o=unnamed2.so unnamed2/main.go
 GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" host
 
+# test that DWARF sections are emitted for plugins and programs importing "plugin"
+if [ $GOOS != "darwin" ]; then
+	# On macOS, for some reason, the linker doesn't add debug sections to .so,
+	# see issue #27502.
+	go run src/checkdwarf/main.go plugin2.so plugin2.UnexportedNameReuse
+fi
+go run src/checkdwarf/main.go host main.main
+
 LD_LIBRARY_PATH=$(pwd) ./host
 
 # Test that types and itabs get properly uniqified.
diff --git a/misc/cgo/testplugin/unnamed1/main.go b/misc/cgo/testplugin/unnamed1/main.go
index 5c1df08..caf09c9 100644
--- a/misc/cgo/testplugin/unnamed1/main.go
+++ b/misc/cgo/testplugin/unnamed1/main.go
@@ -9,7 +9,7 @@
 
 func FuncInt() int { return 1 }
 
-// Add a recursive type to to check that type equality across plugins doesn't
+// Add a recursive type to check that type equality across plugins doesn't
 // crash. See https://golang.org/issues/19258
 func FuncRecursive() X { return X{} }
 
diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go
index f09ad52..218e225 100644
--- a/misc/cgo/testsanitizers/cc_test.go
+++ b/misc/cgo/testsanitizers/cc_test.go
@@ -374,7 +374,7 @@
 	}
 
 	// libcgo.h sets CGO_TSAN if it detects TSAN support in the C compiler.
-	// Dump the preprocessor defines to check that that works.
+	// Dump the preprocessor defines to check that works.
 	// (Sometimes it doesn't: see https://golang.org/issue/15983.)
 	cmd, err := cc(c.cFlags...)
 	if err != nil {
diff --git a/misc/cgo/testsanitizers/tsan_test.go b/misc/cgo/testsanitizers/tsan_test.go
index 314b507..1d769a9 100644
--- a/misc/cgo/testsanitizers/tsan_test.go
+++ b/misc/cgo/testsanitizers/tsan_test.go
@@ -5,9 +5,9 @@
 package sanitizers_test
 
 import (
+	"runtime"
 	"strings"
 	"testing"
-	"runtime"
 )
 
 func TestTSAN(t *testing.T) {
diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go
index 846a271..41a24ef 100644
--- a/misc/cgo/testshared/shared_test.go
+++ b/misc/cgo/testshared/shared_test.go
@@ -560,7 +560,7 @@
 			abiHashNoteFound = true
 		case 3: // ELF_NOTE_GODEPS_TAG
 			if depsNoteFound {
-				t.Error("multiple depedency list notes")
+				t.Error("multiple dependency list notes")
 			}
 			testDepsNote(t, f, note)
 			depsNoteFound = true
@@ -578,7 +578,7 @@
 }
 
 // Build a GOPATH package (depBase) into a shared library that links against the goroot
-// runtime, another package (dep2) that links against the first, and and an
+// runtime, another package (dep2) that links against the first, and an
 // executable that links against dep2.
 func TestTwoGopathShlibs(t *testing.T) {
 	goCmd(t, "install", "-buildmode=shared", "-linkshared", "depBase")
@@ -911,3 +911,9 @@
 func TestTestInstalledShared(t *testing.T) {
 	goCmd(nil, "test", "-linkshared", "-test.short", "sync/atomic")
 }
+
+// Test generated pointer method with -linkshared.
+// Issue 25065.
+func TestGeneratedMethod(t *testing.T) {
+	goCmd(t, "install", "-buildmode=shared", "-linkshared", "issue25065")
+}
diff --git a/misc/cgo/testshared/src/issue25065/a.go b/misc/cgo/testshared/src/issue25065/a.go
new file mode 100644
index 0000000..979350f
--- /dev/null
+++ b/misc/cgo/testshared/src/issue25065/a.go
@@ -0,0 +1,20 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package issue25065 has a type with a method that is
+//  1) referenced in a method expression
+//  2) not called
+//  3) not converted to an interface
+//  4) is a value method but the reference is to the pointer method
+// These cases avoid the call to makefuncsym from typecheckfunc, but we
+// still need to call makefuncsym somehow or the symbol will not be defined.
+package issue25065
+
+type T int
+
+func (t T) M() {}
+
+func F() func(*T) {
+	return (*T).M
+}
diff --git a/misc/ios/detect.go b/misc/ios/detect.go
index 2594185..1d47e47 100644
--- a/misc/ios/detect.go
+++ b/misc/ios/detect.go
@@ -33,9 +33,9 @@
 		fail("did not find mobile provision matching device udids %q", udids)
 	}
 
-	fmt.Println("Available provisioning profiles below.")
-	fmt.Println("NOTE: Any existing app on the device with the app id specified by GOIOS_APP_ID")
-	fmt.Println("will be overwritten when running Go programs.")
+	fmt.Println("# Available provisioning profiles below.")
+	fmt.Println("# NOTE: Any existing app on the device with the app id specified by GOIOS_APP_ID")
+	fmt.Println("# will be overwritten when running Go programs.")
 	for _, mp := range mps {
 		fmt.Println()
 		f, err := ioutil.TempFile("", "go_ios_detect_")
diff --git a/misc/nacl/README b/misc/nacl/README
index 99b94dc..179e526 100644
--- a/misc/nacl/README
+++ b/misc/nacl/README
@@ -26,7 +26,7 @@
 # Download NaCl
 
 Download nacl_sdk.zip file from
-	https://developers.google.com/native-client/dev/sdk/download
+	https://developer.chrome.com/native-client/sdk/download
 and unpack it. I chose /opt/nacl_sdk.
 
 # Update
@@ -37,7 +37,7 @@
 	% cd /opt/nacl_sdk
 	% ./naclsdk update
 
-At this time pepper_40 is the stable version. The NaCl port needs at least pepper_39
+At this time pepper_49 is the stable version. The NaCl port needs at least pepper_39
 to work. If naclsdk downloads a later version, please adjust accordingly.
 
 The cmd/go helper scripts expect that the loaders sel_ldr_{x86_{32,64},arm} and
diff --git a/misc/nacl/testzip.proto b/misc/nacl/testzip.proto
index f15a2ab..d052193 100644
--- a/misc/nacl/testzip.proto
+++ b/misc/nacl/testzip.proto
@@ -47,6 +47,9 @@
 					google
 						pprof
 							internal
+								binutils
+									testdata
+										+
 								driver
 									testdata
 										+
@@ -151,6 +154,9 @@
 			trace
 				testdata
 					+
+			xcoff
+				testdata
+					+
 		io
 			+
 		mime
@@ -177,6 +183,8 @@
 		strconv
 			testdata
 				+
+		testdata
+			+
 		text
 			template
 				testdata
diff --git a/misc/sortac/sortac.go b/misc/sortac/sortac.go
deleted file mode 100644
index f61aa96..0000000
--- a/misc/sortac/sortac.go
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Sortac sorts the AUTHORS and CONTRIBUTORS files.
-//
-// Usage:
-//
-//    sortac [file...]
-//
-// Sortac sorts the named files in place.
-// If given no arguments, it sorts standard input to standard output.
-package main
-
-import (
-	"bufio"
-	"bytes"
-	"flag"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"log"
-	"os"
-
-	"golang.org/x/text/collate"
-	"golang.org/x/text/language"
-)
-
-func main() {
-	log.SetFlags(0)
-	log.SetPrefix("sortac: ")
-	flag.Parse()
-
-	args := flag.Args()
-	if len(args) == 0 {
-		os.Stdout.Write(sortAC(os.Stdin))
-	} else {
-		for _, arg := range args {
-			f, err := os.Open(arg)
-			if err != nil {
-				log.Fatal(err)
-			}
-			sorted := sortAC(f)
-			f.Close()
-			if err := ioutil.WriteFile(arg, sorted, 0644); err != nil {
-				log.Fatal(err)
-			}
-		}
-	}
-}
-
-func sortAC(r io.Reader) []byte {
-	bs := bufio.NewScanner(r)
-	var header []string
-	var lines []string
-	for bs.Scan() {
-		t := bs.Text()
-		lines = append(lines, t)
-		if t == "# Please keep the list sorted." {
-			header = lines
-			lines = nil
-			continue
-		}
-	}
-	if err := bs.Err(); err != nil {
-		log.Fatal(err)
-	}
-
-	var out bytes.Buffer
-	c := collate.New(language.Und, collate.Loose)
-	c.SortStrings(lines)
-	for _, l := range header {
-		fmt.Fprintln(&out, l)
-	}
-	for _, l := range lines {
-		fmt.Fprintln(&out, l)
-	}
-	return out.Bytes()
-}
diff --git a/misc/wasm/wasm_exec.html b/misc/wasm/wasm_exec.html
index cc37ea7..72e6447 100644
--- a/misc/wasm/wasm_exec.html
+++ b/misc/wasm/wasm_exec.html
@@ -12,6 +12,11 @@
 </head>
 
 <body>
+	<!--
+	Add the following polyfill for Microsoft Edge 17/18 support:
+	<script src="https://cdn.jsdelivr.net/npm/text-encoding@0.7.0/lib/encoding.min.js"></script>
+	(see https://caniuse.com/#feat=textencoder)
+	-->
 	<script src="wasm_exec.js"></script>
 	<script>
 		if (!WebAssembly.instantiateStreaming) { // polyfill
@@ -27,6 +32,8 @@
 			mod = result.module;
 			inst = result.instance;
 			document.getElementById("runButton").disabled = false;
+		}).catch((err) => {
+			console.error(err);
 		});
 
 		async function run() {
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index 94b9552..165d567 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -3,8 +3,18 @@
 // license that can be found in the LICENSE file.
 
 (() => {
+	if (typeof global !== "undefined") {
+		// global already exists
+	} else if (typeof window !== "undefined") {
+		window.global = window;
+	} else if (typeof self !== "undefined") {
+		self.global = self;
+	} else {
+		throw new Error("cannot export Go (neither global, window nor self is defined)");
+	}
+
 	// Map web browser API and Node.js API to a single common API (preferring web standards over Node.js API).
-	const isNodeJS = typeof process !== "undefined";
+	const isNodeJS = global.process && global.process.title === "node";
 	if (isNodeJS) {
 		global.require = require;
 		global.fs = require("fs");
@@ -27,14 +37,6 @@
 		global.TextEncoder = util.TextEncoder;
 		global.TextDecoder = util.TextDecoder;
 	} else {
-		if (typeof window !== "undefined") {
-			window.global = window;
-		} else if (typeof self !== "undefined") {
-			self.global = self;
-		} else {
-			throw new Error("cannot export Go (neither window nor self is defined)");
-		}
-
 		let outputBuf = "";
 		global.fs = {
 			constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
@@ -47,10 +49,25 @@
 				}
 				return buf.length;
 			},
-			openSync(path, flags, mode) {
+			write(fd, buf, offset, length, position, callback) {
+				if (offset !== 0 || length !== buf.length || position !== null) {
+					throw new Error("not implemented");
+				}
+				const n = this.writeSync(fd, buf);
+				callback(null, n);
+			},
+			open(path, flags, mode, callback) {
 				const err = new Error("not implemented");
 				err.code = "ENOSYS";
-				throw err;
+				callback(err);
+			},
+			read(fd, buffer, offset, length, position, callback) {
+				const err = new Error("not implemented");
+				err.code = "ENOSYS";
+				callback(err);
+			},
+			fsync(fd, callback) {
+				callback(null);
 			},
 		};
 	}
@@ -67,7 +84,11 @@
 					console.warn("exit code:", code);
 				}
 			};
-			this._callbackTimeouts = new Map();
+			this._exitPromise = new Promise((resolve) => {
+				this._resolveExitPromise = resolve;
+			});
+			this._pendingEvent = null;
+			this._scheduledTimeouts = new Map();
 			this._nextCallbackTimeoutID = 1;
 
 			const mem = () => {
@@ -88,6 +109,9 @@
 
 			const loadValue = (addr) => {
 				const f = mem().getFloat64(addr, true);
+				if (f === 0) {
+					return undefined;
+				}
 				if (!isNaN(f)) {
 					return f;
 				}
@@ -105,14 +129,18 @@
 						mem().setUint32(addr, 0, true);
 						return;
 					}
+					if (v === 0) {
+						mem().setUint32(addr + 4, nanHead, true);
+						mem().setUint32(addr, 1, true);
+						return;
+					}
 					mem().setFloat64(addr, v, true);
 					return;
 				}
 
 				switch (v) {
 					case undefined:
-						mem().setUint32(addr + 4, nanHead, true);
-						mem().setUint32(addr, 1, true);
+						mem().setFloat64(addr, 0, true);
 						return;
 					case null:
 						mem().setUint32(addr + 4, nanHead, true);
@@ -175,6 +203,11 @@
 			const timeOrigin = Date.now() - performance.now();
 			this.importObject = {
 				go: {
+					// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
+					// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
+					// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
+					// This changes the SP, thus we have to update the SP used by the imported function.
+
 					// func wasmExit(code int32)
 					"runtime.wasmExit": (sp) => {
 						const code = mem().getInt32(sp + 8, true);
@@ -205,22 +238,22 @@
 						mem().setInt32(sp + 16, (msec % 1000) * 1000000, true);
 					},
 
-					// func scheduleCallback(delay int64) int32
-					"runtime.scheduleCallback": (sp) => {
+					// func scheduleTimeoutEvent(delay int64) int32
+					"runtime.scheduleTimeoutEvent": (sp) => {
 						const id = this._nextCallbackTimeoutID;
 						this._nextCallbackTimeoutID++;
-						this._callbackTimeouts.set(id, setTimeout(
-							() => { this._resolveCallbackPromise(); },
+						this._scheduledTimeouts.set(id, setTimeout(
+							() => { this._resume(); },
 							getInt64(sp + 8) + 1, // setTimeout has been seen to fire up to 1 millisecond early
 						));
 						mem().setInt32(sp + 16, id, true);
 					},
 
-					// func clearScheduledCallback(id int32)
-					"runtime.clearScheduledCallback": (sp) => {
+					// func clearTimeoutEvent(id int32)
+					"runtime.clearTimeoutEvent": (sp) => {
 						const id = mem().getInt32(sp + 8, true);
-						clearTimeout(this._callbackTimeouts.get(id));
-						this._callbackTimeouts.delete(id);
+						clearTimeout(this._scheduledTimeouts.get(id));
+						this._scheduledTimeouts.delete(id);
 					},
 
 					// func getRandomData(r []byte)
@@ -235,7 +268,9 @@
 
 					// func valueGet(v ref, p string) ref
 					"syscall/js.valueGet": (sp) => {
-						storeValue(sp + 32, Reflect.get(loadValue(sp + 8), loadString(sp + 16)));
+						const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
+						sp = this._inst.exports.getsp(); // see comment above
+						storeValue(sp + 32, result);
 					},
 
 					// func valueSet(v ref, p string, x ref)
@@ -259,7 +294,9 @@
 							const v = loadValue(sp + 8);
 							const m = Reflect.get(v, loadString(sp + 16));
 							const args = loadSliceOfValues(sp + 32);
-							storeValue(sp + 56, Reflect.apply(m, v, args));
+							const result = Reflect.apply(m, v, args);
+							sp = this._inst.exports.getsp(); // see comment above
+							storeValue(sp + 56, result);
 							mem().setUint8(sp + 64, 1);
 						} catch (err) {
 							storeValue(sp + 56, err);
@@ -272,7 +309,9 @@
 						try {
 							const v = loadValue(sp + 8);
 							const args = loadSliceOfValues(sp + 16);
-							storeValue(sp + 40, Reflect.apply(v, undefined, args));
+							const result = Reflect.apply(v, undefined, args);
+							sp = this._inst.exports.getsp(); // see comment above
+							storeValue(sp + 40, result);
 							mem().setUint8(sp + 48, 1);
 						} catch (err) {
 							storeValue(sp + 40, err);
@@ -285,7 +324,9 @@
 						try {
 							const v = loadValue(sp + 8);
 							const args = loadSliceOfValues(sp + 16);
-							storeValue(sp + 40, Reflect.construct(v, args));
+							const result = Reflect.construct(v, args);
+							sp = this._inst.exports.getsp(); // see comment above
+							storeValue(sp + 40, result);
 							mem().setUint8(sp + 48, 1);
 						} catch (err) {
 							storeValue(sp + 40, err);
@@ -327,7 +368,7 @@
 			this._inst = instance;
 			this._values = [ // TODO: garbage collection
 				NaN,
-				undefined,
+				0,
 				null,
 				true,
 				false,
@@ -336,7 +377,6 @@
 				this,
 			];
 			this._refs = new Map();
-			this._callbackShutdown = false;
 			this.exited = false;
 
 			const mem = new DataView(this._inst.exports.mem.buffer)
@@ -371,42 +411,30 @@
 				offset += 8;
 			});
 
-			while (true) {
-				const callbackPromise = new Promise((resolve) => {
-					this._resolveCallbackPromise = () => {
-						if (this.exited) {
-							throw new Error("bad callback: Go program has already exited");
-						}
-						setTimeout(resolve, 0); // make sure it is asynchronous
-					};
-				});
-				this._inst.exports.run(argc, argv);
-				if (this.exited) {
-					break;
-				}
-				await callbackPromise;
+			this._inst.exports.run(argc, argv);
+			if (this.exited) {
+				this._resolveExitPromise();
+			}
+			await this._exitPromise;
+		}
+
+		_resume() {
+			if (this.exited) {
+				throw new Error("Go program has already exited");
+			}
+			this._inst.exports.resume();
+			if (this.exited) {
+				this._resolveExitPromise();
 			}
 		}
 
-		static _makeCallbackHelper(id, pendingCallbacks, go) {
-			return function() {
-				pendingCallbacks.push({ id: id, args: arguments });
-				go._resolveCallbackPromise();
-			};
-		}
-
-		static _makeEventCallbackHelper(preventDefault, stopPropagation, stopImmediatePropagation, fn) {
-			return function(event) {
-				if (preventDefault) {
-					event.preventDefault();
-				}
-				if (stopPropagation) {
-					event.stopPropagation();
-				}
-				if (stopImmediatePropagation) {
-					event.stopImmediatePropagation();
-				}
-				fn(event);
+		_makeFuncWrapper(id) {
+			const go = this;
+			return function () {
+				const event = { id: id, this: this, args: arguments };
+				go._pendingEvent = event;
+				go._resume();
+				return event.result;
 			};
 		}
 	}
@@ -419,14 +447,14 @@
 
 		const go = new Go();
 		go.argv = process.argv.slice(2);
-		go.env = process.env;
+		go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
 		go.exit = process.exit;
 		WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
-			process.on("exit", (code) => { // Node.js exits if no callback is pending
+			process.on("exit", (code) => { // Node.js exits if no event handler is pending
 				if (code === 0 && !go.exited) {
 					// deadlock, make Go print error and stack traces
-					go._callbackShutdown = true;
-					go._inst.exports.run();
+					go._pendingEvent = { id: 0 };
+					go._resume();
 				}
 			});
 			return go.run(result.instance);
diff --git a/src/archive/tar/format.go b/src/archive/tar/format.go
index 1f89d0c..cfe24a5 100644
--- a/src/archive/tar/format.go
+++ b/src/archive/tar/format.go
@@ -160,7 +160,7 @@
 func (b *block) GNU() *headerGNU     { return (*headerGNU)(b) }
 func (b *block) STAR() *headerSTAR   { return (*headerSTAR)(b) }
 func (b *block) USTAR() *headerUSTAR { return (*headerUSTAR)(b) }
-func (b *block) Sparse() sparseArray { return (sparseArray)(b[:]) }
+func (b *block) Sparse() sparseArray { return sparseArray(b[:]) }
 
 // GetFormat checks that the block is a valid tar header based on the checksum.
 // It then attempts to guess the specific format based on magic values.
@@ -263,7 +263,7 @@
 func (h *headerGNU) DevMinor() []byte    { return h[337:][:8] }
 func (h *headerGNU) AccessTime() []byte  { return h[345:][:12] }
 func (h *headerGNU) ChangeTime() []byte  { return h[357:][:12] }
-func (h *headerGNU) Sparse() sparseArray { return (sparseArray)(h[386:][:24*4+1]) }
+func (h *headerGNU) Sparse() sparseArray { return sparseArray(h[386:][:24*4+1]) }
 func (h *headerGNU) RealSize() []byte    { return h[483:][:12] }
 
 type headerSTAR [blockSize]byte
@@ -293,7 +293,7 @@
 
 type sparseArray []byte
 
-func (s sparseArray) Entry(i int) sparseElem { return (sparseElem)(s[i*24:]) }
+func (s sparseArray) Entry(i int) sparseElem { return sparseElem(s[i*24:]) }
 func (s sparseArray) IsExtended() []byte     { return s[24*s.MaxEntries():][:1] }
 func (s sparseArray) MaxEntries() int        { return len(s) / 24 }
 
diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go
index 2444106..2260b39 100644
--- a/src/archive/zip/reader.go
+++ b/src/archive/zip/reader.go
@@ -69,6 +69,9 @@
 // NewReader returns a new Reader reading from r, which is assumed to
 // have the given size in bytes.
 func NewReader(r io.ReaderAt, size int64) (*Reader, error) {
+	if size < 0 {
+		return nil, errors.New("zip: size cannot be negative")
+	}
 	zr := new(Reader)
 	if err := zr.init(r, size); err != nil {
 		return nil, err
diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
index 1e58b26..6b3f2f3 100644
--- a/src/archive/zip/reader_test.go
+++ b/src/archive/zip/reader_test.go
@@ -658,6 +658,12 @@
 	if err != ErrFormat {
 		t.Errorf("sigs: error=%v, want %v", err, ErrFormat)
 	}
+
+	// negative size
+	_, err = NewReader(bytes.NewReader([]byte("foobar")), -1)
+	if err == nil {
+		t.Errorf("archive/zip.NewReader: expected error when negative size is passed")
+	}
 }
 
 func messWith(fileName string, corrupter func(b []byte)) (r io.ReaderAt, size int64) {
diff --git a/src/archive/zip/struct.go b/src/archive/zip/struct.go
index c90151d..bd637d1 100644
--- a/src/archive/zip/struct.go
+++ b/src/archive/zip/struct.go
@@ -303,8 +303,8 @@
 }
 
 // isZip64 reports whether the file size exceeds the 32 bit limit
-func (fh *FileHeader) isZip64() bool {
-	return fh.CompressedSize64 >= uint32max || fh.UncompressedSize64 >= uint32max
+func (h *FileHeader) isZip64() bool {
+	return h.CompressedSize64 >= uint32max || h.UncompressedSize64 >= uint32max
 }
 
 func msdosModeToFileMode(m uint32) (mode os.FileMode) {
diff --git a/src/archive/zip/writer.go b/src/archive/zip/writer.go
index 5f0c0a1..cdc534e 100644
--- a/src/archive/zip/writer.go
+++ b/src/archive/zip/writer.go
@@ -178,7 +178,7 @@
 			return err
 		}
 
-		// store max values in the regular end record to signal that
+		// store max values in the regular end record to signal
 		// that the zip64 values should be used instead
 		records = uint16max
 		size = uint32max
diff --git a/src/archive/zip/zip_test.go b/src/archive/zip/zip_test.go
index 50218a2..3d5c759 100644
--- a/src/archive/zip/zip_test.go
+++ b/src/archive/zip/zip_test.go
@@ -159,7 +159,7 @@
 	return len(p), nil
 }
 
-func min(x, y int) int {
+func min(x, y int64) int64 {
 	if x < y {
 		return x
 	}
@@ -190,7 +190,7 @@
 	if len(parts) > 0 {
 		skipBytes := off - parts[0].off
 		for _, part := range parts {
-			repeat := min(int(part.n-skipBytes), len(p)-n)
+			repeat := int(min(part.n-skipBytes, int64(len(p)-n)))
 			memset(p[n:n+repeat], part.b)
 			n += repeat
 			if n == len(p) {
diff --git a/src/bufio/bufio.go b/src/bufio/bufio.go
index 72545a7..0125d72 100644
--- a/src/bufio/bufio.go
+++ b/src/bufio/bufio.go
@@ -33,8 +33,8 @@
 	rd           io.Reader // reader provided by the client
 	r, w         int       // buf read and write positions
 	err          error
-	lastByte     int
-	lastRuneSize int
+	lastByte     int // last byte read for UnreadByte; -1 means invalid
+	lastRuneSize int // size of last rune read for UnreadRune; -1 means invalid
 }
 
 const minReadBufferSize = 16
@@ -63,7 +63,7 @@
 }
 
 // Size returns the size of the underlying buffer in bytes.
-func (r *Reader) Size() int { return len(r.buf) }
+func (b *Reader) Size() int { return len(b.buf) }
 
 // Reset discards any buffered data, resets all state, and switches
 // the buffered reader to read from r.
@@ -123,11 +123,17 @@
 // being valid at the next read call. If Peek returns fewer than n bytes, it
 // also returns an error explaining why the read is short. The error is
 // ErrBufferFull if n is larger than b's buffer size.
+//
+// Calling Peek prevents a UnreadByte or UnreadRune call from succeeding
+// until the next read operation.
 func (b *Reader) Peek(n int) ([]byte, error) {
 	if n < 0 {
 		return nil, ErrNegativeCount
 	}
 
+	b.lastByte = -1
+	b.lastRuneSize = -1
+
 	for b.w-b.r < n && b.w-b.r < len(b.buf) && b.err == nil {
 		b.fill() // b.w-b.r < len(b.buf) => buffer is not full
 	}
@@ -186,6 +192,7 @@
 // It returns the number of bytes read into p.
 // The bytes are taken from at most one Read on the underlying Reader,
 // hence n may be less than len(p).
+// To read exactly len(p) bytes, use io.ReadFull(b, p).
 // At EOF, the count will be zero and err will be io.EOF.
 func (b *Reader) Read(p []byte) (n int, err error) {
 	n = len(p)
@@ -248,6 +255,10 @@
 }
 
 // UnreadByte unreads the last byte. Only the most recently read byte can be unread.
+//
+// UnreadByte returns an error if the most recent method called on the
+// Reader was not a read operation. Notably, Peek is not considered a
+// read operation.
 func (b *Reader) UnreadByte() error {
 	if b.lastByte < 0 || b.r == 0 && b.w > 0 {
 		return ErrInvalidUnreadByte
@@ -286,8 +297,8 @@
 	return r, size, nil
 }
 
-// UnreadRune unreads the last rune. If the most recent read operation on
-// the buffer was not a ReadRune, UnreadRune returns an error.  (In this
+// UnreadRune unreads the last rune. If the most recent method called on
+// the Reader was not a ReadRune, UnreadRune returns an error. (In this
 // regard it is stricter than UnreadByte, which will unread the last byte
 // from any read operation.)
 func (b *Reader) UnreadRune() error {
@@ -314,9 +325,11 @@
 // ReadBytes or ReadString instead.
 // ReadSlice returns err != nil if and only if line does not end in delim.
 func (b *Reader) ReadSlice(delim byte) (line []byte, err error) {
+	s := 0 // search start index
 	for {
 		// Search buffer.
-		if i := bytes.IndexByte(b.buf[b.r:b.w], delim); i >= 0 {
+		if i := bytes.IndexByte(b.buf[b.r+s:b.w], delim); i >= 0 {
+			i += s
 			line = b.buf[b.r : b.r+i+1]
 			b.r += i + 1
 			break
@@ -338,6 +351,8 @@
 			break
 		}
 
+		s = b.w - b.r // do not rescan area we scanned before
+
 		b.fill() // buffer is not full
 	}
 
diff --git a/src/bufio/bufio_test.go b/src/bufio/bufio_test.go
index c829d2b..f7a0682 100644
--- a/src/bufio/bufio_test.go
+++ b/src/bufio/bufio_test.go
@@ -285,6 +285,24 @@
 	}
 }
 
+func TestNoUnreadRuneAfterPeek(t *testing.T) {
+	br := NewReader(strings.NewReader("example"))
+	br.ReadRune()
+	br.Peek(1)
+	if err := br.UnreadRune(); err == nil {
+		t.Error("UnreadRune didn't fail after Peek")
+	}
+}
+
+func TestNoUnreadByteAfterPeek(t *testing.T) {
+	br := NewReader(strings.NewReader("example"))
+	br.ReadByte()
+	br.Peek(1)
+	if err := br.UnreadByte(); err == nil {
+		t.Error("UnreadByte didn't fail after Peek")
+	}
+}
+
 func TestUnreadByte(t *testing.T) {
 	segments := []string{"Hello, ", "world"}
 	r := NewReader(&StringReader{data: segments})
@@ -550,7 +568,7 @@
 				t.Errorf("%s: %d bytes written", context, len(written))
 			}
 			for l := 0; l < len(written); l++ {
-				if written[i] != data[i] {
+				if written[l] != data[l] {
 					t.Errorf("wrong bytes written")
 					t.Errorf("want=%q", data[0:len(written)])
 					t.Errorf("have=%q", written)
diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go
index 4578c85..c78fe09 100644
--- a/src/builtin/builtin.go
+++ b/src/builtin/builtin.go
@@ -152,6 +152,9 @@
 //	String: the number of bytes in v.
 //	Channel: the number of elements queued (unread) in the channel buffer;
 //	if v is nil, len(v) is zero.
+// For some arguments, such as a string literal or a simple array expression, the
+// result can be a constant. See the Go language specification's "Length and
+// capacity" section for details.
 func len(v Type) int
 
 // The cap built-in function returns the capacity of v, according to its type:
@@ -161,6 +164,9 @@
 //	if v is nil, cap(v) is zero.
 //	Channel: the channel buffer capacity, in units of elements;
 //	if v is nil, cap(v) is zero.
+// For some arguments, such as a simple array expression, the result can be a
+// constant. See the Go language specification's "Length and capacity" section for
+// details.
 func cap(v Type) int
 
 // The make built-in function allocates and initializes an object of type
diff --git a/src/bytes/buffer.go b/src/bytes/buffer.go
index a2eca2e..aff2db5 100644
--- a/src/bytes/buffer.go
+++ b/src/bytes/buffer.go
@@ -12,13 +12,15 @@
 	"unicode/utf8"
 )
 
+// smallBufferSize is an initial allocation minimal capacity.
+const smallBufferSize = 64
+
 // A Buffer is a variable-sized buffer of bytes with Read and Write methods.
 // The zero value for Buffer is an empty buffer ready to use.
 type Buffer struct {
-	buf       []byte   // contents are the bytes buf[off : len(buf)]
-	off       int      // read at &buf[off], write at &buf[len(buf)]
-	bootstrap [64]byte // memory to hold first slice; helps small buffers avoid allocation.
-	lastRead  readOp   // last read operation, so that Unread* can work correctly.
+	buf      []byte // contents are the bytes buf[off : len(buf)]
+	off      int    // read at &buf[off], write at &buf[len(buf)]
+	lastRead readOp // last read operation, so that Unread* can work correctly.
 
 	// FIXME: it would be advisable to align Buffer to cachelines to avoid false
 	// sharing.
@@ -66,7 +68,7 @@
 	return string(b.buf[b.off:])
 }
 
-// empty returns whether the unread portion of the buffer is empty.
+// empty reports whether the unread portion of the buffer is empty.
 func (b *Buffer) empty() bool { return len(b.buf) <= b.off }
 
 // Len returns the number of bytes of the unread portion of the buffer;
@@ -125,9 +127,8 @@
 	if i, ok := b.tryGrowByReslice(n); ok {
 		return i
 	}
-	// Check if we can make use of bootstrap array.
-	if b.buf == nil && n <= len(b.bootstrap) {
-		b.buf = b.bootstrap[:n]
+	if b.buf == nil && n <= smallBufferSize {
+		b.buf = make([]byte, n, smallBufferSize)
 		return 0
 	}
 	c := cap(b.buf)
@@ -441,9 +442,9 @@
 // NewBuffer creates and initializes a new Buffer using buf as its
 // initial contents. The new Buffer takes ownership of buf, and the
 // caller should not use buf after this call. NewBuffer is intended to
-// prepare a Buffer to read existing data. It can also be used to size
-// the internal buffer for writing. To do that, buf should have the
-// desired capacity but a length of zero.
+// prepare a Buffer to read existing data. It can also be used to set
+// the initial size of the internal buffer for writing. To do that,
+// buf should have the desired capacity but a length of zero.
 //
 // In most cases, new(Buffer) (or just declaring a Buffer variable) is
 // sufficient to initialize a Buffer.
diff --git a/src/bytes/buffer_test.go b/src/bytes/buffer_test.go
index acbe5ca..6e9d695 100644
--- a/src/bytes/buffer_test.go
+++ b/src/bytes/buffer_test.go
@@ -293,7 +293,7 @@
 	}
 	check(t, "TestReadFromPanicReader (1)", &buf, "")
 
-	// Confirm that when Reader panics, the emtpy buffer remains empty
+	// Confirm that when Reader panics, the empty buffer remains empty
 	var buf2 Buffer
 	defer func() {
 		recover()
diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go
index 437a6e1..daf4a32 100644
--- a/src/bytes/bytes.go
+++ b/src/bytes/bytes.go
@@ -12,6 +12,13 @@
 	"unicode/utf8"
 )
 
+// Equal returns a boolean reporting whether a and b
+// are the same length and contain the same bytes.
+// A nil argument is equivalent to an empty slice.
+func Equal(a, b []byte) bool {
+	return bytealg.Equal(a, b)
+}
+
 func equalPortable(a, b []byte) bool {
 	if len(a) != len(b) {
 		return false
@@ -24,6 +31,13 @@
 	return true
 }
 
+// Compare returns an integer comparing two byte slices lexicographically.
+// The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
+// A nil argument is equivalent to an empty slice.
+func Compare(a, b []byte) int {
+	return bytealg.Compare(a, b)
+}
+
 // explode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes),
 // up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes.
 func explode(s []byte, n int) [][]byte {
@@ -83,6 +97,11 @@
 	return IndexRune(b, r) >= 0
 }
 
+// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
+func IndexByte(b []byte, c byte) int {
+	return bytealg.IndexByte(b, c)
+}
+
 func indexBytePortable(s []byte, c byte) int {
 	for i, b := range s {
 		if b == c {
@@ -489,19 +508,19 @@
 // ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
 // upper case, giving priority to the special casing rules.
 func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte {
-	return Map(func(r rune) rune { return c.ToUpper(r) }, s)
+	return Map(c.ToUpper, s)
 }
 
 // ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
 // lower case, giving priority to the special casing rules.
 func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte {
-	return Map(func(r rune) rune { return c.ToLower(r) }, s)
+	return Map(c.ToLower, s)
 }
 
 // ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
 // title case, giving priority to the special casing rules.
 func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte {
-	return Map(func(r rune) rune { return c.ToTitle(r) }, s)
+	return Map(c.ToTitle, s)
 }
 
 // isSeparator reports whether the rune could mark a word boundary.
@@ -774,6 +793,15 @@
 	return t[0:w]
 }
 
+// ReplaceAll returns a copy of the slice s with all
+// non-overlapping instances of old replaced by new.
+// If old is empty, it matches at the beginning of the slice
+// and after each UTF-8 sequence, yielding up to k+1 replacements
+// for a k-rune slice.
+func ReplaceAll(s, old, new []byte) []byte {
+	return Replace(s, old, new, -1)
+}
+
 // EqualFold reports whether s and t, interpreted as UTF-8 strings,
 // are equal under Unicode case-folding.
 func EqualFold(s, t []byte) bool {
@@ -849,21 +877,22 @@
 		if len(s) <= bytealg.MaxBruteForce {
 			return bytealg.Index(s, sep)
 		}
-		c := sep[0]
+		c0 := sep[0]
+		c1 := sep[1]
 		i := 0
-		t := s[:len(s)-n+1]
+		t := len(s) - n + 1
 		fails := 0
-		for i < len(t) {
-			if t[i] != c {
+		for i < t {
+			if s[i] != c0 {
 				// IndexByte is faster than bytealg.Index, so use it as long as
 				// we're not getting lots of false positives.
-				o := IndexByte(t[i:], c)
+				o := IndexByte(s[i:t], c0)
 				if o < 0 {
 					return -1
 				}
 				i += o
 			}
-			if Equal(s[i:i+n], sep) {
+			if s[i+1] == c1 && Equal(s[i:i+n], sep) {
 				return i
 			}
 			fails++
@@ -879,24 +908,25 @@
 		}
 		return -1
 	}
-	c := sep[0]
+	c0 := sep[0]
+	c1 := sep[1]
 	i := 0
 	fails := 0
-	t := s[:len(s)-n+1]
-	for i < len(t) {
-		if t[i] != c {
-			o := IndexByte(t[i:], c)
+	t := len(s) - n + 1
+	for i < t {
+		if s[i] != c0 {
+			o := IndexByte(s[i:t], c0)
 			if o < 0 {
 				break
 			}
 			i += o
 		}
-		if Equal(s[i:i+n], sep) {
+		if s[i+1] == c1 && Equal(s[i:i+n], sep) {
 			return i
 		}
 		i++
 		fails++
-		if fails >= 4+i>>4 && i < len(t) {
+		if fails >= 4+i>>4 && i < t {
 			// Give up on IndexByte, it isn't skipping ahead
 			// far enough to be better than Rabin-Karp.
 			// Experiments (using IndexPeriodic) suggest
diff --git a/src/bytes/bytes_decl.go b/src/bytes/bytes_decl.go
deleted file mode 100644
index af0f8b1..0000000
--- a/src/bytes/bytes_decl.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bytes
-
-//go:noescape
-
-// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
-func IndexByte(b []byte, c byte) int // in internal/bytealg
-
-//go:noescape
-
-// Equal returns a boolean reporting whether a and b
-// are the same length and contain the same bytes.
-// A nil argument is equivalent to an empty slice.
-func Equal(a, b []byte) bool // in internal/bytealg
-
-//go:noescape
-
-// Compare returns an integer comparing two byte slices lexicographically.
-// The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
-// A nil argument is equivalent to an empty slice.
-func Compare(a, b []byte) int // in internal/bytealg
diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go
index 55a22ba..f4c0ffd 100644
--- a/src/bytes/bytes_test.go
+++ b/src/bytes/bytes_test.go
@@ -1362,6 +1362,12 @@
 		if cap(in) == cap(out) && &in[:1][0] == &out[:1][0] {
 			t.Errorf("Replace(%q, %q, %q, %d) didn't copy", tt.in, tt.old, tt.new, tt.n)
 		}
+		if tt.n == -1 {
+			out := ReplaceAll(in, []byte(tt.old), []byte(tt.new))
+			if s := string(out); s != tt.out {
+				t.Errorf("ReplaceAll(%q, %q, %q) = %q, want %q", tt.in, tt.old, tt.new, s, tt.out)
+			}
+		}
 	}
 }
 
diff --git a/src/bytes/compare_test.go b/src/bytes/compare_test.go
index 3e33c27..a321f2e 100644
--- a/src/bytes/compare_test.go
+++ b/src/bytes/compare_test.go
@@ -41,9 +41,16 @@
 
 func TestCompare(t *testing.T) {
 	for _, tt := range compareTests {
-		cmp := Compare(tt.a, tt.b)
-		if cmp != tt.i {
-			t.Errorf(`Compare(%q, %q) = %v`, tt.a, tt.b, cmp)
+		numShifts := 16
+		buffer := make([]byte, len(tt.b)+numShifts)
+		// vary the input alignment of tt.b
+		for offset := 0; offset <= numShifts; offset++ {
+			shiftedB := buffer[offset : len(tt.b)+offset]
+			copy(shiftedB, tt.b)
+			cmp := Compare(tt.a, shiftedB)
+			if cmp != tt.i {
+				t.Errorf(`Compare(%q, %q), offset %d = %v; want %v`, tt.a, tt.b, offset, cmp, tt.i)
+			}
 		}
 	}
 }
diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go
index 5b7a460..6d32837 100644
--- a/src/bytes/example_test.go
+++ b/src/bytes/example_test.go
@@ -39,6 +39,14 @@
 	// Output: "64 bytes or fewer"
 }
 
+func ExampleBuffer_Len() {
+	var b bytes.Buffer
+	b.Grow(64)
+	b.Write([]byte("abcde"))
+	fmt.Printf("%d", b.Len())
+	// Output: 5
+}
+
 func ExampleCompare() {
 	// Interpret Compare's result by comparing it to zero.
 	var a, b []byte
@@ -290,6 +298,12 @@
 	// moo moo moo
 }
 
+func ExampleReplaceAll() {
+	fmt.Printf("%s\n", bytes.ReplaceAll([]byte("oink oink oink"), []byte("oink"), []byte("moo")))
+	// Output:
+	// moo moo moo
+}
+
 func ExampleRunes() {
 	rs := bytes.Runes([]byte("go gopher"))
 	for _, r := range rs {
diff --git a/src/bytes/reader.go b/src/bytes/reader.go
index 08464c2..5946cf9 100644
--- a/src/bytes/reader.go
+++ b/src/bytes/reader.go
@@ -14,6 +14,7 @@
 // io.ByteScanner, and io.RuneScanner interfaces by reading from
 // a byte slice.
 // Unlike a Buffer, a Reader is read-only and supports seeking.
+// The zero value for Reader operates like a Reader of an empty slice.
 type Reader struct {
 	s        []byte
 	i        int64 // current reading index
@@ -75,10 +76,10 @@
 
 // UnreadByte complements ReadByte in implementing the io.ByteScanner interface.
 func (r *Reader) UnreadByte() error {
-	r.prevRune = -1
 	if r.i <= 0 {
 		return errors.New("bytes.Reader.UnreadByte: at beginning of slice")
 	}
+	r.prevRune = -1
 	r.i--
 	return nil
 }
@@ -101,6 +102,9 @@
 
 // UnreadRune complements ReadRune in implementing the io.RuneScanner interface.
 func (r *Reader) UnreadRune() error {
+	if r.i <= 0 {
+		return errors.New("bytes.Reader.UnreadRune: at beginning of slice")
+	}
 	if r.prevRune < 0 {
 		return errors.New("bytes.Reader.UnreadRune: previous operation was not ReadRune")
 	}
diff --git a/src/bytes/reader_test.go b/src/bytes/reader_test.go
index 8806876..d799e03 100644
--- a/src/bytes/reader_test.go
+++ b/src/bytes/reader_test.go
@@ -276,3 +276,45 @@
 		t.Errorf("ReadAll: got %q, want %q", got, want)
 	}
 }
+
+func TestReaderZero(t *testing.T) {
+	if l := (&Reader{}).Len(); l != 0 {
+		t.Errorf("Len: got %d, want 0", l)
+	}
+
+	if n, err := (&Reader{}).Read(nil); n != 0 || err != io.EOF {
+		t.Errorf("Read: got %d, %v; want 0, io.EOF", n, err)
+	}
+
+	if n, err := (&Reader{}).ReadAt(nil, 11); n != 0 || err != io.EOF {
+		t.Errorf("ReadAt: got %d, %v; want 0, io.EOF", n, err)
+	}
+
+	if b, err := (&Reader{}).ReadByte(); b != 0 || err != io.EOF {
+		t.Errorf("ReadByte: got %d, %v; want 0, io.EOF", b, err)
+	}
+
+	if ch, size, err := (&Reader{}).ReadRune(); ch != 0 || size != 0 || err != io.EOF {
+		t.Errorf("ReadRune: got %d, %d, %v; want 0, 0, io.EOF", ch, size, err)
+	}
+
+	if offset, err := (&Reader{}).Seek(11, io.SeekStart); offset != 11 || err != nil {
+		t.Errorf("Seek: got %d, %v; want 11, nil", offset, err)
+	}
+
+	if s := (&Reader{}).Size(); s != 0 {
+		t.Errorf("Size: got %d, want 0", s)
+	}
+
+	if (&Reader{}).UnreadByte() == nil {
+		t.Errorf("UnreadByte: got nil, want error")
+	}
+
+	if (&Reader{}).UnreadRune() == nil {
+		t.Errorf("UnreadRune: got nil, want error")
+	}
+
+	if n, err := (&Reader{}).WriteTo(ioutil.Discard); n != 0 || err != nil {
+		t.Errorf("WriteTo: got %d, %v; want 0, nil", n, err)
+	}
+}
diff --git a/src/cmd/addr2line/main.go b/src/cmd/addr2line/main.go
index 267f417..0188029 100644
--- a/src/cmd/addr2line/main.go
+++ b/src/cmd/addr2line/main.go
@@ -61,6 +61,7 @@
 	if err != nil {
 		log.Fatal(err)
 	}
+	defer f.Close()
 
 	tab, err := f.PCLineTable()
 	if err != nil {
diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go
index 8cc78c0..02dfa7c 100644
--- a/src/cmd/api/goapi.go
+++ b/src/cmd/api/goapi.go
@@ -385,9 +385,7 @@
 	return f, nil
 }
 
-// The package cache doesn't operate correctly in rare (so far artificial)
-// circumstances (issue 8425). Disable before debugging non-obvious errors
-// from the type-checker.
+// Disable before debugging non-obvious errors from the type-checker.
 const usePkgCache = true
 
 var (
@@ -398,7 +396,7 @@
 // tagKey returns the tag-based key to use in the pkgCache.
 // It is a comma-separated string; the first part is dir, the rest tags.
 // The satisfied tags are derived from context but only those that
-// matter (the ones listed in the tags argument) are used.
+// matter (the ones listed in the tags argument plus GOOS and GOARCH) are used.
 // The tags list, which came from go/build's Package.AllTags,
 // is known to be sorted.
 func tagKey(dir string, context *build.Context, tags []string) string {
@@ -414,9 +412,17 @@
 	}
 	// TODO: ReleaseTags (need to load default)
 	key := dir
+
+	// explicit on GOOS and GOARCH as global cache will use "all" cached packages for
+	// an indirect imported package. See https://github.com/golang/go/issues/21181
+	// for more detail.
+	tags = append(tags, context.GOOS, context.GOARCH)
+	sort.Strings(tags)
+
 	for _, tag := range tags {
 		if ctags[tag] {
 			key += "," + tag
+			ctags[tag] = false
 		}
 	}
 	return key
@@ -436,13 +442,8 @@
 	}
 	w.imported[name] = &importing
 
-	root := w.root
-	if strings.HasPrefix(name, "golang_org/x/") {
-		root = filepath.Join(root, "vendor")
-	}
-
 	// Determine package files.
-	dir := filepath.Join(root, filepath.FromSlash(name))
+	dir := filepath.Join(w.root, filepath.FromSlash(name))
 	if fi, err := os.Stat(dir); err != nil || !fi.IsDir() {
 		log.Fatalf("no source in tree for import %q: %v", name, err)
 	}
diff --git a/src/cmd/api/goapi_test.go b/src/cmd/api/goapi_test.go
index 3c4e50a..1c8e2a3 100644
--- a/src/cmd/api/goapi_test.go
+++ b/src/cmd/api/goapi_test.go
@@ -188,3 +188,18 @@
 		}
 	}
 }
+
+func TestIssue21181(t *testing.T) {
+	for _, c := range contexts {
+		c.Compiler = build.Default.Compiler
+	}
+	for _, context := range contexts {
+		w := NewWalker(context, "testdata/src/issue21181")
+		pkg, err := w.Import("p")
+		if err != nil {
+			t.Fatalf("%s: (%s-%s) %s %v", err, context.GOOS, context.GOARCH,
+				pkg.Name(), w.imported)
+		}
+		w.export(pkg)
+	}
+}
diff --git a/src/cmd/api/testdata/src/issue21181/dep/p.go b/src/cmd/api/testdata/src/issue21181/dep/p.go
new file mode 100644
index 0000000..2d8e0c4
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/dep/p.go
@@ -0,0 +1,5 @@
+package dep
+
+type Interface interface {
+	N([]byte)
+}
diff --git a/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go b/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
new file mode 100644
index 0000000..8a2343a
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
@@ -0,0 +1 @@
+package dep
diff --git a/src/cmd/api/testdata/src/issue21181/indirect/p.go b/src/cmd/api/testdata/src/issue21181/indirect/p.go
new file mode 100644
index 0000000..e37cf3f
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/indirect/p.go
@@ -0,0 +1,5 @@
+package indirect
+
+import "dep"
+
+func F(dep.Interface) {}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p.go b/src/cmd/api/testdata/src/issue21181/p/p.go
new file mode 100644
index 0000000..a704160
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p.go
@@ -0,0 +1,9 @@
+package p
+
+import (
+	"dep"
+)
+
+type algo struct {
+	indrt func(dep.Interface)
+}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p_amd64.go b/src/cmd/api/testdata/src/issue21181/p/p_amd64.go
new file mode 100644
index 0000000..02b4cbf
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p_amd64.go
@@ -0,0 +1,7 @@
+package p
+
+import "indirect"
+
+var in = []algo{
+	{indirect.F},
+}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p_generic.go b/src/cmd/api/testdata/src/issue21181/p/p_generic.go
new file mode 100644
index 0000000..4d75809
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p_generic.go
@@ -0,0 +1,11 @@
+// +build !amd64
+
+package p
+
+import (
+	"indirect"
+)
+
+var in = []algo{
+	{indirect.F},
+}
diff --git a/src/cmd/asm/doc.go b/src/cmd/asm/doc.go
index c39cab3..8bf0aca 100644
--- a/src/cmd/asm/doc.go
+++ b/src/cmd/asm/doc.go
@@ -39,6 +39,8 @@
 		Generate code that can be linked into a shared library.
 	-trimpath prefix
 		Remove prefix from recorded source file paths.
+	-gensymabis
+		Write symbol ABI information to output file. Don't assemble.
 Input language:
 
 The assembler uses mostly the same syntax for all architectures,
diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go
index ecea6ba..eaa5cb8 100644
--- a/src/cmd/asm/internal/arch/arch.go
+++ b/src/cmd/asm/internal/arch/arch.go
@@ -258,6 +258,9 @@
 	for i := arm64.REG_R0; i <= arm64.REG_R31; i++ {
 		register[obj.Rconv(i)] = int16(i)
 	}
+	// Rename R18 to R18_PLATFORM to avoid accidental use.
+	register["R18_PLATFORM"] = register["R18"]
+	delete(register, "R18")
 	for i := arm64.REG_F0; i <= arm64.REG_F31; i++ {
 		register[obj.Rconv(i)] = int16(i)
 	}
diff --git a/src/cmd/asm/internal/arch/arm64.go b/src/cmd/asm/internal/arch/arm64.go
index 475d7da..98858bd 100644
--- a/src/cmd/asm/internal/arch/arm64.go
+++ b/src/cmd/asm/internal/arch/arm64.go
@@ -74,11 +74,12 @@
 		arm64.ASTXRB, arm64.ASTXRH, arm64.ASTXRW, arm64.ASTXR,
 		arm64.ASTXP, arm64.ASTXPW, arm64.ASTLXP, arm64.ASTLXPW,
 		arm64.ASWPB, arm64.ASWPH, arm64.ASWPW, arm64.ASWPD,
+		arm64.ASWPALB, arm64.ASWPALH, arm64.ASWPALW, arm64.ASWPALD,
 		arm64.ALDADDB, arm64.ALDADDH, arm64.ALDADDW, arm64.ALDADDD,
 		arm64.ALDANDB, arm64.ALDANDH, arm64.ALDANDW, arm64.ALDANDD,
 		arm64.ALDEORB, arm64.ALDEORH, arm64.ALDEORW, arm64.ALDEORD,
 		arm64.ALDORB, arm64.ALDORH, arm64.ALDORW, arm64.ALDORD,
-		arm64.ALDADDALD, arm64.ALDADDALW:
+		arm64.ALDADDALD, arm64.ALDADDALW, arm64.ALDADDALH, arm64.ALDADDALB:
 		return true
 	}
 	return false
diff --git a/src/cmd/asm/internal/asm/asm.go b/src/cmd/asm/internal/asm/asm.go
index 627be09..5da64f1 100644
--- a/src/cmd/asm/internal/asm/asm.go
+++ b/src/cmd/asm/internal/asm/asm.go
@@ -308,6 +308,28 @@
 	p.append(prog, "", true)
 }
 
+// asmPCAlign assembles a PCALIGN pseudo-op.
+// PCALIGN $16
+func (p *Parser) asmPCAlign(operands [][]lex.Token) {
+	if len(operands) != 1 {
+		p.errorf("expect one operand for PCALIGN")
+		return
+	}
+
+	// Operand 0 must be an immediate constant.
+	key := p.address(operands[0])
+	if !p.validImmediate("PCALIGN", &key) {
+		return
+	}
+
+	prog := &obj.Prog{
+		Ctxt: p.ctxt,
+		As:   obj.APCALIGN,
+		From: key,
+	}
+	p.append(prog, "", true)
+}
+
 // asmFuncData assembles a FUNCDATA pseudo-op.
 // FUNCDATA $1, funcdata<>+4(SB)
 func (p *Parser) asmFuncData(operands [][]lex.Token) {
diff --git a/src/cmd/asm/internal/asm/line_test.go b/src/cmd/asm/internal/asm/line_test.go
index b77337b..7462f24 100644
--- a/src/cmd/asm/internal/asm/line_test.go
+++ b/src/cmd/asm/internal/asm/line_test.go
@@ -38,8 +38,7 @@
 		parser := NewParser(ctxt, arch, tokenizer)
 
 		err := tryParse(t, func() {
-			parser.start(lex.Tokenize(test.input))
-			parser.line()
+			parser.Parse()
 		})
 
 		switch {
diff --git a/src/cmd/asm/internal/asm/operand_test.go b/src/cmd/asm/internal/asm/operand_test.go
index 1d1cf51..2ba3fd7 100644
--- a/src/cmd/asm/internal/asm/operand_test.go
+++ b/src/cmd/asm/internal/asm/operand_test.go
@@ -33,7 +33,7 @@
 
 // tryParse executes parse func in panicOnError=true context.
 // parse is expected to call any parsing methods that may panic.
-// Returns error gathered from recover; nil if no parse errors occured.
+// Returns error gathered from recover; nil if no parse errors occurred.
 //
 // For unexpected panics, calls t.Fatal.
 func tryParse(t *testing.T, parse func()) (err error) {
@@ -122,6 +122,49 @@
 	testOperandParser(t, parser, s390xOperandTests)
 }
 
+func TestFuncAddress(t *testing.T) {
+	type subtest struct {
+		arch  string
+		tests []operandTest
+	}
+	for _, sub := range []subtest{
+		{"amd64", amd64OperandTests},
+		{"386", x86OperandTests},
+		{"arm", armOperandTests},
+		{"arm64", arm64OperandTests},
+		{"ppc64", ppc64OperandTests},
+		{"mips", mipsOperandTests},
+		{"mips64", mips64OperandTests},
+		{"s390x", s390xOperandTests},
+	} {
+		t.Run(sub.arch, func(t *testing.T) {
+			parser := newParser(sub.arch)
+			for _, test := range sub.tests {
+				parser.start(lex.Tokenize(test.input))
+				name, ok := parser.funcAddress()
+
+				isFuncSym := strings.HasSuffix(test.input, "(SB)") &&
+					// Ignore static symbols.
+					!strings.Contains(test.input, "<>") &&
+					// Ignore symbols with offsets.
+					!strings.Contains(test.input, "+")
+
+				wantName := ""
+				if isFuncSym {
+					// Strip $|* and (SB).
+					wantName = test.output[:len(test.output)-4]
+					if strings.HasPrefix(wantName, "$") || strings.HasPrefix(wantName, "*") {
+						wantName = wantName[1:]
+					}
+				}
+				if ok != isFuncSym || name != wantName {
+					t.Errorf("fail at %s as function address: got %s, %v; expected %s, %v", test.input, name, ok, wantName, isFuncSym)
+				}
+			}
+		})
+	}
+}
+
 type operandTest struct {
 	input, output string
 }
@@ -607,6 +650,7 @@
 	{"R0", "R0"},
 	{"R10", "R10"},
 	{"R11", "R11"},
+	{"R18_PLATFORM", "R18"},
 	{"$4503601774854144.0", "$(4503601774854144.0)"},
 	{"$runtime·badsystemstack(SB)", "$runtime.badsystemstack(SB)"},
 	{"ZR", "ZR"},
diff --git a/src/cmd/asm/internal/asm/parse.go b/src/cmd/asm/internal/asm/parse.go
index 48749b7..346976e 100644
--- a/src/cmd/asm/internal/asm/parse.go
+++ b/src/cmd/asm/internal/asm/parse.go
@@ -91,7 +91,23 @@
 }
 
 func (p *Parser) Parse() (*obj.Prog, bool) {
-	for p.line() {
+	scratch := make([][]lex.Token, 0, 3)
+	for {
+		word, cond, operands, ok := p.line(scratch)
+		if !ok {
+			break
+		}
+		scratch = operands
+
+		if p.pseudo(word, operands) {
+			continue
+		}
+		i, present := p.arch.Instructions[word]
+		if present {
+			p.instruction(i, word, cond, operands)
+			continue
+		}
+		p.errorf("unrecognized instruction %q", word)
 	}
 	if p.errorCount > 0 {
 		return nil, false
@@ -100,8 +116,33 @@
 	return p.firstProg, true
 }
 
-// WORD [ arg {, arg} ] (';' | '\n')
-func (p *Parser) line() bool {
+// ParseSymABIs parses p's assembly code to find text symbol
+// definitions and references and writes a symabis file to w.
+func (p *Parser) ParseSymABIs(w io.Writer) bool {
+	operands := make([][]lex.Token, 0, 3)
+	for {
+		word, _, operands1, ok := p.line(operands)
+		if !ok {
+			break
+		}
+		operands = operands1
+
+		p.symDefRef(w, word, operands)
+	}
+	return p.errorCount == 0
+}
+
+// line consumes a single assembly line from p.lex of the form
+//
+//   {label:} WORD[.cond] [ arg {, arg} ] (';' | '\n')
+//
+// It adds any labels to p.pendingLabels and returns the word, cond,
+// operand list, and true. If there is an error or EOF, it returns
+// ok=false.
+//
+// line may reuse the memory from scratch.
+func (p *Parser) line(scratch [][]lex.Token) (word, cond string, operands [][]lex.Token, ok bool) {
+next:
 	// Skip newlines.
 	var tok lex.ScanToken
 	for {
@@ -114,24 +155,29 @@
 		case '\n', ';':
 			continue
 		case scanner.EOF:
-			return false
+			return "", "", nil, false
 		}
 		break
 	}
 	// First item must be an identifier.
 	if tok != scanner.Ident {
 		p.errorf("expected identifier, found %q", p.lex.Text())
-		return false // Might as well stop now.
+		return "", "", nil, false // Might as well stop now.
 	}
-	word := p.lex.Text()
-	var cond string
-	operands := make([][]lex.Token, 0, 3)
+	word, cond = p.lex.Text(), ""
+	operands = scratch[:0]
 	// Zero or more comma-separated operands, one per loop.
 	nesting := 0
 	colon := -1
 	for tok != '\n' && tok != ';' {
 		// Process one operand.
-		items := make([]lex.Token, 0, 3)
+		var items []lex.Token
+		if cap(operands) > len(operands) {
+			// Reuse scratch items slice.
+			items = operands[:cap(operands)][len(operands)][:0]
+		} else {
+			items = make([]lex.Token, 0, 3)
+		}
 		for {
 			tok = p.lex.Next()
 			if len(operands) == 0 && len(items) == 0 {
@@ -148,12 +194,12 @@
 				if tok == ':' {
 					// Labels.
 					p.pendingLabels = append(p.pendingLabels, word)
-					return true
+					goto next
 				}
 			}
 			if tok == scanner.EOF {
 				p.errorf("unexpected EOF")
-				return false
+				return "", "", nil, false
 			}
 			// Split operands on comma. Also, the old syntax on x86 for a "register pair"
 			// was AX:DX, for which the new syntax is DX, AX. Note the reordering.
@@ -162,7 +208,7 @@
 					// Remember this location so we can swap the operands below.
 					if colon >= 0 {
 						p.errorf("invalid ':' in operand")
-						return true
+						return word, cond, operands, true
 					}
 					colon = len(operands)
 				}
@@ -188,16 +234,7 @@
 			p.errorf("missing operand")
 		}
 	}
-	if p.pseudo(word, operands) {
-		return true
-	}
-	i, present := p.arch.Instructions[word]
-	if present {
-		p.instruction(i, word, cond, operands)
-		return true
-	}
-	p.errorf("unrecognized instruction %q", word)
-	return true
+	return word, cond, operands, true
 }
 
 func (p *Parser) instruction(op obj.As, word, cond string, operands [][]lex.Token) {
@@ -227,6 +264,8 @@
 		p.asmGlobl(operands)
 	case "PCDATA":
 		p.asmPCData(operands)
+	case "PCALIGN":
+		p.asmPCAlign(operands)
 	case "TEXT":
 		p.asmText(operands)
 	default:
@@ -235,6 +274,42 @@
 	return true
 }
 
+// symDefRef scans a line for potential text symbol definitions and
+// references and writes symabis information to w.
+//
+// The symabis format is documented at
+// cmd/compile/internal/gc.readSymABIs.
+func (p *Parser) symDefRef(w io.Writer, word string, operands [][]lex.Token) {
+	switch word {
+	case "TEXT":
+		// Defines text symbol in operands[0].
+		if len(operands) > 0 {
+			p.start(operands[0])
+			if name, ok := p.funcAddress(); ok {
+				fmt.Fprintf(w, "def %s ABI0\n", name)
+			}
+		}
+		return
+	case "GLOBL", "PCDATA":
+		// No text definitions or symbol references.
+	case "DATA", "FUNCDATA":
+		// For DATA, operands[0] is defined symbol.
+		// For FUNCDATA, operands[0] is an immediate constant.
+		// Remaining operands may have references.
+		if len(operands) < 2 {
+			return
+		}
+		operands = operands[1:]
+	}
+	// Search for symbol references.
+	for _, op := range operands {
+		p.start(op)
+		if name, ok := p.funcAddress(); ok {
+			fmt.Fprintf(w, "ref %s ABI0\n", name)
+		}
+	}
+}
+
 func (p *Parser) start(operand []lex.Token) {
 	p.input = operand
 	p.inputPos = 0
@@ -723,6 +798,35 @@
 	}
 }
 
+// funcAddress parses an external function address. This is a
+// constrained form of the operand syntax that's always SB-based,
+// non-static, and has no additional offsets:
+//
+//    [$|*]sym(SB)
+func (p *Parser) funcAddress() (string, bool) {
+	switch p.peek() {
+	case '$', '*':
+		// Skip prefix.
+		p.next()
+	}
+
+	tok := p.next()
+	name := tok.String()
+	if tok.ScanToken != scanner.Ident || p.atStartOfRegister(name) {
+		return "", false
+	}
+	if p.next().ScanToken != '(' {
+		return "", false
+	}
+	if reg := p.next(); reg.ScanToken != scanner.Ident || reg.String() != "SB" {
+		return "", false
+	}
+	if p.next().ScanToken != ')' || p.peek() != scanner.EOF {
+		return "", false
+	}
+	return name, true
+}
+
 // registerIndirect parses the general form of a register indirection.
 // It is can be (R1), (R2*scale), (R1)(R2*scale), (R1)(R2.SXTX<<3) or (R1)(R2<<3)
 // where R1 may be a simple register or register pair R:R or (R, R) or (R+R).
diff --git a/src/cmd/asm/internal/asm/testdata/386.s b/src/cmd/asm/internal/asm/testdata/386.s
index 90a6616..d524a4c 100644
--- a/src/cmd/asm/internal/asm/testdata/386.s
+++ b/src/cmd/asm/internal/asm/testdata/386.s
@@ -70,7 +70,7 @@
 // LTYPEM spec6	{ outcode(int($1), &$2); }
 	MOVL	AX, BX
 	MOVL	$4, BX
-	
+
 // LTYPEI spec7	{ outcode(int($1), &$2); }
 	IMULL	AX
 	IMULL	$4, CX
diff --git a/src/cmd/asm/internal/asm/testdata/386enc.s b/src/cmd/asm/internal/asm/testdata/386enc.s
index 15d1705..4af6de3 100644
--- a/src/cmd/asm/internal/asm/testdata/386enc.s
+++ b/src/cmd/asm/internal/asm/testdata/386enc.s
@@ -18,7 +18,7 @@
 	MOVL -2147483648(AX), AX // 8b8000000080
 	ADDL 2147483648(AX), AX  // 038000000080
 	ADDL -2147483648(AX), AX // 038000000080
-	// Make sure MOV CR/DR continues to work after changing it's movtabs.
+	// Make sure MOV CR/DR continues to work after changing its movtabs.
 	MOVL CR0, AX // 0f20c0
 	MOVL CR0, DX // 0f20c2
 	MOVL CR4, DI // 0f20e7
diff --git a/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s b/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
index afd1dfd..d7afecc 100644
--- a/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
+++ b/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
@@ -302,7 +302,7 @@
 	// Check that LEAL is permitted to use overflowing offset.
 	LEAL 2400959708(BP)(R10*1), BP // 428dac15dcbc1b8f
 	LEAL 3395469782(AX)(R10*1), AX // 428d8410d6c162ca
-	// Make sure MOV CR/DR continues to work after changing it's movtabs.
+	// Make sure MOV CR/DR continues to work after changing its movtabs.
 	MOVQ CR0, AX // 0f20c0
 	MOVQ CR0, DX // 0f20c2
 	MOVQ CR4, DI // 0f20e7
@@ -911,7 +911,7 @@
 	VADDPD.BCST.Z (AX), Z2, K1, Z1 // 62f1edd95808
 	VMAXPD.BCST (AX), Z2, K1, Z1   // 62f1ed595f08
 	VMAXPD.BCST.Z (AX), Z2, K1, Z1 // 62f1edd95f08
-	// EVEX: surpress all exceptions (SAE).
+	// EVEX: suppress all exceptions (SAE).
 	VMAXPD.SAE   Z3, Z2, K1, Z1   // 62f1ed595fcb or 62f1ed195fcb
 	VMAXPD.SAE.Z Z3, Z2, K1, Z1   // 62f1edd95fcb or 62f1ed995fcb
 	VMAXPD (AX), Z2, K1, Z1       // 62f1ed495f08
diff --git a/src/cmd/asm/internal/asm/testdata/arm64.s b/src/cmd/asm/internal/asm/testdata/arm64.s
index 3a4410f..b54fd86 100644
--- a/src/cmd/asm/internal/asm/testdata/arm64.s
+++ b/src/cmd/asm/internal/asm/testdata/arm64.s
@@ -25,6 +25,18 @@
 	ADD	R1, R2, R3
 	ADD	R1, ZR, R3
 	ADD	$1, R2, R3
+	ADD	$0x000aaa, R2, R3 // ADD $2730, R2, R3     // 43a82a91
+	ADD	$0x000aaa, R2     // ADD $2730, R2         // 42a82a91
+	ADD	$0xaaa000, R2, R3 // ADD $11182080, R2, R3 // 43a86a91
+	ADD	$0xaaa000, R2     // ADD $11182080, R2     // 42a86a91
+	ADD	$0xaaaaaa, R2, R3 // ADD $11184810, R2, R3 // 43a82a9163a86a91
+	ADD	$0xaaaaaa, R2     // ADD $11184810, R2     // 42a82a9142a86a91
+	SUB	$0x000aaa, R2, R3 // SUB $2730, R2, R3     // 43a82ad1
+	SUB	$0x000aaa, R2     // SUB $2730, R2         // 42a82ad1
+	SUB	$0xaaa000, R2, R3 // SUB $11182080, R2, R3 // 43a86ad1
+	SUB	$0xaaa000, R2     // SUB $11182080, R2     // 42a86ad1
+	SUB	$0xaaaaaa, R2, R3 // SUB $11184810, R2, R3 // 43a82ad163a86ad1
+	SUB	$0xaaaaaa, R2     // SUB $11184810, R2     // 42a82ad142a86ad1
 	ADD	R1>>11, R2, R3
 	ADD	R1<<22, R2, R3
 	ADD	R1->33, R2, R3
@@ -35,8 +47,8 @@
 	ADD	R2.SXTX<<1, RSP, RSP            // ffe7228b
 	ADD	ZR.SXTX<<1, R2, R3              // 43e43f8b
 	ADDW	R2.SXTW, R10, R12               // 4cc1220b
-	ADD	R18.UXTX, R14, R17              // d161328b
-	ADDSW	R18.UXTW, R14, R17              // d141322b
+	ADD	R19.UXTX, R14, R17              // d161338b
+	ADDSW	R19.UXTW, R14, R17              // d141332b
 	ADDS	R12.SXTX, R3, R1                // 61e02cab
 	SUB	R19.UXTH<<4, R2, R21            // 553033cb
 	SUBW	R1.UXTX<<1, R3, R2              // 6264214b
@@ -132,7 +144,7 @@
 	MOVD	(R2)(R6.SXTW), R4               // 44c866f8
 	MOVD	(R3)(R6), R5                    // MOVD	(R3)(R6*1), R5                  // 656866f8
 	MOVD	(R2)(R6), R4                    // MOVD	(R2)(R6*1), R4                  // 446866f8
-	MOVWU	(R19)(R18<<2), R18              // 727a72b8
+	MOVWU	(R19)(R20<<2), R20              // 747a74b8
 	MOVD	(R2)(R6<<3), R4                 // 447866f8
 	MOVD	(R3)(R7.SXTX<<3), R8            // 68f867f8
 	MOVWU	(R5)(R4.UXTW), R10              // aa4864b8
@@ -142,7 +154,7 @@
 	MOVHU	(R1)(R2<<1), R5                 // 25786278
 	MOVB	(R9)(R3.UXTW), R6               // 2649a338
 	MOVB	(R10)(R6), R15                  // MOVB	(R10)(R6*1), R15                // 4f69a638
-	MOVH	(R5)(R7.SXTX<<1), R18           // b2f8a778
+	MOVH	(R5)(R7.SXTX<<1), R19           // b3f8a778
 	MOVH	(R8)(R4<<1), R10                // 0a79a478
 	MOVW	(R9)(R8.SXTW<<2), R19           // 33d9a8b8
 	MOVW	(R1)(R4.SXTX), R11              // 2be8a4b8
@@ -163,7 +175,32 @@
 	MOVB	(R29)(R30<<0), R14              // ae7bbe38
 	MOVB	(R29)(R30), R14                 // MOVB	(R29)(R30*1), R14                // ae6bbe38
 	MOVB	R4, (R2)(R6.SXTX)               // 44e82638
+	FMOVS	$(4.0), F0                      // 0010221e
+	FMOVD	$(4.0), F0                      // 0010621e
+	FMOVS	$(0.265625), F1                 // 01302a1e
+	FMOVD	$(0.1796875), F2                // 02f0681e
+	FMOVS	$(0.96875), F3                  // 03f02d1e
+	FMOVD	$(28.0), F4                     // 0490671e
 
+	FMOVS	(R2)(R6), F4       // FMOVS (R2)(R6*1), F4    // 446866bc
+	FMOVS	(R2)(R6<<2), F4                               // 447866bc
+	FMOVD	(R2)(R6), F4       // FMOVD (R2)(R6*1), F4    // 446866fc
+	FMOVD	(R2)(R6<<3), F4                               // 447866fc
+	FMOVS	F4, (R2)(R6)       // FMOVS F4, (R2)(R6*1)    // 446826bc
+	FMOVS	F4, (R2)(R6<<2)                               // 447826bc
+	FMOVD	F4, (R2)(R6)       // FMOVD F4, (R2)(R6*1)    // 446826fc
+	FMOVD	F4, (R2)(R6<<3)                               // 447826fc
+
+	CMPW	$40960, R0                      // 1f284071
+	CMPW	$27745, R2                      // 3b8c8d525f001b6b
+	CMNW	$0x3fffffc0, R2                 // CMNW	$1073741760, R2                   // fb5f1a325f001b2b
+	CMPW	$0xffff0, R1                    // CMPW	$1048560, R1                      // fb3f1c323f001b6b
+	CMP	$0xffffffffffa0, R3             // CMP	$281474976710560, R3              // fb0b80921b00e0f27f001beb
+	CMP	$0xf4240, R1                    // CMP	$1000000, R1                      // 1b4888d2fb01a0f23f001beb
+	ADD	$0x186a0, R2, R5                // ADD	$100000, R2, R5                   // 45801a91a5604091
+	SUB	$0xe7791f700, R3, R1            // SUB	$62135596800, R3, R1              // 1be09ed23bf2aef2db01c0f261001bcb
+	CMP     $3343198598084851058, R3        // 5bae8ed2db8daef23badcdf2bbcce5f27f001beb
+	ADD	$0x3fffffffc000, R5             // ADD	$70368744161280, R5               // fb7f72b2a5001b8b
 //	LTYPE1 imsr ',' spreg ','
 //	{
 //		outcode($1, &$2, $4, &nullgen);
@@ -190,6 +227,13 @@
 	EOR	$(1<<63), R1   // EOR	$-9223372036854775808, R1 // 210041d2
 	EOR	$(1<<63-1), R1 // EOR	$9223372036854775807, R1  // 21f840d2
 
+	ANDW	$0x3ff00000, R2 // ANDW	$1072693248, R2 // 42240c12
+	BICW	$0x3ff00000, R2 // BICW	$1072693248, R2 // 42540212
+	ORRW	$0x3ff00000, R2 // ORRW	$1072693248, R2 // 42240c32
+	ORNW	$0x3ff00000, R2 // ORNW	$1072693248, R2 // 42540232
+	EORW	$0x3ff00000, R2 // EORW	$1072693248, R2 // 42240c52
+	EONW	$0x3ff00000, R2 // EONW	$1072693248, R2 // 42540252
+
 	AND	$0x22220000, R3, R4   // AND $572653568, R3, R4   // 5b44a4d264001b8a
 	ORR	$0x22220000, R3, R4   // ORR $572653568, R3, R4   // 5b44a4d264001baa
 	EOR	$0x22220000, R3, R4   // EOR $572653568, R3, R4   // 5b44a4d264001bca
@@ -199,6 +243,37 @@
 	ANDS	$0x22220000, R3, R4   // ANDS $572653568, R3, R4  // 5b44a4d264001bea
 	BICS	$0x22220000, R3, R4   // BICS $572653568, R3, R4  // 5b44a4d264003bea
 
+	EOR	$0xe03fffffffffffff, R20, R22       // EOR	$-2287828610704211969, R20, R22 // 96e243d2
+	TSTW	$0x600000006, R1                    // TSTW	$25769803782, R1                // 3f041f72
+	TST	$0x4900000049, R0                   // TST	$313532612681, R0               // 3b0980d23b09c0f21f001bea
+	ORR	$0x170000, R2, R1                   // ORR	$1507328, R2, R1                // fb02a0d241001baa
+	AND	$0xff00ff, R2                       // AND	$16711935, R2                   // fb1f80d2fb1fa0f242001b8a
+	AND	$0xff00ffff, R1                     // AND	$4278255615, R1                 // fbff9fd21be0bff221001b8a
+	ANDS	$0xffff, R2                         // ANDS	$65535, R2                      // 423c40f2
+	AND	$0x7fffffff, R3                     // AND	$2147483647, R3                 // 63784092
+	ANDS	$0x0ffffffff80000000, R2            // ANDS	$-2147483648, R2                // 428061f2
+	AND	$0xfffff, R2                        // AND	$1048575, R2                    // 424c4092
+	ANDW	$0xf00fffff, R1                     // ANDW	$4027580415, R1                 // 215c0412
+	ANDSW	$0xff00ffff, R1                     // ANDSW	$4278255615, R1                 // 215c0872
+	TST	$0x11223344, R2                     // TST	$287454020, R2                  // 9b6886d25b24a2f25f001bea
+	TSTW	$0xa000, R3                         // TSTW	$40960, R3                      // 1b0094527f001b6a
+	BICW	$0xa000, R3                         // BICW	$40960, R3                      // 1b00945263003b0a
+	ORRW	$0x1b000, R2, R3                    // ORRW	$110592, R2, R3                 // 1b0096523b00a07243001b2a
+	TSTW	$0x500000, R1                       // TSTW	$5242880, R1                    // 1b0aa0523f001b6a
+	TSTW	$0xff00ff, R1                       // TSTW	$16711935, R1                   // 3f9c0072
+	TSTW	$0x60060, R5                        // TSTW	$393312, R5                     // 1b0c8052db00a072bf001b6a
+	TSTW	$0x6006000060060, R5                // TSTW	$1689262177517664, R5           // 1b0c8052db00a072bf001b6a
+	ANDW	$0x6006000060060, R5                // ANDW	$1689262177517664, R5           // 1b0c8052db00a072a5001b0a
+	ANDSW	$0x6006000060060, R5                // ANDSW	$1689262177517664, R5           // 1b0c8052db00a072a5001b6a
+	EORW	$0x6006000060060, R5                // EORW	$1689262177517664, R5           // 1b0c8052db00a072a5001b4a
+	ORRW	$0x6006000060060, R5                // ORRW	$1689262177517664, R5           // 1b0c8052db00a072a5001b2a
+	BICW	$0x6006000060060, R5                // BICW	$1689262177517664, R5           // 1b0c8052db00a072a5003b0a
+	EONW	$0x6006000060060, R5                // EONW	$1689262177517664, R5           // 1b0c8052db00a072a5003b4a
+	ORNW	$0x6006000060060, R5                // ORNW	$1689262177517664, R5           // 1b0c8052db00a072a5003b2a
+	BICSW	$0x6006000060060, R5                // BICSW	$1689262177517664, R5           // 1b0c8052db00a072a5003b6a
+	ADDW	$0x60060, R2                        // ADDW	$393312, R2                     // 4280011142804111
+	CMPW	$0x60060, R2                        // CMPW	$393312, R2                     // 1b0c8052db00a0725f001b6b
+
 	AND	$8, R0, RSP // 1f007d92
 	ORR	$8, R0, RSP // 1f007db2
 	EOR	$8, R0, RSP // 1f007dd2
@@ -206,6 +281,26 @@
 	ORN	$8, R0, RSP // 1ff87cb2
 	EON	$8, R0, RSP // 1ff87cd2
 
+	MOVD	$0x3fffffffc000, R0           // MOVD	$70368744161280, R0         // e07f72b2
+	MOVW	$1000000, R4                  // 04488852e401a072
+	MOVW	$0xaaaa0000, R1               // MOVW	$2863267840, R1             // 4155b552
+	MOVW	$0xaaaaffff, R1               // MOVW	$2863333375, R1             // a1aaaa12
+	MOVW	$0xaaaa, R1                   // MOVW	$43690, R1                  // 41559552
+	MOVW	$0xffffaaaa, R1               // MOVW	$4294945450, R1             // a1aa8a12
+	MOVW	$0xffff0000, R1               // MOVW	$4294901760, R1             // e1ffbf52
+	MOVD	$0xffff00000000000, R1        // MOVD	$1152903912420802560, R1    // e13f54b2
+	MOVD	$0x1111000000001111, R1       // MOVD	$1229764173248860433, R1    // 212282d22122e2f2
+	MOVD	$0x1111ffff1111ffff, R1       // MOVD	$1230045644216991743, R1    // c1ddbd922122e2f2
+	MOVD	$0x1111222233334444, R1       // MOVD	$1229801703532086340, R1    // 818888d26166a6f24144c4f22122e2f2
+	MOVD	$0xaaaaffff, R1               // MOVD	$2863333375, R1             // e1ff9fd24155b5f2
+	MOVD	$0x11110000, R1               // MOVD	$286326784, R1              // 2122a2d2
+	MOVD	$0xaaaa0000aaaa1111, R1       // MOVD	$-6149102338357718767, R1   // 212282d24155b5f24155f5f2
+	MOVD	$0x1111ffff1111aaaa, R1       // MOVD	$1230045644216969898, R1    // a1aa8a922122a2f22122e2f2
+	MOVD	$0, R1                        // 010080d2
+	MOVD	$-1, R1                       // 01008092
+	MOVD	$0x210000, R0                 // MOVD	$2162688, R0                 // 2004a0d2
+	MOVD	$0xffffffffffffaaaa, R1       // MOVD	$-21846, R1                  // a1aa8a92
+
 //
 // CLS
 //
@@ -401,7 +496,7 @@
 	CMP	R22.SXTX, RSP // ffe336eb
 
 	CMP	$0x22220000, RSP  // CMP $572653568, RSP   // 5b44a4d2ff633beb
-	CMPW	$0x22220000, RSP  // CMPW $572653568, RSP  // 5b44a4d2ff633b6b
+	CMPW	$0x22220000, RSP  // CMPW $572653568, RSP  // 5b44a452ff633b6b
 
 // TST
 	TST	$15, R2                               // 5f0c40f2
@@ -470,14 +565,14 @@
 //	{
 //		outcode($1, &$2, NREG, &$4);
 //	}
-	FADDD	$0.5, F1 // FADDD $(0.5), F1
+//	FADDD	$0.5, F1 // FADDD $(0.5), F1
 	FADDD	F1, F2
 
 //		LTYPEK frcon ',' freg ',' freg
 //	{
 //		outcode($1, &$2, $4.reg, &$6);
 //	}
-	FADDD	$0.7, F1, F2 // FADDD	$(0.69999999999999996), F1, F2
+//	FADDD	$0.7, F1, F2 // FADDD	$(0.69999999999999996), F1, F2
 	FADDD	F1, F2, F3
 
 //
@@ -572,6 +667,14 @@
 	SWPH	R5, (RSP), R7                        // e7832578
 	SWPB	R5, (R6), R7                         // c7802538
 	SWPB	R5, (RSP), R7                        // e7832538
+	SWPALD	R5, (R6), R7                         // c780e5f8
+	SWPALD	R5, (RSP), R7                        // e783e5f8
+	SWPALW	R5, (R6), R7                         // c780e5b8
+	SWPALW	R5, (RSP), R7                        // e783e5b8
+	SWPALH	R5, (R6), R7                         // c780e578
+	SWPALH	R5, (RSP), R7                        // e783e578
+	SWPALB	R5, (R6), R7                         // c780e538
+	SWPALB	R5, (RSP), R7                        // e783e538
 	LDADDD	R5, (R6), R7                         // c70025f8
 	LDADDD	R5, (RSP), R7                        // e70325f8
 	LDADDW	R5, (R6), R7                         // c70025b8
@@ -605,7 +708,9 @@
 	LDORB	R5, (R6), R7                         // c7302538
 	LDORB	R5, (RSP), R7                        // e7332538
 	LDADDALD	R2, (R1), R3                 // 2300e2f8
-	LDADDALW	R5, (R4), R6                 // 8600e5b8
+	LDADDALW	R2, (R1), R3                 // 2300e2b8
+	LDADDALH	R2, (R1), R3                 // 2300e278
+	LDADDALB	R2, (R1), R3                 // 2300e238
 
 // RET
 //
@@ -629,6 +734,7 @@
 	CALL	foo(SB)
 
 // LDP/STP
+	LDP	(R0), (R0, R1)      // 000440a9
 	LDP	(R0), (R1, R2)      // 010840a9
 	LDP	8(R0), (R1, R2)     // 018840a9
 	LDP	-8(R0), (R1, R2)    // 01887fa9
@@ -724,6 +830,78 @@
 	UBFIZ	$0, R1, $1, R2      // 220040d3
 	UBFIZW	$0, R1, $1, R2      // 22000053
 
+// FSTPD/FSTPS/FLDPD/FLDPS
+	FLDPD	(R0), (F1, F2)      // 0108406d
+	FLDPD	8(R0), (F1, F2)     // 0188406d
+	FLDPD	-8(R0), (F1, F2)    // 01887f6d
+	FLDPD	11(R0), (F1, F2)    // 1b2c0091610b406d
+	FLDPD	1024(R0), (F1, F2)  // 1b001091610b406d
+	FLDPD.W	8(R0), (F1, F2)     // 0188c06d
+	FLDPD.P	8(R0), (F1, F2)     // 0188c06c
+	FLDPD	(RSP), (F1, F2)     // e10b406d
+	FLDPD	8(RSP), (F1, F2)    // e18b406d
+	FLDPD	-8(RSP), (F1, F2)   // e18b7f6d
+	FLDPD	11(RSP), (F1, F2)   // fb2f0091610b406d
+	FLDPD	1024(RSP), (F1, F2) // fb031091610b406d
+	FLDPD.W	8(RSP), (F1, F2)    // e18bc06d
+	FLDPD.P	8(RSP), (F1, F2)    // e18bc06c
+	FLDPD	-31(R0), (F1, F2)   // 1b7c00d1610b406d
+	FLDPD	-4(R0), (F1, F2)    // 1b1000d1610b406d
+	FLDPD	-8(R0), (F1, F2)    // 01887f6d
+	FLDPD	x(SB), (F1, F2)
+	FLDPD	x+8(SB), (F1, F2)
+	FLDPS	-5(R0), (F1, F2)    // 1b1400d1610b402d
+	FLDPS	(R0), (F1, F2)      // 0108402d
+	FLDPS	4(R0), (F1, F2)     // 0188402d
+	FLDPS	-4(R0), (F1, F2)    // 01887f2d
+	FLDPS.W	4(R0), (F1, F2)     // 0188c02d
+	FLDPS.P	4(R0), (F1, F2)     // 0188c02c
+	FLDPS	11(R0), (F1, F2)    // 1b2c0091610b402d
+	FLDPS	1024(R0), (F1, F2)  // 1b001091610b402d
+	FLDPS	(RSP), (F1, F2)     // e10b402d
+	FLDPS	4(RSP), (F1, F2)    // e18b402d
+	FLDPS	-4(RSP), (F1, F2)   // e18b7f2d
+	FLDPS.W	4(RSP), (F1, F2)    // e18bc02d
+	FLDPS.P	4(RSP), (F1, F2)    // e18bc02c
+	FLDPS	11(RSP), (F1, F2)   // fb2f0091610b402d
+	FLDPS	1024(RSP), (F1, F2) // fb031091610b402d
+	FLDPS	x(SB), (F1, F2)
+	FLDPS	x+8(SB), (F1, F2)
+	FSTPD	(F3, F4), (R5)      // a310006d
+	FSTPD	(F3, F4), 8(R5)     // a390006d
+	FSTPD.W	(F3, F4), 8(R5)     // a390806d
+	FSTPD.P	(F3, F4), 8(R5)     // a390806c
+	FSTPD	(F3, F4), -8(R5)    // a3903f6d
+	FSTPD	(F3, F4), -4(R5)    // bb1000d16313006d
+	FSTPD	(F3, F4), 11(R0)    // 1b2c00916313006d
+	FSTPD	(F3, F4), 1024(R0)  // 1b0010916313006d
+	FSTPD	(F3, F4), (RSP)     // e313006d
+	FSTPD	(F3, F4), 8(RSP)    // e393006d
+	FSTPD.W	(F3, F4), 8(RSP)    // e393806d
+	FSTPD.P	(F3, F4), 8(RSP)    // e393806c
+	FSTPD	(F3, F4), -8(RSP)   // e3933f6d
+	FSTPD	(F3, F4), 11(RSP)   // fb2f00916313006d
+	FSTPD	(F3, F4), 1024(RSP) // fb0310916313006d
+	FSTPD	(F3, F4), x(SB)
+	FSTPD	(F3, F4), x+8(SB)
+	FSTPS	(F3, F4), (R5)      // a310002d
+	FSTPS	(F3, F4), 4(R5)     // a390002d
+	FSTPS.W	(F3, F4), 4(R5)     // a390802d
+	FSTPS.P	(F3, F4), 4(R5)     // a390802c
+	FSTPS	(F3, F4), -4(R5)    // a3903f2d
+	FSTPS	(F3, F4), -5(R5)    // bb1400d16313002d
+	FSTPS	(F3, F4), 11(R0)    // 1b2c00916313002d
+	FSTPS	(F3, F4), 1024(R0)  // 1b0010916313002d
+	FSTPS	(F3, F4), (RSP)     // e313002d
+	FSTPS	(F3, F4), 4(RSP)    // e393002d
+	FSTPS.W	(F3, F4), 4(RSP)    // e393802d
+	FSTPS.P	(F3, F4), 4(RSP)    // e393802c
+	FSTPS	(F3, F4), -4(RSP)   // e3933f2d
+	FSTPS	(F3, F4), 11(RSP)   // fb2f00916313002d
+	FSTPS	(F3, F4), 1024(RSP) // fb0310916313002d
+	FSTPS	(F3, F4), x(SB)
+	FSTPS	(F3, F4), x+8(SB)
+
 // END
 //
 //	LTYPEE comma
diff --git a/src/cmd/asm/internal/asm/testdata/arm64enc.s b/src/cmd/asm/internal/asm/testdata/arm64enc.s
index ee4673c..a2850e2 100644
--- a/src/cmd/asm/internal/asm/testdata/arm64enc.s
+++ b/src/cmd/asm/internal/asm/testdata/arm64enc.s
@@ -56,7 +56,7 @@
    BFXILW $3, R27, $23, R14                   // 6e670333
    BFXIL $26, R8, $16, R20                    // 14a55ab3
    BICW R7@>15, R5, R16                       // b03ce70a
-   BIC R12@>13, R12, R18                      // 9235ec8a
+   BIC R12@>13, R12, R19                      // 9335ec8a
    BICSW R25->20, R3, R20                     // 7450b96a
    BICS R19->12, R1, R23                      // 3730b3ea
    BICS R19, R1, R23                          // 370033ea
@@ -76,7 +76,7 @@
    CCMN LE, R30, R12, $6                      // c6d34cba
    CCMPW VS, R29, $15, $7                     // a76b4f7a
    CCMP LE, R7, $19, $3                       // e3d853fa
-   CCMPW HS, R18, R6, $0                      // 4022467a
+   CCMPW HS, R19, R6, $0                      // 6022467a
    CCMP LT, R30, R6, $7                       // c7b346fa
    CCMN  MI, ZR, R1, $4                       // e44341ba
    CSINCW HS, ZR, R27, R14                    // ee279b1a
@@ -118,7 +118,7 @@
    CRC32H R3, R21, R27                        // bb46c31a
    CRC32W R22, R30, R9                        // c94bd61a
    CRC32X R20, R4, R15                        // 8f4cd49a
-   CRC32CB R18, R27, R22                      // 7653d21a
+   CRC32CB R19, R27, R22                      // 7653d31a
    CRC32CH R21, R0, R20                       // 1454d51a
    CRC32CW R9, R3, R21                        // 7558c91a
    CRC32CX R11, R0, R24                       // 185ccb9a
@@ -133,7 +133,7 @@
    CSINVW AL, R23, R21, R5                    // e5e2955a
    CSINV LO, R2, R11, R14                     // 4e308bda
    CSNEGW HS, R16, R29, R10                   // 0a269d5a
-   CSNEG NE, R21, R18, R11                    // ab1692da
+   CSNEG NE, R21, R19, R11                    // ab1693da
    //TODO DC
    DCPS1 $11378                               // 418ea5d4
    DCPS2 $10699                               // 6239a5d4
@@ -185,23 +185,23 @@
    MOVBU.P 42(R2), R12                        // 4ca44238
    MOVBU.W -27(R2), R14                       // 4e5c5e38
    MOVBU 2916(R24), R3                        // 03936d39
-   MOVBU (R18)(R14<<0), R23                   // 577a6e38
+   MOVBU (R19)(R14<<0), R23                   // 777a6e38
    MOVBU (R2)(R8.SXTX), R19                   // 53e86838
    MOVBU (R27)(R23), R14                      // MOVBU (R27)(R23*1), R14     // 6e6b7738
-   MOVHU.P 107(R13), R13                      // adb54678
-   MOVHU.W 192(R2), R2                        // 420c4c78
-   MOVHU 6844(R4), R18                        // 92787579
+   MOVHU.P 107(R14), R13                      // cdb54678
+   MOVHU.W 192(R3), R2                        // 620c4c78
+   MOVHU 6844(R4), R19                        // 93787579
    MOVHU (R5)(R25.SXTW), R15                  // afc87978
-   //TODO MOVBW.P 77(R18), R11                // 4bd6c438
+   //TODO MOVBW.P 77(R19), R11                // 6bd6c438
    MOVB.P 36(RSP), R27                        // fb478238
-   //TODO MOVBW.W -57(R18), R13               // 4d7edc38
+   //TODO MOVBW.W -57(R19), R13               // 6d7edc38
    MOVB.W -178(R16), R24                      // 18ee9438
    //TODO MOVBW 430(R8), R22                  // 16b9c639
    MOVB 997(R9), R23                          // 37958f39
    //TODO MOVBW (R2<<1)(R21), R15             // af7ae238
    //TODO MOVBW (R26)(R0), R21                // 1568fa38
    MOVB (R5)(R15), R16                        // MOVB (R5)(R15*1), R16         // b068af38
-   MOVB (R18)(R26.SXTW), R19                  // 53caba38
+   MOVB (R19)(R26.SXTW), R19                  // 73caba38
    MOVB (R29)(R30), R14                       // MOVB (R29)(R30*1), R14        // ae6bbe38
    //TODO MOVHW.P 218(R22), R25               // d9a6cd78
    MOVH.P 179(R23), R5                        // e5368b78
@@ -212,7 +212,7 @@
    //TODO MOVHW (R22)(R24.SXTX), R4           // c4eaf878
    MOVH (R26)(R30.UXTW<<1), ZR                // 5f5bbe78
    MOVW.P -58(R16), R2                        // 02669cb8
-   MOVW.W -216(R18), R8                       // 488e92b8
+   MOVW.W -216(R19), R8                       // 688e92b8
    MOVW 4764(R23), R10                        // ea9e92b9
    MOVW (R8)(R3.UXTW), R17                    // 1149a3b8
    //TODO LDTR -0x1e(R3), R4                  // 64285eb8
@@ -297,7 +297,7 @@
    RET                                        // c0035fd6
    REVW R8, R10                               // 0a09c05a
    REV R1, R2                                 // 220cc0da
-   REV16W R21, R18                            // b206c05a
+   REV16W R21, R19                            // b306c05a
    REV16 R25, R4                              // 2407c0da
    REV32 R27, R21                             // 750bc0da
    EXTRW $27, R4, R25, R19                    // 336f8413
@@ -308,7 +308,7 @@
    ROR R0, R23, R2                            // e22ec09a
    SBCW R4, R8, R24                           // 1801045a
    SBC R25, R10, R26                          // 5a0119da
-   SBCSW R27, R18, R18                        // 52021b7a
+   SBCSW R27, R19, R19                        // 73021b7a
    SBCS R5, R9, R5                            // 250105fa
    SBFIZW $9, R10, $18, R22                   // 56451713
    SBFIZ $6, R11, $15, R20                    // 74397a93
@@ -337,7 +337,7 @@
    //TODO STNPW 44(R1), R3, R10               // 2a8c0528
    //TODO STNP 0x108(R3), ZR, R7              // 67fc10a8
    LDP.P -384(R3), (R22, R26)                 // 7668e8a8
-   LDP.W 280(R8), (R18, R11)                  // 12add1a9
+   LDP.W 280(R8), (R19, R11)                  // 13add1a9
    STP.P (R22, R27), 352(R0)                  // 166c96a8
    STP.W (R17, R11), 96(R8)                   // 112d86a9
    MOVW.P R20, -28(R1)                        // 34441eb8
@@ -360,22 +360,22 @@
    MOVB R2, (R29)(R26)                        // MOVB R2, (R29)(R26*1)         // a26b3a38
    MOVH R11, -80(R23)                         // eb021b78
    MOVH R11, (R27)(R14.SXTW<<1)               // 6bdb2e78
-   MOVB R18, (R0)(R4)                         // MOVB R18, (R0)(R4*1)          // 12682438
+   MOVB R19, (R0)(R4)                         // MOVB R19, (R0)(R4*1)          // 13682438
    MOVB R1, (R6)(R4)                          // MOVB R1, (R6)(R4*1)           // c1682438
    MOVH R3, (R11)(R13<<1)                     // 63792d78
    //TODO STTR 55(R4), R29                    // 9d7803b8
    //TODO STTR 124(R5), R25                   // b9c807f8
    //TODO STTRB -28(R23), R16                 // f04a1e38
-   //TODO STTRH 9(R10), R18                   // 52990078
+   //TODO STTRH 9(R10), R19                   // 53990078
    STXP (R1, R2), (R3), R10                   // 61082ac8
    STXP (R1, R2), (RSP), R10                  // e10b2ac8
    STXPW (R1, R2), (R3), R10                  // 61082a88
    STXPW (R1, R2), (RSP), R10                 // e10b2a88
-   STXRW R2, (R19), R18                       // 627e1288
+   STXRW R2, (R19), R20                       // 627e1488
    STXR R15, (R21), R13                       // af7e0dc8
    STXRB R7, (R9), R24                        // 277d1808
    STXRH R12, (R3), R8                        // 6c7c0848
-   SUBW R20.UXTW<<2, R23, R18                 // f24a344b
+   SUBW R20.UXTW<<2, R23, R19                 // f34a344b
    SUB R5.SXTW<<2, R1, R26                    // 3ac825cb
    SUB $(1923<<12), R4, R27                   // SUB $7876608, R4, R27         // 9b0c5ed1
    SUBW $(1923<<12), R4, R27                  // SUBW $7876608, R4, R27        // 9b0c5e51
@@ -410,12 +410,12 @@
    UBFXW $3, R7, $20, R15                     // ef580353
    UBFX $33, R17, $25, R5                     // 25e661d3
    UDIVW R8, R21, R15                         // af0ac81a
-   UDIV R2, R18, R21                          // 550ac29a
+   UDIV R2, R19, R21                          // 750ac29a
    UMADDL R0, R20, R17, R17                   // 3152a09b
    UMSUBL R22, R4, R3, R7                     // 6790b69b
-   UMNEGL R3, R18, R1                         // 41fea39b
+   UMNEGL R3, R19, R1                         // 61fea39b
    UMULH R24, R20, R24                        // 987ed89b
-   UMULL R18, R22, R19                        // d37eb29b
+   UMULL R19, R22, R19                        // d37eb39b
    UXTBW R2, R6                               // 461c0053
    UXTHW R7, R20                              // f43c0053
    VCNT V0.B8, V0.B8                          // 0058200e
@@ -471,7 +471,7 @@
    //TODO FCVTAS F27, R7                      // 6703241e
    //TODO FCVTAS F19, R26                     // 7a02249e
    //TODO FCVTAS F4, R0                       // 8000641e
-   //TODO FCVTAS F3, R18                      // 7200649e
+   //TODO FCVTAS F3, R19                      // 7300649e
    //TODO FCVTAU F18, F28                     // 5cca217e
    //TODO VFCVTAU V30.S4, V27.S4              // dbcb216e
    //TODO FCVTAU F0, R2                       // 0200251e
@@ -482,16 +482,16 @@
    //TODO VFCVTL2 V15.H8, V25.S4              // f979214e
    //TODO FCVTMS F21, F28                     // bcba215e
    //TODO VFCVTMS V5.D2, V2.D2                // a2b8614e
-   //TODO FCVTMS F31, R18                     // f203301e
+   //TODO FCVTMS F31, R19                     // f303301e
    //TODO FCVTMS F23, R16                     // f002309e
    //TODO FCVTMS F16, R22                     // 1602701e
    //TODO FCVTMS F14, R19                     // d301709e
    //TODO FCVTMU F14, F8                      // c8b9217e
    //TODO VFCVTMU V7.D2, V1.D2                // e1b8616e
    //TODO FCVTMU F2, R0                       // 4000311e
-   //TODO FCVTMU F23, R18                     // f202319e
+   //TODO FCVTMU F23, R19                     // f302319e
    //TODO FCVTMU F16, R17                     // 1102711e
-   //TODO FCVTMU F12, R18                     // 9201719e
+   //TODO FCVTMU F12, R19                     // 9301719e
    //TODO VFCVTN V23.D2, V26.S2               // fa6a610e
    //TODO VFCVTN2 V2.D2, V31.S4               // 5f68614e
    //TODO FCVTNS F3, F27                      // 7ba8215e
@@ -540,7 +540,7 @@
    //TODO FCVTZU $14, F24, R20                // 14cb191e
    //TODO FCVTZU $6, F25, R17                 // 31eb199e
    //TODO FCVTZU $5, F17, R10                 // 2aee591e
-   //TODO FCVTZU $6, F7, R18                  // f2e8599e
+   //TODO FCVTZU $6, F7, R19                  // f3e8599e
    FCVTZUSW F2, R9                            // 4900391e
    FCVTZUS F12, R29                           // 9d01399e
    FCVTZUDW F27, R22                          // 7603791e
@@ -682,11 +682,11 @@
    VLD1.P (R19)(R4), [V24.B8, V25.B8]                          // VLD1.P (R19)(R4*1), [V24.B8, V25.B8]         // 78a2c40c
    VLD1.P (R20)(R8), [V7.H8, V8.H8, V9.H8]                     // VLD1.P (R20)(R8*1), [V7.H8, V8.H8, V9.H8]    // 8766c84c
    VLD1.P 32(R30), [V5.B8, V6.B8, V7.B8, V8.B8]                // c523df0c
-   VLD1 (R18), V14.B[15]                                       // 4e1e404d
+   VLD1 (R19), V14.B[15]                                       // 6e1e404d
    VLD1 (R29), V0.H[1]                                         // a04b400d
    VLD1 (R27), V2.S[0]                                         // 6283400d
    VLD1 (R21), V5.D[1]                                         // a586404d
-   VLD1.P 1(R18), V10.B[14]                                    // 4a1adf4d
+   VLD1.P 1(R19), V10.B[14]                                    // 6a1adf4d
    VLD1.P (R3)(R14), V16.B[11]                                 // VLD1.P (R3)(R14*1), V16.B[11]                // 700cce4d
    VLD1.P 2(R1), V28.H[2]                                      // 3c50df0d
    VLD1.P (R13)(R20), V9.H[2]                                  // VLD1.P (R13)(R20*1), V9.H[2]                 // a951d40d
diff --git a/src/cmd/asm/internal/asm/testdata/arm64error.s b/src/cmd/asm/internal/asm/testdata/arm64error.s
index 01d23eb..357db80 100644
--- a/src/cmd/asm/internal/asm/testdata/arm64error.s
+++ b/src/cmd/asm/internal/asm/testdata/arm64error.s
@@ -8,7 +8,19 @@
 	ADDSW	R7->32, R14, R13                                 // ERROR "shift amount out of range 0 to 31"
 	ADD	R1.UXTB<<5, R2, R3                               // ERROR "shift amount out of range 0 to 4"
 	ADDS	R1.UXTX<<7, R2, R3                               // ERROR "shift amount out of range 0 to 4"
+	AND	$0x22220000, R2, RSP                             // ERROR "illegal combination"
+	ANDS	$0x22220000, R2, RSP                             // ERROR "illegal combination"
+	ADD	R1, R2, R3, R4                                   // ERROR "illegal combination"
 	BICW	R7@>33, R5, R16                                  // ERROR "shift amount out of range 0 to 31"
+	CINC	CS, R2, R3, R4                                   // ERROR "illegal combination"
+	CSEL	LT, R1, R2                                       // ERROR "illegal combination"
+	LDP.P	8(R2), (R2, R3)                                  // ERROR "constrained unpredictable behavior"
+	LDP.W	8(R3), (R2, R3)                                  // ERROR "constrained unpredictable behavior"
+	LDP	(R1), (R2, R2)                                   // ERROR "constrained unpredictable behavior"
+	LDP	(R0), (F0, F1)                                   // ERROR "invalid register pair"
+	LDP	(R0), (R3, ZR)                                   // ERROR "invalid register pair"
+	LDXPW	(RSP), (R2, R2)                                  // ERROR "constrained unpredictable behavior"
+	LDAXPW	(R5), (R2, R2)                                   // ERROR "constrained unpredictable behavior"
 	MOVD.P	300(R2), R3                                      // ERROR "offset out of range [-255,254]"
 	MOVD.P	R3, 344(R2)                                      // ERROR "offset out of range [-255,254]"
 	MOVD	(R3)(R7.SXTX<<2), R8                             // ERROR "invalid index shift amount"
@@ -16,6 +28,17 @@
 	MOVWU	(R5)(R4<<1), R10                                 // ERROR "invalid index shift amount"
 	MOVB	(R5)(R4.SXTW<<5), R10                            // ERROR "invalid index shift amount"
 	MOVH	R5, (R6)(R2<<3)                                  // ERROR "invalid index shift amount"
+	MADD	R1, R2, R3                                       // ERROR "illegal combination"
+	MOVD.P	R1, 8(R1)                                        // ERROR "constrained unpredictable behavior"
+	MOVD.W 	16(R2), R2                                       // ERROR "constrained unpredictable behavior"
+	STP	(F2, F3), (R0)                                   // ERROR "invalid register pair"
+	STP.W	(R1, R2), 8(R1)                                  // ERROR "constrained unpredictable behavior"
+	STP.P	(R1, R2), 8(R2)                                  // ERROR "constrained unpredictable behavior"
+	STLXP	(R6, R11), (RSP), R6                             // ERROR "constrained unpredictable behavior"
+	STXP	(R6, R11), (R2), R2                              // ERROR "constrained unpredictable behavior"
+	STLXR	R3, (RSP), R3                                    // ERROR "constrained unpredictable behavior"
+	STXR	R3, (R4), R4                                     // ERROR "constrained unpredictable behavior"
+	STLXRB	R2, (R5), R5                                     // ERROR "constrained unpredictable behavior"
 	VLD1	(R8)(R13), [V2.B16]                              // ERROR "illegal combination"
 	VLD1	8(R9), [V2.B16]                                  // ERROR "illegal combination"
 	VST1	[V1.B16], (R8)(R13)                              // ERROR "illegal combination"
@@ -83,12 +106,10 @@
 	VST1.P	[V1.B16], (R8)(R9<<1)                            // ERROR "invalid extended register"
 	VREV64	V1.H4, V2.H8                                     // ERROR "invalid arrangement"
 	VREV64	V1.D1, V2.D1                                     // ERROR "invalid arrangement"
-	ADD	R1, R2, R3, R4                                   // ERROR "illegal combination"
-	MADD	R1, R2, R3                                       // ERROR "illegal combination"
-	CINC	CS, R2, R3, R4                                   // ERROR "illegal combination"
-	CSEL	LT, R1, R2                                       // ERROR "illegal combination"
-	AND	$0x22220000, R2, RSP                             // ERROR "illegal combination"
-	ANDS	$0x22220000, R2, RSP                             // ERROR "illegal combination"
-	LDP	(R0), (F0, F1)                                   // ERROR "invalid register pair"
-	STP	(F2, F3), (R0)                                   // ERROR "invalid register pair"
+	FLDPD	(R0), (R1, R2)                                   // ERROR "invalid register pair"
+	FLDPD	(R1), (F2, F2)                                   // ERROR "constrained unpredictable behavior"
+	FLDPS	(R2), (F3, F3)                                   // ERROR "constrained unpredictable behavior"
+	FSTPD	(R1, R2), (R0)                                   // ERROR "invalid register pair"
+	FMOVS	(F2), F0                                         // ERROR "illegal combination"
+	FMOVD	F0, (F1)                                         // ERROR "illegal combination"
 	RET
diff --git a/src/cmd/asm/internal/asm/testdata/ppc64.s b/src/cmd/asm/internal/asm/testdata/ppc64.s
index ba00b8f..366c80c 100644
--- a/src/cmd/asm/internal/asm/testdata/ppc64.s
+++ b/src/cmd/asm/internal/asm/testdata/ppc64.s
@@ -550,7 +550,7 @@
 //	ftsqrt	BF, FRB
 	FTSQRT	F2,$7
 
-//	FCFID	
+//	FCFID
 //	FCFIDS
 
 	FCFID	F2,F3
@@ -948,6 +948,7 @@
 //	<MNEMONIC> VRA,VRB,VRC,VRT produces
 //	<mnemonic> VRT,VRA,VRB,VRC
 	VPERM V3, V2, V1, V0
+	VPERMXOR V3, V2, V1, V0
 
 //	Vector bit permute, VX-form
 //	<MNEMONIC> VRA,VRB,VRT produces
diff --git a/src/cmd/asm/internal/asm/testdata/ppc64enc.s b/src/cmd/asm/internal/asm/testdata/ppc64enc.s
index 7ab1a57..0133a85 100644
--- a/src/cmd/asm/internal/asm/testdata/ppc64enc.s
+++ b/src/cmd/asm/internal/asm/testdata/ppc64enc.s
@@ -98,4 +98,7 @@
 	LDAR (R4),$0,R5                 // 7ca020a8
 	LDAR (R3),R5                    // 7ca018a8
 
+	// float constants
+	FMOVD $(0.0), F1                // f0210cd0
+	FMOVD $(-0.0), F1               // f0210cd0fc200850
 	RET
diff --git a/src/cmd/asm/internal/asm/testdata/s390x.s b/src/cmd/asm/internal/asm/testdata/s390x.s
index fce855e..0e50303 100644
--- a/src/cmd/asm/internal/asm/testdata/s390x.s
+++ b/src/cmd/asm/internal/asm/testdata/s390x.s
@@ -115,6 +115,7 @@
 	NEGW	R1                    // b9130011
 	NEGW	R1, R2                // b9130021
 	FLOGR	R2, R2                // b9830022
+	POPCNT	R3, R4                // b9e10043
 
 	AND	R1, R2                // b9800021
 	AND	R1, R2, R3            // b9e42031
@@ -368,6 +369,9 @@
 	VSTEH	$7, V31, (R2)           // e7f020007809
 	VSTEB	$15, V29, 4094(R12)     // e7d0cffef808
 	VMSLG	V21, V22, V23, V24      // e78563007fb8
+	VMSLEG  V21, V22, V23, V24      // e78563807fb8
+	VMSLOG  V21, V22, V23, V24      // e78563407fb8
+	VMSLEOG V21, V22, V23, V24      // e78563c07fb8
 
 	RET
 	RET	foo(SB)
diff --git a/src/cmd/asm/internal/flags/flags.go b/src/cmd/asm/internal/flags/flags.go
index 6acde29..5fe3fd9 100644
--- a/src/cmd/asm/internal/flags/flags.go
+++ b/src/cmd/asm/internal/flags/flags.go
@@ -22,6 +22,7 @@
 	Shared     = flag.Bool("shared", false, "generate code that can be linked into a shared library")
 	Dynlink    = flag.Bool("dynlink", false, "support references to Go symbols defined in other shared libraries")
 	AllErrors  = flag.Bool("e", false, "no limit on number of errors reported")
+	SymABIs    = flag.Bool("gensymabis", false, "write symbol ABI information to output file, don't assemble")
 )
 
 var (
diff --git a/src/cmd/asm/internal/lex/input.go b/src/cmd/asm/internal/lex/input.go
index 5186635..a43953b 100644
--- a/src/cmd/asm/internal/lex/input.go
+++ b/src/cmd/asm/internal/lex/input.go
@@ -139,7 +139,7 @@
 	return in.text
 }
 
-// hash processes a # preprocessor directive. It returns true iff it completes.
+// hash processes a # preprocessor directive. It reports whether it completes.
 func (in *Input) hash() bool {
 	// We have a '#'; it must be followed by a known word (define, include, etc.).
 	tok := in.Stack.Next()
diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go
index 04f56f9..447d1af 100644
--- a/src/cmd/asm/main.go
+++ b/src/cmd/asm/main.go
@@ -36,7 +36,7 @@
 
 	ctxt := obj.Linknew(architecture.LinkArch)
 	if *flags.PrintOut {
-		ctxt.Debugasm = true
+		ctxt.Debugasm = 1
 	}
 	ctxt.Flag_dynlink = *flags.Dynlink
 	ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
@@ -53,8 +53,10 @@
 	defer bio.MustClose(out)
 	buf := bufio.NewWriter(bio.MustWriter(out))
 
-	fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version)
-	fmt.Fprintf(buf, "!\n")
+	if !*flags.SymABIs {
+		fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version)
+		fmt.Fprintf(buf, "!\n")
+	}
 
 	var ok, diag bool
 	var failedFile string
@@ -65,16 +67,22 @@
 			diag = true
 			log.Printf(format, args...)
 		}
-		pList := new(obj.Plist)
-		pList.Firstpc, ok = parser.Parse()
+		if *flags.SymABIs {
+			ok = parser.ParseSymABIs(buf)
+		} else {
+			pList := new(obj.Plist)
+			pList.Firstpc, ok = parser.Parse()
+			// reports errors to parser.Errorf
+			if ok {
+				obj.Flushplist(ctxt, pList, nil, "")
+			}
+		}
 		if !ok {
 			failedFile = f
 			break
 		}
-		// reports errors to parser.Errorf
-		obj.Flushplist(ctxt, pList, nil, "")
 	}
-	if ok {
+	if ok && !*flags.SymABIs {
 		obj.WriteObjFile(ctxt, buf)
 	}
 	if !ok || diag {
diff --git a/src/cmd/cgo/ast.go b/src/cmd/cgo/ast.go
index 4462136..54d6bc2 100644
--- a/src/cmd/cgo/ast.go
+++ b/src/cmd/cgo/ast.go
@@ -145,6 +145,7 @@
 	if f.Ref == nil {
 		f.Ref = make([]*Ref, 0, 8)
 	}
+	f.walk(ast2, ctxProg, (*File).validateIdents)
 	f.walk(ast2, ctxProg, (*File).saveExprs)
 
 	// Accumulate exported functions.
@@ -181,6 +182,14 @@
 	return strings.Join(pieces, "")
 }
 
+func (f *File) validateIdents(x interface{}, context astContext) {
+	if x, ok := x.(*ast.Ident); ok {
+		if f.isMangledName(x.Name) {
+			error_(x.Pos(), "identifier %q may conflict with identifiers generated by cgo", x.Name)
+		}
+	}
+}
+
 // Save various references we are going to need later.
 func (f *File) saveExprs(x interface{}, context astContext) {
 	switch x := x.(type) {
diff --git a/src/cmd/cgo/doc.go b/src/cmd/cgo/doc.go
index 157cd94..cceb33e 100644
--- a/src/cmd/cgo/doc.go
+++ b/src/cmd/cgo/doc.go
@@ -413,6 +413,8 @@
 	jobjectArray
 	jweak
 
+3. The EGLDisplay type from the EGL API.
+
 These types are uintptr on the Go side because they would otherwise
 confuse the Go garbage collector; they are sometimes not really
 pointers but data structures encoded in a pointer type. All operations
@@ -427,6 +429,11 @@
 
 It will replace nil with 0 in the appropriate places.
 
+The EGLDisplay case were introduced in Go 1.12. Use the egl rewrite
+to auto-update code from Go 1.11 and earlier:
+
+	go tool fix -r egl <pkg>
+
 Using cgo directly
 
 Usage:
@@ -827,6 +834,10 @@
 	possibly version in the dynamic library, and the optional "<library>"
 	names the specific library where the symbol should be found.
 
+	On AIX, the library pattern is slightly different. It must be
+	"lib.a/obj.o" with obj.o the member of this library exporting
+	this symbol.
+
 	In the <remote>, # or @ can be used to introduce a symbol version.
 
 	Examples:
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index 20e794b..915ad66 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -20,6 +20,7 @@
 	"go/ast"
 	"go/parser"
 	"go/token"
+	"internal/xcoff"
 	"math"
 	"os"
 	"strconv"
@@ -90,7 +91,13 @@
 	p.CgoFlags[flag] = append(p.CgoFlags[flag], args...)
 	if flag == "CFLAGS" {
 		// We'll also need these when preprocessing for dwarf information.
-		p.GccOptions = append(p.GccOptions, args...)
+		// However, discard any -g options: we need to be able
+		// to parse the debug info, so stick to what we expect.
+		for _, arg := range args {
+			if !strings.HasPrefix(arg, "-g") {
+				p.GccOptions = append(p.GccOptions, arg)
+			}
+		}
 	}
 }
 
@@ -163,6 +170,10 @@
 		// Convert C.ulong to C.unsigned long, etc.
 		cref.Name.C = cname(cref.Name.Go)
 	}
+
+	var conv typeConv
+	conv.Init(p.PtrSize, p.IntSize)
+
 	p.loadDefines(f)
 	p.typedefs = map[string]bool{}
 	p.typedefList = nil
@@ -170,15 +181,17 @@
 	for len(p.typedefs) > numTypedefs {
 		numTypedefs = len(p.typedefs)
 		// Also ask about any typedefs we've seen so far.
-		for _, a := range p.typedefList {
-			f.Name[a] = &Name{
-				Go: a,
-				C:  a,
+		for _, info := range p.typedefList {
+			n := &Name{
+				Go: info.typedef,
+				C:  info.typedef,
 			}
+			f.Name[info.typedef] = n
+			f.NamePos[n] = info.pos
 		}
 		needType := p.guessKinds(f)
 		if len(needType) > 0 {
-			p.loadDWARF(f, needType)
+			p.loadDWARF(f, &conv, needType)
 		}
 
 		// In godefs mode we're OK with the typedefs, which
@@ -188,6 +201,7 @@
 			break
 		}
 	}
+	p.prepareNames(f)
 	if p.rewriteCalls(f) {
 		// Add `import _cgo_unsafe "unsafe"` after the package statement.
 		f.Edit.Insert(f.offset(f.AST.Name.End()), "; import _cgo_unsafe \"unsafe\"")
@@ -472,7 +486,7 @@
 // loadDWARF parses the DWARF debug information generated
 // by gcc to learn the details of the constants, variables, and types
 // being referred to as C.xxx.
-func (p *Package) loadDWARF(f *File, names []*Name) {
+func (p *Package) loadDWARF(f *File, conv *typeConv, names []*Name) {
 	// Extract the types from the DWARF section of an object
 	// from a well-formed C program. Gcc only generates DWARF info
 	// for symbols in the object file, so it is not enough to print the
@@ -571,7 +585,7 @@
 				fatalf("malformed __cgo__ name: %s", name)
 			}
 			types[i] = t.Type
-			p.recordTypedefs(t.Type)
+			p.recordTypedefs(t.Type, f.NamePos[names[i]])
 		}
 		if e.Tag != dwarf.TagCompileUnit {
 			r.SkipChildren()
@@ -579,8 +593,6 @@
 	}
 
 	// Record types and typedef information.
-	var conv typeConv
-	conv.Init(p.PtrSize, p.IntSize)
 	for i, n := range names {
 		if strings.HasSuffix(n.Go, "GetTypeID") && types[i].String() == "func() CFTypeID" {
 			conv.getTypeIDs[n.Go[:len(n.Go)-9]] = true
@@ -639,10 +651,11 @@
 }
 
 // recordTypedefs remembers in p.typedefs all the typedefs used in dtypes and its children.
-func (p *Package) recordTypedefs(dtype dwarf.Type) {
-	p.recordTypedefs1(dtype, map[dwarf.Type]bool{})
+func (p *Package) recordTypedefs(dtype dwarf.Type, pos token.Pos) {
+	p.recordTypedefs1(dtype, pos, map[dwarf.Type]bool{})
 }
-func (p *Package) recordTypedefs1(dtype dwarf.Type, visited map[dwarf.Type]bool) {
+
+func (p *Package) recordTypedefs1(dtype dwarf.Type, pos token.Pos, visited map[dwarf.Type]bool) {
 	if dtype == nil {
 		return
 	}
@@ -658,27 +671,48 @@
 		}
 		if !p.typedefs[dt.Name] {
 			p.typedefs[dt.Name] = true
-			p.typedefList = append(p.typedefList, dt.Name)
-			p.recordTypedefs1(dt.Type, visited)
+			p.typedefList = append(p.typedefList, typedefInfo{dt.Name, pos})
+			p.recordTypedefs1(dt.Type, pos, visited)
 		}
 	case *dwarf.PtrType:
-		p.recordTypedefs1(dt.Type, visited)
+		p.recordTypedefs1(dt.Type, pos, visited)
 	case *dwarf.ArrayType:
-		p.recordTypedefs1(dt.Type, visited)
+		p.recordTypedefs1(dt.Type, pos, visited)
 	case *dwarf.QualType:
-		p.recordTypedefs1(dt.Type, visited)
+		p.recordTypedefs1(dt.Type, pos, visited)
 	case *dwarf.FuncType:
-		p.recordTypedefs1(dt.ReturnType, visited)
+		p.recordTypedefs1(dt.ReturnType, pos, visited)
 		for _, a := range dt.ParamType {
-			p.recordTypedefs1(a, visited)
+			p.recordTypedefs1(a, pos, visited)
 		}
 	case *dwarf.StructType:
 		for _, f := range dt.Field {
-			p.recordTypedefs1(f.Type, visited)
+			p.recordTypedefs1(f.Type, pos, visited)
 		}
 	}
 }
 
+// prepareNames finalizes the Kind field of not-type names and sets
+// the mangled name of all names.
+func (p *Package) prepareNames(f *File) {
+	for _, n := range f.Name {
+		if n.Kind == "not-type" {
+			if n.Define == "" {
+				n.Kind = "var"
+			} else {
+				n.Kind = "macro"
+				n.FuncType = &FuncType{
+					Result: n.Type,
+					Go: &ast.FuncType{
+						Results: &ast.FieldList{List: []*ast.Field{{Type: n.Type.Go}}},
+					},
+				}
+			}
+		}
+		p.mangleName(n)
+	}
+}
+
 // mangleName does name mangling to translate names
 // from the original Go source files to the names
 // used in the final Go files generated by cgo.
@@ -693,24 +727,37 @@
 	n.Mangle = prefix + n.Kind + "_" + n.Go
 }
 
+func (f *File) isMangledName(s string) bool {
+	prefix := "_C"
+	if strings.HasPrefix(s, prefix) {
+		t := s[len(prefix):]
+		for _, k := range nameKinds {
+			if strings.HasPrefix(t, k+"_") {
+				return true
+			}
+		}
+	}
+	return false
+}
+
 // rewriteCalls rewrites all calls that pass pointers to check that
 // they follow the rules for passing pointers between Go and C.
-// This returns whether the package needs to import unsafe as _cgo_unsafe.
+// This reports whether the package needs to import unsafe as _cgo_unsafe.
 func (p *Package) rewriteCalls(f *File) bool {
 	needsUnsafe := false
+	// Walk backward so that in C.f1(C.f2()) we rewrite C.f2 first.
 	for _, call := range f.Calls {
-		// This is a call to C.xxx; set goname to "xxx".
-		goname := call.Call.Fun.(*ast.SelectorExpr).Sel.Name
-		if goname == "malloc" {
+		if call.Done {
 			continue
 		}
-		name := f.Name[goname]
-		if name.Kind != "func" {
-			// Probably a type conversion.
-			continue
-		}
-		if p.rewriteCall(f, call, name) {
-			needsUnsafe = true
+		start := f.offset(call.Call.Pos())
+		end := f.offset(call.Call.End())
+		str, nu := p.rewriteCall(f, call)
+		if str != "" {
+			f.Edit.Replace(start, end, str)
+			if nu {
+				needsUnsafe = true
+			}
 		}
 	}
 	return needsUnsafe
@@ -720,162 +767,201 @@
 // If any pointer checks are required, we rewrite the call into a
 // function literal that calls _cgoCheckPointer for each pointer
 // argument and then calls the original function.
-// This returns whether the package needs to import unsafe as _cgo_unsafe.
-func (p *Package) rewriteCall(f *File, call *Call, name *Name) bool {
+// This returns the rewritten call and whether the package needs to
+// import unsafe as _cgo_unsafe.
+// If it returns the empty string, the call did not need to be rewritten.
+func (p *Package) rewriteCall(f *File, call *Call) (string, bool) {
+	// This is a call to C.xxx; set goname to "xxx".
+	// It may have already been mangled by rewriteName.
+	var goname string
+	switch fun := call.Call.Fun.(type) {
+	case *ast.SelectorExpr:
+		goname = fun.Sel.Name
+	case *ast.Ident:
+		goname = strings.TrimPrefix(fun.Name, "_C2func_")
+		goname = strings.TrimPrefix(goname, "_Cfunc_")
+	}
+	if goname == "" || goname == "malloc" {
+		return "", false
+	}
+	name := f.Name[goname]
+	if name == nil || name.Kind != "func" {
+		// Probably a type conversion.
+		return "", false
+	}
+
+	params := name.FuncType.Params
+	args := call.Call.Args
+
 	// Avoid a crash if the number of arguments is
 	// less than the number of parameters.
 	// This will be caught when the generated file is compiled.
-	if len(call.Call.Args) < len(name.FuncType.Params) {
-		return false
+	if len(args) < len(params) {
+		return "", false
 	}
 
 	any := false
-	for i, param := range name.FuncType.Params {
-		if p.needsPointerCheck(f, param.Go, call.Call.Args[i]) {
+	for i, param := range params {
+		if p.needsPointerCheck(f, param.Go, args[i]) {
 			any = true
 			break
 		}
 	}
 	if !any {
-		return false
+		return "", false
 	}
 
 	// We need to rewrite this call.
 	//
-	// We are going to rewrite C.f(p) to
-	//    func (_cgo0 ptype) {
+	// Rewrite C.f(p) to
+	//    func() {
+	//            _cgo0 := p
 	//            _cgoCheckPointer(_cgo0)
 	//            C.f(_cgo0)
-	//    }(p)
-	// Using a function literal like this lets us do correct
-	// argument type checking, and works correctly if the call is
-	// deferred.
+	//    }()
+	// Using a function literal like this lets us evaluate the
+	// function arguments only once while doing pointer checks.
+	// This is particularly useful when passing additional arguments
+	// to _cgoCheckPointer, as done in checkIndex and checkAddr.
+	//
+	// When the function argument is a conversion to unsafe.Pointer,
+	// we unwrap the conversion before checking the pointer,
+	// and then wrap again when calling C.f. This lets us check
+	// the real type of the pointer in some cases. See issue #25941.
+	//
+	// When the call to C.f is deferred, we use an additional function
+	// literal to evaluate the arguments at the right time.
+	//    defer func() func() {
+	//            _cgo0 := p
+	//            return func() {
+	//                    _cgoCheckPointer(_cgo0)
+	//                    C.f(_cgo0)
+	//            }
+	//    }()()
+	// This works because the defer statement evaluates the first
+	// function literal in order to get the function to call.
+
+	var sb bytes.Buffer
+	sb.WriteString("func() ")
+	if call.Deferred {
+		sb.WriteString("func() ")
+	}
+
 	needsUnsafe := false
-	params := make([]*ast.Field, len(name.FuncType.Params))
-	nargs := make([]ast.Expr, len(name.FuncType.Params))
-	var stmts []ast.Stmt
-	for i, param := range name.FuncType.Params {
-		// params is going to become the parameters of the
-		// function literal.
-		// nargs is going to become the list of arguments made
-		// by the call within the function literal.
-		// nparam is the parameter of the function literal that
-		// corresponds to param.
+	result := false
+	twoResults := false
+	if !call.Deferred {
+		// Check whether this call expects two results.
+		for _, ref := range f.Ref {
+			if ref.Expr != &call.Call.Fun {
+				continue
+			}
+			if ref.Context == ctxCall2 {
+				sb.WriteString("(")
+				result = true
+				twoResults = true
+			}
+			break
+		}
 
-		origArg := call.Call.Args[i]
-		nparam := ast.NewIdent(fmt.Sprintf("_cgo%d", i))
-		nargs[i] = nparam
+		// Add the result type, if any.
+		if name.FuncType.Result != nil {
+			rtype := p.rewriteUnsafe(name.FuncType.Result.Go)
+			if rtype != name.FuncType.Result.Go {
+				needsUnsafe = true
+			}
+			sb.WriteString(gofmtLine(rtype))
+			result = true
+		}
 
-		// The Go version of the C type might use unsafe.Pointer,
-		// but the file might not import unsafe.
-		// Rewrite the Go type if necessary to use _cgo_unsafe.
-		ptype := p.rewriteUnsafe(param.Go)
-		if ptype != param.Go {
+		// Add the second result type, if any.
+		if twoResults {
+			if name.FuncType.Result == nil {
+				// An explicit void result looks odd but it
+				// seems to be how cgo has worked historically.
+				sb.WriteString("_Ctype_void")
+			}
+			sb.WriteString(", error)")
+		}
+	}
+
+	sb.WriteString("{ ")
+
+	// Define _cgoN for each argument value.
+	// Write _cgoCheckPointer calls to sbCheck.
+	var sbCheck bytes.Buffer
+	for i, param := range params {
+		origArg := args[i]
+		arg, nu := p.mangle(f, &args[i])
+		if nu {
 			needsUnsafe = true
 		}
 
-		params[i] = &ast.Field{
-			Names: []*ast.Ident{nparam},
-			Type:  ptype,
-		}
+		// Use "var x T = ..." syntax to explicitly convert untyped
+		// constants to the parameter type, to avoid a type mismatch.
+		ptype := p.rewriteUnsafe(param.Go)
 
-		if !p.needsPointerCheck(f, param.Go, origArg) {
+		if !p.needsPointerCheck(f, param.Go, args[i]) || param.BadPointer {
+			if ptype != param.Go {
+				needsUnsafe = true
+			}
+			fmt.Fprintf(&sb, "var _cgo%d %s = %s; ", i,
+				gofmtLine(ptype), gofmtPos(arg, origArg.Pos()))
 			continue
 		}
 
-		// Run the cgo pointer checks on nparam.
-
-		// Change the function literal to call the real function
-		// with the parameter passed through _cgoCheckPointer.
-		c := &ast.CallExpr{
-			Fun: ast.NewIdent("_cgoCheckPointer"),
-			Args: []ast.Expr{
-				nparam,
-			},
+		// Check for &a[i].
+		if p.checkIndex(&sb, &sbCheck, arg, i) {
+			continue
 		}
 
-		// Add optional additional arguments for an address
-		// expression.
-		c.Args = p.checkAddrArgs(f, c.Args, origArg)
-
-		stmt := &ast.ExprStmt{
-			X: c,
+		// Check for &x.
+		if p.checkAddr(&sb, &sbCheck, arg, i) {
+			continue
 		}
-		stmts = append(stmts, stmt)
+
+		fmt.Fprintf(&sb, "_cgo%d := %s; ", i, gofmtPos(arg, origArg.Pos()))
+		fmt.Fprintf(&sbCheck, "_cgoCheckPointer(_cgo%d); ", i)
 	}
 
-	const cgoMarker = "__cgo__###__marker__"
-	fcall := &ast.CallExpr{
-		Fun:  ast.NewIdent(cgoMarker),
-		Args: nargs,
-	}
-	ftype := &ast.FuncType{
-		Params: &ast.FieldList{
-			List: params,
-		},
-	}
-	if name.FuncType.Result != nil {
-		rtype := p.rewriteUnsafe(name.FuncType.Result.Go)
-		if rtype != name.FuncType.Result.Go {
-			needsUnsafe = true
-		}
-		ftype.Results = &ast.FieldList{
-			List: []*ast.Field{
-				&ast.Field{
-					Type: rtype,
-				},
-			},
-		}
+	if call.Deferred {
+		sb.WriteString("return func() { ")
 	}
 
-	// If this call expects two results, we have to
-	// adjust the results of the function we generated.
-	for _, ref := range f.Ref {
-		if ref.Expr == &call.Call.Fun && ref.Context == ctxCall2 {
-			if ftype.Results == nil {
-				// An explicit void argument
-				// looks odd but it seems to
-				// be how cgo has worked historically.
-				ftype.Results = &ast.FieldList{
-					List: []*ast.Field{
-						&ast.Field{
-							Type: ast.NewIdent("_Ctype_void"),
-						},
-					},
-				}
-			}
-			ftype.Results.List = append(ftype.Results.List,
-				&ast.Field{
-					Type: ast.NewIdent("error"),
-				})
-		}
+	// Write out the calls to _cgoCheckPointer.
+	sb.WriteString(sbCheck.String())
+
+	if result {
+		sb.WriteString("return ")
 	}
 
-	var fbody ast.Stmt
-	if ftype.Results == nil {
-		fbody = &ast.ExprStmt{
-			X: fcall,
-		}
-	} else {
-		fbody = &ast.ReturnStmt{
-			Results: []ast.Expr{fcall},
-		}
+	m, nu := p.mangle(f, &call.Call.Fun)
+	if nu {
+		needsUnsafe = true
 	}
-	lit := &ast.FuncLit{
-		Type: ftype,
-		Body: &ast.BlockStmt{
-			List: append(stmts, fbody),
-		},
-	}
-	text := strings.Replace(gofmt(lit), "\n", ";", -1)
-	repl := strings.Split(text, cgoMarker)
-	f.Edit.Insert(f.offset(call.Call.Fun.Pos()), repl[0])
-	f.Edit.Insert(f.offset(call.Call.Fun.End()), repl[1])
+	sb.WriteString(gofmtLine(m))
 
-	return needsUnsafe
+	sb.WriteString("(")
+	for i := range params {
+		if i > 0 {
+			sb.WriteString(", ")
+		}
+		fmt.Fprintf(&sb, "_cgo%d", i)
+	}
+	sb.WriteString("); ")
+	if call.Deferred {
+		sb.WriteString("}")
+	}
+	sb.WriteString("}")
+	if call.Deferred {
+		sb.WriteString("()")
+	}
+	sb.WriteString("()")
+
+	return sb.String(), needsUnsafe
 }
 
-// needsPointerCheck returns whether the type t needs a pointer check.
+// needsPointerCheck reports whether the type t needs a pointer check.
 // This is true if t is a pointer and if the value to which it points
 // might contain a pointer.
 func (p *Package) needsPointerCheck(f *File, t ast.Expr, arg ast.Expr) bool {
@@ -892,7 +978,7 @@
 
 // hasPointer is used by needsPointerCheck. If top is true it returns
 // whether t is or contains a pointer that might point to a pointer.
-// If top is false it returns whether t is or contains a pointer.
+// If top is false it reports whether t is or contains a pointer.
 // f may be nil.
 func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool {
 	switch t := t.(type) {
@@ -979,19 +1065,73 @@
 	}
 }
 
-// checkAddrArgs tries to add arguments to the call of
-// _cgoCheckPointer when the argument is an address expression. We
-// pass true to mean that the argument is an address operation of
-// something other than a slice index, which means that it's only
-// necessary to check the specific element pointed to, not the entire
-// object. This is for &s.f, where f is a field in a struct. We can
-// pass a slice or array, meaning that we should check the entire
-// slice or array but need not check any other part of the object.
-// This is for &s.a[i], where we need to check all of a. However, we
-// only pass the slice or array if we can refer to it without side
-// effects.
-func (p *Package) checkAddrArgs(f *File, args []ast.Expr, x ast.Expr) []ast.Expr {
+// mangle replaces references to C names in arg with the mangled names,
+// rewriting calls when it finds them.
+// It removes the corresponding references in f.Ref and f.Calls, so that we
+// don't try to do the replacement again in rewriteRef or rewriteCall.
+func (p *Package) mangle(f *File, arg *ast.Expr) (ast.Expr, bool) {
+	needsUnsafe := false
+	f.walk(arg, ctxExpr, func(f *File, arg interface{}, context astContext) {
+		px, ok := arg.(*ast.Expr)
+		if !ok {
+			return
+		}
+		sel, ok := (*px).(*ast.SelectorExpr)
+		if ok {
+			if l, ok := sel.X.(*ast.Ident); !ok || l.Name != "C" {
+				return
+			}
+
+			for _, r := range f.Ref {
+				if r.Expr == px {
+					*px = p.rewriteName(f, r)
+					r.Done = true
+					break
+				}
+			}
+
+			return
+		}
+
+		call, ok := (*px).(*ast.CallExpr)
+		if !ok {
+			return
+		}
+
+		for _, c := range f.Calls {
+			if !c.Done && c.Call.Lparen == call.Lparen {
+				cstr, nu := p.rewriteCall(f, c)
+				if cstr != "" {
+					// Smuggle the rewritten call through an ident.
+					*px = ast.NewIdent(cstr)
+					if nu {
+						needsUnsafe = true
+					}
+					c.Done = true
+				}
+			}
+		}
+	})
+	return *arg, needsUnsafe
+}
+
+// checkIndex checks whether arg has the form &a[i], possibly inside
+// type conversions. If so, then in the general case it writes
+//    _cgoIndexNN := a
+//    _cgoNN := &cgoIndexNN[i] // with type conversions, if any
+// to sb, and writes
+//    _cgoCheckPointer(_cgoNN, _cgoIndexNN)
+// to sbCheck, and returns true. If a is a simple variable or field reference,
+// it writes
+//    _cgoIndexNN := &a
+// and dereferences the uses of _cgoIndexNN. Taking the address avoids
+// making a copy of an array.
+//
+// This tells _cgoCheckPointer to check the complete contents of the
+// slice or array being indexed, but no other part of the memory allocation.
+func (p *Package) checkIndex(sb, sbCheck *bytes.Buffer, arg ast.Expr, i int) bool {
 	// Strip type conversions.
+	x := arg
 	for {
 		c, ok := x.(*ast.CallExpr)
 		if !ok || len(c.Args) != 1 || !p.isType(c.Fun) {
@@ -1001,40 +1141,73 @@
 	}
 	u, ok := x.(*ast.UnaryExpr)
 	if !ok || u.Op != token.AND {
-		return args
+		return false
 	}
 	index, ok := u.X.(*ast.IndexExpr)
 	if !ok {
-		// This is the address of something that is not an
-		// index expression. We only need to examine the
-		// single value to which it points.
-		// TODO: what if true is shadowed?
-		return append(args, ast.NewIdent("true"))
+		return false
 	}
-	if !p.hasSideEffects(f, index.X) {
-		// Examine the entire slice.
-		return append(args, index.X)
+
+	addr := ""
+	deref := ""
+	if p.isVariable(index.X) {
+		addr = "&"
+		deref = "*"
 	}
-	// Treat the pointer as unknown.
-	return args
+
+	fmt.Fprintf(sb, "_cgoIndex%d := %s%s; ", i, addr, gofmtPos(index.X, index.X.Pos()))
+	origX := index.X
+	index.X = ast.NewIdent(fmt.Sprintf("_cgoIndex%d", i))
+	if deref == "*" {
+		index.X = &ast.StarExpr{X: index.X}
+	}
+	fmt.Fprintf(sb, "_cgo%d := %s; ", i, gofmtPos(arg, arg.Pos()))
+	index.X = origX
+
+	fmt.Fprintf(sbCheck, "_cgoCheckPointer(_cgo%d, %s_cgoIndex%d); ", i, deref, i)
+
+	return true
 }
 
-// hasSideEffects returns whether the expression x has any side
-// effects.  x is an expression, not a statement, so the only side
-// effect is a function call.
-func (p *Package) hasSideEffects(f *File, x ast.Expr) bool {
-	found := false
-	f.walk(x, ctxExpr,
-		func(f *File, x interface{}, context astContext) {
-			switch x.(type) {
-			case *ast.CallExpr:
-				found = true
-			}
-		})
-	return found
+// checkAddr checks whether arg has the form &x, possibly inside type
+// conversions. If so, it writes
+//    _cgoBaseNN := &x
+//    _cgoNN := _cgoBaseNN // with type conversions, if any
+// to sb, and writes
+//    _cgoCheckPointer(_cgoBaseNN, true)
+// to sbCheck, and returns true. This tells _cgoCheckPointer to check
+// just the contents of the pointer being passed, not any other part
+// of the memory allocation. This is run after checkIndex, which looks
+// for the special case of &a[i], which requires different checks.
+func (p *Package) checkAddr(sb, sbCheck *bytes.Buffer, arg ast.Expr, i int) bool {
+	// Strip type conversions.
+	px := &arg
+	for {
+		c, ok := (*px).(*ast.CallExpr)
+		if !ok || len(c.Args) != 1 || !p.isType(c.Fun) {
+			break
+		}
+		px = &c.Args[0]
+	}
+	if u, ok := (*px).(*ast.UnaryExpr); !ok || u.Op != token.AND {
+		return false
+	}
+
+	fmt.Fprintf(sb, "_cgoBase%d := %s; ", i, gofmtPos(*px, (*px).Pos()))
+
+	origX := *px
+	*px = ast.NewIdent(fmt.Sprintf("_cgoBase%d", i))
+	fmt.Fprintf(sb, "_cgo%d := %s; ", i, gofmtPos(arg, arg.Pos()))
+	*px = origX
+
+	// Use "0 == 0" to do the right thing in the unlikely event
+	// that "true" is shadowed.
+	fmt.Fprintf(sbCheck, "_cgoCheckPointer(_cgoBase%d, 0 == 0); ", i)
+
+	return true
 }
 
-// isType returns whether the expression is definitely a type.
+// isType reports whether the expression is definitely a type.
 // This is conservative--it returns false for an unknown identifier.
 func (p *Package) isType(t ast.Expr) bool {
 	switch t := t.(type) {
@@ -1063,6 +1236,9 @@
 
 			return true
 		}
+		if strings.HasPrefix(t.Name, "_Ctype_") {
+			return true
+		}
 	case *ast.StarExpr:
 		return p.isType(t.X)
 	case *ast.ArrayType, *ast.StructType, *ast.FuncType, *ast.InterfaceType,
@@ -1073,6 +1249,17 @@
 	return false
 }
 
+// isVariable reports whether x is a variable, possibly with field references.
+func (p *Package) isVariable(x ast.Expr) bool {
+	switch x := x.(type) {
+	case *ast.Ident:
+		return true
+	case *ast.SelectorExpr:
+		return p.isVariable(x.X)
+	}
+	return false
+}
+
 // rewriteUnsafe returns a version of t with references to unsafe.Pointer
 // rewritten to use _cgo_unsafe.Pointer instead.
 func (p *Package) rewriteUnsafe(t ast.Expr) ast.Expr {
@@ -1131,24 +1318,7 @@
 	// code for them.
 	functions := make(map[string]bool)
 
-	// Assign mangled names.
 	for _, n := range f.Name {
-		if n.Kind == "not-type" {
-			if n.Define == "" {
-				n.Kind = "var"
-			} else {
-				n.Kind = "macro"
-				n.FuncType = &FuncType{
-					Result: n.Type,
-					Go: &ast.FuncType{
-						Results: &ast.FieldList{List: []*ast.Field{{Type: n.Type.Go}}},
-					},
-				}
-			}
-		}
-		if n.Mangle == "" {
-			p.mangleName(n)
-		}
 		if n.Kind == "func" {
 			functions[n.Go] = false
 		}
@@ -1162,104 +1332,16 @@
 		if r.Name.IsConst() && r.Name.Const == "" {
 			error_(r.Pos(), "unable to find value of constant C.%s", fixGo(r.Name.Go))
 		}
-		var expr ast.Expr = ast.NewIdent(r.Name.Mangle) // default
-		switch r.Context {
-		case ctxCall, ctxCall2:
-			if r.Name.Kind != "func" {
-				if r.Name.Kind == "type" {
-					r.Context = ctxType
-					if r.Name.Type == nil {
-						error_(r.Pos(), "invalid conversion to C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C)
-						break
-					}
-					expr = r.Name.Type.Go
-					break
-				}
-				error_(r.Pos(), "call of non-function C.%s", fixGo(r.Name.Go))
-				break
-			}
-			functions[r.Name.Go] = true
-			if r.Context == ctxCall2 {
-				if r.Name.Go == "_CMalloc" {
-					error_(r.Pos(), "no two-result form for C.malloc")
-					break
-				}
-				// Invent new Name for the two-result function.
-				n := f.Name["2"+r.Name.Go]
-				if n == nil {
-					n = new(Name)
-					*n = *r.Name
-					n.AddError = true
-					n.Mangle = "_C2func_" + n.Go
-					f.Name["2"+r.Name.Go] = n
-				}
-				expr = ast.NewIdent(n.Mangle)
-				r.Name = n
-				break
-			}
-		case ctxExpr:
-			switch r.Name.Kind {
-			case "func":
-				if builtinDefs[r.Name.C] != "" {
-					error_(r.Pos(), "use of builtin '%s' not in function call", fixGo(r.Name.C))
-				}
 
-				// Function is being used in an expression, to e.g. pass around a C function pointer.
-				// Create a new Name for this Ref which causes the variable to be declared in Go land.
-				fpName := "fp_" + r.Name.Go
-				name := f.Name[fpName]
-				if name == nil {
-					name = &Name{
-						Go:   fpName,
-						C:    r.Name.C,
-						Kind: "fpvar",
-						Type: &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("void*"), Go: ast.NewIdent("unsafe.Pointer")},
-					}
-					p.mangleName(name)
-					f.Name[fpName] = name
-				}
-				r.Name = name
-				// Rewrite into call to _Cgo_ptr to prevent assignments. The _Cgo_ptr
-				// function is defined in out.go and simply returns its argument. See
-				// issue 7757.
-				expr = &ast.CallExpr{
-					Fun:  &ast.Ident{NamePos: (*r.Expr).Pos(), Name: "_Cgo_ptr"},
-					Args: []ast.Expr{ast.NewIdent(name.Mangle)},
-				}
-			case "type":
-				// Okay - might be new(T)
-				if r.Name.Type == nil {
-					error_(r.Pos(), "expression C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C)
-					break
-				}
-				expr = r.Name.Type.Go
-			case "var":
-				expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr}
-			case "macro":
-				expr = &ast.CallExpr{Fun: expr}
-			}
-		case ctxSelector:
-			if r.Name.Kind == "var" {
-				expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr}
-			} else {
-				error_(r.Pos(), "only C variables allowed in selector expression %s", fixGo(r.Name.Go))
-			}
-		case ctxType:
-			if r.Name.Kind != "type" {
-				error_(r.Pos(), "expression C.%s used as type", fixGo(r.Name.Go))
-			} else if r.Name.Type == nil {
-				// Use of C.enum_x, C.struct_x or C.union_x without C definition.
-				// GCC won't raise an error when using pointers to such unknown types.
-				error_(r.Pos(), "type C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C)
-			} else {
-				expr = r.Name.Type.Go
-			}
-		default:
-			if r.Name.Kind == "func" {
-				error_(r.Pos(), "must call C.%s", fixGo(r.Name.Go))
+		if r.Name.Kind == "func" {
+			switch r.Context {
+			case ctxCall, ctxCall2:
+				functions[r.Name.Go] = true
 			}
 		}
 
+		expr := p.rewriteName(f, r)
+
 		if *godefs {
 			// Substitute definition for mangled type name.
 			if id, ok := expr.(*ast.Ident); ok {
@@ -1276,8 +1358,7 @@
 		// in case expression being replaced is first on line.
 		// See golang.org/issue/6563.
 		pos := (*r.Expr).Pos()
-		switch x := expr.(type) {
-		case *ast.Ident:
+		if x, ok := expr.(*ast.Ident); ok {
 			expr = &ast.Ident{NamePos: pos, Name: x.Name}
 		}
 
@@ -1287,11 +1368,26 @@
 		*r.Expr = expr
 
 		// Record source-level edit for cgo output.
-		repl := gofmt(expr)
-		if r.Name.Kind != "type" {
-			repl = "(" + repl + ")"
+		if !r.Done {
+			// Prepend a space in case the earlier code ends
+			// with '/', which would give us a "//" comment.
+			repl := " " + gofmtPos(expr, old.Pos())
+			end := fset.Position(old.End())
+			// Subtract 1 from the column if we are going to
+			// append a close parenthesis. That will set the
+			// correct column for the following characters.
+			sub := 0
+			if r.Name.Kind != "type" {
+				sub = 1
+			}
+			if end.Column > sub {
+				repl = fmt.Sprintf("%s /*line :%d:%d*/", repl, end.Line, end.Column-sub)
+			}
+			if r.Name.Kind != "type" {
+				repl = "(" + repl + ")"
+			}
+			f.Edit.Replace(f.offset(old.Pos()), f.offset(old.End()), repl)
 		}
-		f.Edit.Replace(f.offset(old.Pos()), f.offset(old.End()), repl)
 	}
 
 	// Remove functions only used as expressions, so their respective
@@ -1303,6 +1399,118 @@
 	}
 }
 
+// rewriteName returns the expression used to rewrite a reference.
+func (p *Package) rewriteName(f *File, r *Ref) ast.Expr {
+	var expr ast.Expr = ast.NewIdent(r.Name.Mangle) // default
+	switch r.Context {
+	case ctxCall, ctxCall2:
+		if r.Name.Kind != "func" {
+			if r.Name.Kind == "type" {
+				r.Context = ctxType
+				if r.Name.Type == nil {
+					error_(r.Pos(), "invalid conversion to C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C)
+					break
+				}
+				expr = r.Name.Type.Go
+				break
+			}
+			error_(r.Pos(), "call of non-function C.%s", fixGo(r.Name.Go))
+			break
+		}
+		if r.Context == ctxCall2 {
+			if r.Name.Go == "_CMalloc" {
+				error_(r.Pos(), "no two-result form for C.malloc")
+				break
+			}
+			// Invent new Name for the two-result function.
+			n := f.Name["2"+r.Name.Go]
+			if n == nil {
+				n = new(Name)
+				*n = *r.Name
+				n.AddError = true
+				n.Mangle = "_C2func_" + n.Go
+				f.Name["2"+r.Name.Go] = n
+			}
+			expr = ast.NewIdent(n.Mangle)
+			r.Name = n
+			break
+		}
+	case ctxExpr:
+		switch r.Name.Kind {
+		case "func":
+			if builtinDefs[r.Name.C] != "" {
+				error_(r.Pos(), "use of builtin '%s' not in function call", fixGo(r.Name.C))
+			}
+
+			// Function is being used in an expression, to e.g. pass around a C function pointer.
+			// Create a new Name for this Ref which causes the variable to be declared in Go land.
+			fpName := "fp_" + r.Name.Go
+			name := f.Name[fpName]
+			if name == nil {
+				name = &Name{
+					Go:   fpName,
+					C:    r.Name.C,
+					Kind: "fpvar",
+					Type: &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("void*"), Go: ast.NewIdent("unsafe.Pointer")},
+				}
+				p.mangleName(name)
+				f.Name[fpName] = name
+			}
+			r.Name = name
+			// Rewrite into call to _Cgo_ptr to prevent assignments. The _Cgo_ptr
+			// function is defined in out.go and simply returns its argument. See
+			// issue 7757.
+			expr = &ast.CallExpr{
+				Fun:  &ast.Ident{NamePos: (*r.Expr).Pos(), Name: "_Cgo_ptr"},
+				Args: []ast.Expr{ast.NewIdent(name.Mangle)},
+			}
+		case "type":
+			// Okay - might be new(T)
+			if r.Name.Type == nil {
+				error_(r.Pos(), "expression C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C)
+				break
+			}
+			expr = r.Name.Type.Go
+		case "var":
+			expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr}
+		case "macro":
+			expr = &ast.CallExpr{Fun: expr}
+		}
+	case ctxSelector:
+		if r.Name.Kind == "var" {
+			expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr}
+		} else {
+			error_(r.Pos(), "only C variables allowed in selector expression %s", fixGo(r.Name.Go))
+		}
+	case ctxType:
+		if r.Name.Kind != "type" {
+			error_(r.Pos(), "expression C.%s used as type", fixGo(r.Name.Go))
+		} else if r.Name.Type == nil {
+			// Use of C.enum_x, C.struct_x or C.union_x without C definition.
+			// GCC won't raise an error when using pointers to such unknown types.
+			error_(r.Pos(), "type C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C)
+		} else {
+			expr = r.Name.Type.Go
+		}
+	default:
+		if r.Name.Kind == "func" {
+			error_(r.Pos(), "must call C.%s", fixGo(r.Name.Go))
+		}
+	}
+	return expr
+}
+
+// gofmtPos returns the gofmt-formatted string for an AST node,
+// with a comment setting the position before the node.
+func gofmtPos(n ast.Expr, pos token.Pos) string {
+	s := gofmtLine(n)
+	p := fset.Position(pos)
+	if p.Column == 0 {
+		return s
+	}
+	return fmt.Sprintf("/*line :%d:%d*/%s", p.Line, p.Column, s)
+}
+
 // gccBaseCmd returns the start of the compiler command line.
 // It uses $CC if set, or else $GCC, or else the compiler recorded
 // during the initial build as defaultCC.
@@ -1377,6 +1585,9 @@
 
 	c = append(c, p.GccOptions...)
 	c = append(c, p.gccMachine()...)
+	if goos == "aix" {
+		c = append(c, "-maix64")
+	}
 	c = append(c, "-") //read input from standard input
 	return c
 }
@@ -1663,7 +1874,77 @@
 		return d, ints, floats, strs
 	}
 
-	fatalf("cannot parse gcc output %s as ELF, Mach-O, PE object", gccTmp())
+	if f, err := xcoff.Open(gccTmp()); err == nil {
+		defer f.Close()
+		d, err := f.DWARF()
+		if err != nil {
+			fatalf("cannot load DWARF output from %s: %v", gccTmp(), err)
+		}
+		bo := binary.BigEndian
+		for _, s := range f.Symbols {
+			switch {
+			case isDebugInts(s.Name):
+				if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+					sect := f.Sections[i]
+					if s.Value < sect.Size {
+						if sdat, err := sect.Data(); err == nil {
+							data := sdat[s.Value:]
+							ints = make([]int64, len(data)/8)
+							for i := range ints {
+								ints[i] = int64(bo.Uint64(data[i*8:]))
+							}
+						}
+					}
+				}
+			case isDebugFloats(s.Name):
+				if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+					sect := f.Sections[i]
+					if s.Value < sect.Size {
+						if sdat, err := sect.Data(); err == nil {
+							data := sdat[s.Value:]
+							floats = make([]float64, len(data)/8)
+							for i := range floats {
+								floats[i] = math.Float64frombits(bo.Uint64(data[i*8:]))
+							}
+						}
+					}
+				}
+			default:
+				if n := indexOfDebugStr(s.Name); n != -1 {
+					if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+						sect := f.Sections[i]
+						if s.Value < sect.Size {
+							if sdat, err := sect.Data(); err == nil {
+								data := sdat[s.Value:]
+								strdata[n] = string(data)
+							}
+						}
+					}
+					break
+				}
+				if n := indexOfDebugStrlen(s.Name); n != -1 {
+					if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
+						sect := f.Sections[i]
+						if s.Value < sect.Size {
+							if sdat, err := sect.Data(); err == nil {
+								data := sdat[s.Value:]
+								strlen := bo.Uint64(data[:8])
+								if strlen > (1<<(uint(p.IntSize*8)-1) - 1) { // greater than MaxInt?
+									fatalf("string literal too big")
+								}
+								strlens[n] = int(strlen)
+							}
+						}
+					}
+					break
+				}
+			}
+		}
+
+		buildStrings()
+		return d, ints, floats, strs
+	}
+	fatalf("cannot parse gcc output %s as ELF, Mach-O, PE, XCOFF object", gccTmp())
 	panic("not reached")
 }
 
@@ -1693,6 +1974,11 @@
 		}
 	}
 
+	// Force -O0 optimization but keep the trailing "-" at the end.
+	nargs = append(nargs, "-O0")
+	nl := len(nargs)
+	nargs[nl-2], nargs[nl-1] = nargs[nl-1], nargs[nl-2]
+
 	if *debugGcc {
 		fmt.Fprintf(os.Stderr, "$ %s <<EOF\n", strings.Join(nargs, " "))
 		os.Stderr.Write(stdin)
@@ -1734,10 +2020,10 @@
 // with equivalent memory layout.
 type typeConv struct {
 	// Cache of already-translated or in-progress types.
-	m map[dwarf.Type]*Type
+	m map[string]*Type
 
 	// Map from types to incomplete pointers to those types.
-	ptrs map[dwarf.Type][]*Type
+	ptrs map[string][]*Type
 	// Keys of ptrs in insertion order (deterministic worklist)
 	// ptrKeys contains exactly the keys in ptrs.
 	ptrKeys []dwarf.Type
@@ -1772,8 +2058,8 @@
 func (c *typeConv) Init(ptrSize, intSize int64) {
 	c.ptrSize = ptrSize
 	c.intSize = intSize
-	c.m = make(map[dwarf.Type]*Type)
-	c.ptrs = make(map[dwarf.Type][]*Type)
+	c.m = make(map[string]*Type)
+	c.ptrs = make(map[string][]*Type)
 	c.getTypeIDs = make(map[string]bool)
 	c.bool = c.Ident("bool")
 	c.byte = c.Ident("byte")
@@ -1881,11 +2167,12 @@
 	// Keep looping until they're all done.
 	for len(c.ptrKeys) > 0 {
 		dtype := c.ptrKeys[0]
+		dtypeKey := dtype.String()
 		c.ptrKeys = c.ptrKeys[1:]
-		ptrs := c.ptrs[dtype]
-		delete(c.ptrs, dtype)
+		ptrs := c.ptrs[dtypeKey]
+		delete(c.ptrs, dtypeKey)
 
-		// Note Type might invalidate c.ptrs[dtype].
+		// Note Type might invalidate c.ptrs[dtypeKey].
 		t := c.Type(dtype, pos)
 		for _, ptr := range ptrs {
 			ptr.Go.(*ast.StarExpr).X = t.Go
@@ -1897,18 +2184,29 @@
 // Type returns a *Type with the same memory layout as
 // dtype when used as the type of a variable or a struct field.
 func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
-	if t, ok := c.m[dtype]; ok {
-		if t.Go == nil {
-			fatalf("%s: type conversion loop at %s", lineno(pos), dtype)
+	// Always recompute bad pointer typedefs, as the set of such
+	// typedefs changes as we see more types.
+	checkCache := true
+	if dtt, ok := dtype.(*dwarf.TypedefType); ok && c.badPointerTypedef(dtt) {
+		checkCache = false
+	}
+
+	key := dtype.String()
+
+	if checkCache {
+		if t, ok := c.m[key]; ok {
+			if t.Go == nil {
+				fatalf("%s: type conversion loop at %s", lineno(pos), dtype)
+			}
+			return t
 		}
-		return t
 	}
 
 	t := new(Type)
 	t.Size = dtype.Size() // note: wrong for array of pointers, corrected below
 	t.Align = -1
 	t.C = &TypeRepr{Repr: dtype.Common().Name}
-	c.m[dtype] = t
+	c.m[key] = t
 
 	switch dt := dtype.(type) {
 	default:
@@ -2071,10 +2369,11 @@
 		// Placeholder initialization; completed in FinishType.
 		t.Go = &ast.StarExpr{}
 		t.C.Set("<incomplete>*")
-		if _, ok := c.ptrs[dt.Type]; !ok {
+		key := dt.Type.String()
+		if _, ok := c.ptrs[key]; !ok {
 			c.ptrKeys = append(c.ptrKeys, dt.Type)
 		}
-		c.ptrs[dt.Type] = append(c.ptrs[dt.Type], t)
+		c.ptrs[key] = append(c.ptrs[key], t)
 
 	case *dwarf.QualType:
 		t1 := c.Type(dt.Type, pos)
@@ -2166,13 +2465,16 @@
 			// Treat this typedef as a uintptr.
 			s := *sub
 			s.Go = c.uintptr
+			s.BadPointer = true
 			sub = &s
 			// Make sure we update any previously computed type.
 			if oldType := typedef[name.Name]; oldType != nil {
 				oldType.Go = sub.Go
+				oldType.BadPointer = true
 			}
 		}
 		t.Go = name
+		t.BadPointer = sub.BadPointer
 		if unionWithPointer[sub.Go] {
 			unionWithPointer[t.Go] = true
 		}
@@ -2182,6 +2484,7 @@
 		if oldType == nil {
 			tt := *t
 			tt.Go = sub.Go
+			tt.BadPointer = sub.BadPointer
 			typedef[name.Name] = &tt
 		}
 
@@ -2462,11 +2765,6 @@
 
 	anon := 0
 	for _, f := range dt.Field {
-		if f.ByteOffset > off {
-			fld, sizes = c.pad(fld, sizes, f.ByteOffset-off)
-			off = f.ByteOffset
-		}
-
 		name := f.Name
 		ft := f.Type
 
@@ -2515,6 +2813,19 @@
 			// structs are in system headers that cannot be corrected.
 			continue
 		}
+
+		// Round off up to talign, assumed to be a power of 2.
+		off = (off + talign - 1) &^ (talign - 1)
+
+		if f.ByteOffset > off {
+			fld, sizes = c.pad(fld, sizes, f.ByteOffset-off)
+			off = f.ByteOffset
+		}
+		if f.ByteOffset < off {
+			// Drop a packed field that we can't represent.
+			continue
+		}
+
 		n := len(fld)
 		fld = fld[0 : n+1]
 		if name == "" {
@@ -2564,7 +2875,7 @@
 	return
 }
 
-// dwarfHasPointer returns whether the DWARF type dt contains a pointer.
+// dwarfHasPointer reports whether the DWARF type dt contains a pointer.
 func (c *typeConv) dwarfHasPointer(dt dwarf.Type, pos token.Pos) bool {
 	switch dt := dt.(type) {
 	default:
@@ -2681,6 +2992,9 @@
 	if c.badJNI(dt) {
 		return true
 	}
+	if c.badEGLDisplay(dt) {
+		return true
+	}
 	return false
 }
 
@@ -2817,6 +3131,19 @@
 	return false
 }
 
+func (c *typeConv) badEGLDisplay(dt *dwarf.TypedefType) bool {
+	if dt.Name != "EGLDisplay" {
+		return false
+	}
+	// Check that the typedef is "typedef void *EGLDisplay".
+	if ptr, ok := dt.Type.(*dwarf.PtrType); ok {
+		if _, ok := ptr.Type.(*dwarf.VoidType); ok {
+			return true
+		}
+	}
+	return false
+}
+
 // jniTypes maps from JNI types that we want to be uintptrs, to the underlying type to which
 // they are mapped. The base "jobject" maps to the empty string.
 var jniTypes = map[string]string{
diff --git a/src/cmd/cgo/godefs.go b/src/cmd/cgo/godefs.go
index 6720945..64384a6 100644
--- a/src/cmd/cgo/godefs.go
+++ b/src/cmd/cgo/godefs.go
@@ -126,3 +126,36 @@
 	}
 	return gofmtBuf.String()
 }
+
+// gofmtLineReplacer is used to put a gofmt-formatted string for an
+// AST expression onto a single line. The lexer normally inserts a
+// semicolon at each newline, so we can replace newline with semicolon.
+// However, we can't do that in cases where the lexer would not insert
+// a semicolon. We only have to worry about cases that can occur in an
+// expression passed through gofmt, which means composite literals and
+// (due to the printer possibly inserting newlines because of position
+// information) operators.
+var gofmtLineReplacer = strings.NewReplacer(
+	"{\n", "{",
+	",\n", ",",
+	"++\n", "++;",
+	"--\n", "--;",
+	"+\n", "+",
+	"-\n", "-",
+	"*\n", "*",
+	"/\n", "/",
+	"%\n", "%",
+	"&\n", "&",
+	"|\n", "|",
+	"^\n", "^",
+	"<\n", "<",
+	">\n", ">",
+	"=\n", "=",
+	"\n", ";",
+)
+
+// gofmtLine returns the gofmt-formatted string for an AST node,
+// ensuring that it is on a single line.
+func gofmtLine(n interface{}) string {
+	return gofmtLineReplacer.Replace(gofmt(n))
+}
diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go
index b6f0590..5a7bb3f 100644
--- a/src/cmd/cgo/main.go
+++ b/src/cmd/cgo/main.go
@@ -47,7 +47,14 @@
 	GccFiles    []string        // list of gcc output files
 	Preamble    string          // collected preamble for _cgo_export.h
 	typedefs    map[string]bool // type names that appear in the types of the objects we're interested in
-	typedefList []string
+	typedefList []typedefInfo
+}
+
+// A typedefInfo is an element on Package.typedefList: a typedef name
+// and the position where it was required.
+type typedefInfo struct {
+	typedef string
+	pos     token.Pos
 }
 
 // A File collects information about a single Go input file.
@@ -81,6 +88,7 @@
 type Call struct {
 	Call     *ast.CallExpr
 	Deferred bool
+	Done     bool
 }
 
 // A Ref refers to an expression of the form C.xxx in the AST.
@@ -88,19 +96,22 @@
 	Name    *Name
 	Expr    *ast.Expr
 	Context astContext
+	Done    bool
 }
 
 func (r *Ref) Pos() token.Pos {
 	return (*r.Expr).Pos()
 }
 
+var nameKinds = []string{"iconst", "fconst", "sconst", "type", "var", "fpvar", "func", "macro", "not-type"}
+
 // A Name collects information about C.xxx.
 type Name struct {
 	Go       string // name used in Go referring to package C
 	Mangle   string // name used in generated Go
 	C        string // name used in C
 	Define   string // #define expansion
-	Kind     string // "iconst", "fconst", "sconst", "type", "var", "fpvar", "func", "macro", "not-type"
+	Kind     string // one of the nameKinds
 	Type     *Type  // the type of xxx
 	FuncType *FuncType
 	AddError bool
@@ -140,6 +151,7 @@
 	Go         ast.Expr
 	EnumValues map[string]int64
 	Typedef    string
+	BadPointer bool
 }
 
 // A FuncType collects information about a function type in both the C and Go worlds.
@@ -211,6 +223,8 @@
 var gccgo = flag.Bool("gccgo", false, "generate files for use with gccgo")
 var gccgoprefix = flag.String("gccgoprefix", "", "-fgo-prefix option used with gccgo")
 var gccgopkgpath = flag.String("gccgopkgpath", "", "-fgo-pkgpath option used with gccgo")
+var gccgoMangleCheckDone bool
+var gccgoNewmanglingInEffect bool
 var importRuntimeCgo = flag.Bool("import_runtime_cgo", true, "import runtime/cgo in generated code")
 var importSyscall = flag.Bool("import_syscall", true, "import syscall in generated code")
 var goarch, goos string
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index 89598c9..0cf8b17 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -13,8 +13,11 @@
 	"go/ast"
 	"go/printer"
 	"go/token"
+	"internal/xcoff"
 	"io"
+	"io/ioutil"
 	"os"
+	"os/exec"
 	"path/filepath"
 	"regexp"
 	"sort"
@@ -243,7 +246,22 @@
 
 	init := gccgoInit.String()
 	if init != "" {
-		fmt.Fprintln(fc, "static void init(void) __attribute__ ((constructor));")
+		// The init function does nothing but simple
+		// assignments, so it won't use much stack space, so
+		// it's OK to not split the stack. Splitting the stack
+		// can run into a bug in clang (as of 2018-11-09):
+		// this is a leaf function, and when clang sees a leaf
+		// function it won't emit the split stack prologue for
+		// the function. However, if this function refers to a
+		// non-split-stack function, which will happen if the
+		// cgo code refers to a C function not compiled with
+		// -fsplit-stack, then the linker will think that it
+		// needs to adjust the split stack prologue, but there
+		// won't be one. Marking the function explicitly
+		// no_split_stack works around this problem by telling
+		// the linker that it's OK if there is no split stack
+		// prologue.
+		fmt.Fprintln(fc, "static void init(void) __attribute__ ((constructor, no_split_stack));")
 		fmt.Fprintln(fc, "static void init(void) {")
 		fmt.Fprint(fc, init)
 		fmt.Fprintln(fc, "}")
@@ -312,7 +330,25 @@
 		return
 	}
 
-	fatalf("cannot parse %s as ELF, Mach-O or PE", obj)
+	if f, err := xcoff.Open(obj); err == nil {
+		sym, err := f.ImportedSymbols()
+		if err != nil {
+			fatalf("cannot load imported symbols from XCOFF file %s: %v", obj, err)
+		}
+		for _, s := range sym {
+			fmt.Fprintf(stdout, "//go:cgo_import_dynamic %s %s %q\n", s.Name, s.Name, s.Library)
+		}
+		lib, err := f.ImportedLibraries()
+		if err != nil {
+			fatalf("cannot load imported libraries from XCOFF file %s: %v", obj, err)
+		}
+		for _, l := range lib {
+			fmt.Fprintf(stdout, "//go:cgo_import_dynamic _ _ %q\n", l)
+		}
+		return
+	}
+
+	fatalf("cannot parse %s as ELF, Mach-O, PE or XCOFF", obj)
 }
 
 // Construct a gcc struct matching the gc argument frame.
@@ -740,6 +776,13 @@
 	fmt.Fprintf(fgcc, "#include <stdlib.h>\n")
 	fmt.Fprintf(fgcc, "#include \"_cgo_export.h\"\n\n")
 
+	// We use packed structs, but they are always aligned.
+	// The pragmas and address-of-packed-member are not recognized as warning groups in clang 3.4.1, so ignore unknown pragmas first.
+	// remove as part of #27619 (all: drop support for FreeBSD 10).
+	fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n")
+	fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n")
+	fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n")
+
 	fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *, int, __SIZE_TYPE__), void *, int, __SIZE_TYPE__);\n")
 	fmt.Fprintf(fgcc, "extern __SIZE_TYPE__ _cgo_wait_runtime_init_done();\n")
 	fmt.Fprintf(fgcc, "extern void _cgo_release_context(__SIZE_TYPE__);\n\n")
@@ -1167,12 +1210,91 @@
 	fmt.Fprintf(fgcch, "%s\n", p.gccExportHeaderProlog())
 }
 
-// Return the package prefix when using gccgo.
-func (p *Package) gccgoSymbolPrefix() string {
-	if !*gccgo {
-		return ""
+// gccgoUsesNewMangling reports whether gccgo uses the new collision-free
+// packagepath mangling scheme (see determineGccgoManglingScheme for more
+// info).
+func gccgoUsesNewMangling() bool {
+	if !gccgoMangleCheckDone {
+		gccgoNewmanglingInEffect = determineGccgoManglingScheme()
+		gccgoMangleCheckDone = true
+	}
+	return gccgoNewmanglingInEffect
+}
+
+const mangleCheckCode = `
+package läufer
+func Run(x int) int {
+  return 1
+}
+`
+
+// determineGccgoManglingScheme performs a runtime test to see which
+// flavor of packagepath mangling gccgo is using. Older versions of
+// gccgo use a simple mangling scheme where there can be collisions
+// between packages whose paths are different but mangle to the same
+// string. More recent versions of gccgo use a new mangler that avoids
+// these collisions. Return value is whether gccgo uses the new mangling.
+func determineGccgoManglingScheme() bool {
+
+	// Emit a small Go file for gccgo to compile.
+	filepat := "*_gccgo_manglecheck.go"
+	var f *os.File
+	var err error
+	if f, err = ioutil.TempFile(*objDir, filepat); err != nil {
+		fatalf("%v", err)
+	}
+	gofilename := f.Name()
+	defer os.Remove(gofilename)
+
+	if err = ioutil.WriteFile(gofilename, []byte(mangleCheckCode), 0666); err != nil {
+		fatalf("%v", err)
 	}
 
+	// Compile with gccgo, capturing generated assembly.
+	gccgocmd := os.Getenv("GCCGO")
+	if gccgocmd == "" {
+		gpath, gerr := exec.LookPath("gccgo")
+		if gerr != nil {
+			fatalf("unable to locate gccgo: %v", gerr)
+		}
+		gccgocmd = gpath
+	}
+	cmd := exec.Command(gccgocmd, "-S", "-o", "-", gofilename)
+	buf, cerr := cmd.CombinedOutput()
+	if cerr != nil {
+		fatalf("%s", cerr)
+	}
+
+	// New mangling: expect go.l..u00e4ufer.Run
+	// Old mangling: expect go.l__ufer.Run
+	return regexp.MustCompile(`go\.l\.\.u00e4ufer\.Run`).Match(buf)
+}
+
+// gccgoPkgpathToSymbolNew converts a package path to a gccgo-style
+// package symbol.
+func gccgoPkgpathToSymbolNew(ppath string) string {
+	bsl := []byte{}
+	changed := false
+	for _, c := range []byte(ppath) {
+		switch {
+		case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z',
+			'0' <= c && c <= '9', c == '_', c == '.':
+			bsl = append(bsl, c)
+		default:
+			changed = true
+			encbytes := []byte(fmt.Sprintf("..z%02x", c))
+			bsl = append(bsl, encbytes...)
+		}
+	}
+	if !changed {
+		return ppath
+	}
+	return string(bsl)
+}
+
+// gccgoPkgpathToSymbolOld converts a package path to a gccgo-style
+// package symbol using the older mangling scheme.
+func gccgoPkgpathToSymbolOld(ppath string) string {
 	clean := func(r rune) rune {
 		switch {
 		case 'A' <= r && r <= 'Z', 'a' <= r && r <= 'z',
@@ -1181,14 +1303,32 @@
 		}
 		return '_'
 	}
+	return strings.Map(clean, ppath)
+}
+
+// gccgoPkgpathToSymbol converts a package path to a mangled packagepath
+// symbol.
+func gccgoPkgpathToSymbol(ppath string) string {
+	if gccgoUsesNewMangling() {
+		return gccgoPkgpathToSymbolNew(ppath)
+	} else {
+		return gccgoPkgpathToSymbolOld(ppath)
+	}
+}
+
+// Return the package prefix when using gccgo.
+func (p *Package) gccgoSymbolPrefix() string {
+	if !*gccgo {
+		return ""
+	}
 
 	if *gccgopkgpath != "" {
-		return strings.Map(clean, *gccgopkgpath)
+		return gccgoPkgpathToSymbol(*gccgopkgpath)
 	}
 	if *gccgoprefix == "" && p.PackageName == "main" {
 		return "main"
 	}
-	prefix := strings.Map(clean, *gccgoprefix)
+	prefix := gccgoPkgpathToSymbol(*gccgoprefix)
 	if prefix == "" {
 		prefix = "go"
 	}
@@ -1340,6 +1480,14 @@
 
 extern char* _cgo_topofstack(void);
 
+/* We use packed structs, but they are always aligned.  */
+/* The pragmas and address-of-packed-member are not recognized as warning groups in clang 3.4.1, so ignore unknown pragmas first. */
+/* remove as part of #27619 (all: drop support for FreeBSD 10). */
+
+#pragma GCC diagnostic ignored "-Wunknown-pragmas"
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+
 #include <errno.h>
 #include <string.h>
 `
@@ -1422,6 +1570,7 @@
 /* Define intgo when compiling with GCC.  */
 typedef ptrdiff_t intgo;
 
+#define GO_CGO_GOSTRING_TYPEDEF
 typedef struct { const char *p; intgo n; } _GoString_;
 typedef struct { char *p; intgo n; intgo c; } _GoBytes_;
 _GoString_ GoString(char *p);
@@ -1432,7 +1581,7 @@
 void *_CMalloc(size_t);
 
 __attribute__ ((unused))
-static size_t _GoStringLen(_GoString_ s) { return s.n; }
+static size_t _GoStringLen(_GoString_ s) { return (size_t)s.n; }
 
 __attribute__ ((unused))
 static const char *_GoStringPtr(_GoString_ s) { return s.p; }
@@ -1673,15 +1822,20 @@
 // because _cgo_export.h defines GoString as a struct while builtinProlog
 // defines it as a function. We don't change this to avoid unnecessarily
 // breaking existing code.
+// The test of GO_CGO_GOSTRING_TYPEDEF avoids a duplicate definition
+// error if a Go file with a cgo comment #include's the export header
+// generated by a different package.
 const builtinExportProlog = `
-#line 1 "cgo-builtin-prolog"
+#line 1 "cgo-builtin-export-prolog"
 
 #include <stddef.h> /* for ptrdiff_t below */
 
 #ifndef GO_CGO_EXPORT_PROLOGUE_H
 #define GO_CGO_EXPORT_PROLOGUE_H
 
+#ifndef GO_CGO_GOSTRING_TYPEDEF
 typedef struct { const char *p; ptrdiff_t n; } _GoString_;
+#endif
 
 #endif
 `
@@ -1690,6 +1844,19 @@
 	return strings.Replace(gccExportHeaderProlog, "GOINTBITS", fmt.Sprint(8*p.IntSize), -1)
 }
 
+// gccExportHeaderProlog is written to the exported header, after the
+// import "C" comment preamble but before the generated declarations
+// of exported functions. This permits the generated declarations to
+// use the type names that appear in goTypes, above.
+//
+// The test of GO_CGO_GOSTRING_TYPEDEF avoids a duplicate definition
+// error if a Go file with a cgo comment #include's the export header
+// generated by a different package. Unfortunately GoString means two
+// different things: in this prolog it means a C name for the Go type,
+// while in the prolog written into the start of the C code generated
+// from a cgo-using Go file it means the C.GoString function. There is
+// no way to resolve this conflict, but it also doesn't make much
+// difference, as Go code never wants to refer to the latter meaning.
 const gccExportHeaderProlog = `
 /* Start of boilerplate cgo prologue.  */
 #line 1 "cgo-gcc-export-header-prolog"
@@ -1719,7 +1886,9 @@
 */
 typedef char _check_for_GOINTBITS_bit_pointer_matching_GoInt[sizeof(void*)==GOINTBITS/8 ? 1:-1];
 
+#ifndef GO_CGO_GOSTRING_TYPEDEF
 typedef _GoString_ GoString;
+#endif
 typedef void *GoMap;
 typedef void *GoChan;
 typedef struct { void *t; void *v; } GoInterface;
diff --git a/src/cmd/compile/doc.go b/src/cmd/compile/doc.go
index 0dfaacb..5291a8b 100644
--- a/src/cmd/compile/doc.go
+++ b/src/cmd/compile/doc.go
@@ -44,8 +44,12 @@
 		Print compiler version and exit.
 	-asmhdr file
 		Write assembly header to file.
+	-buildid id
+		Record id as the build id in the export metadata.
 	-blockprofile file
 		Write block profile for the compilation to file.
+	-c int
+		Concurrency during compilation. Set 1 for no concurrency (default is 1).
 	-complete
 		Assume package has no non-Go components.
 	-cpuprofile file
@@ -54,8 +58,14 @@
 		Allow references to Go symbols in shared libraries (experimental).
 	-e
 		Remove the limit on the number of errors reported (default limit is 10).
+	-goversion string
+		Specify required go tool version of the runtime.
+		Exits when the runtime go version does not match goversion.
 	-h
 		Halt with a stack trace at the first error detected.
+	-importcfg file
+		Read import configuration from file.
+		In the file, set importmap, packagefile to specify import resolution.
 	-importmap old=new
 		Interpret import "old" as import "new" during compilation.
 		The option may be repeated to add multiple mappings.
@@ -64,6 +74,9 @@
 		instead of $GOROOT/pkg/$GOOS_$GOARCH.
 	-l
 		Disable inlining.
+	-lang version
+		Set language version to compile, as in -lang=go1.12.
+		Default is current version.
 	-largemodel
 		Generate code that assumes a large memory model.
 	-linkobj file
@@ -71,6 +84,8 @@
 		object to usual output file (as specified by -o).
 		Without this flag, the -o output is a combination of both
 		linker and compiler input.
+	-m
+		Print optimization decisions.
 	-memprofile file
 		Write memory profile for the compilation to file.
 	-memprofilerate rate
@@ -90,13 +105,50 @@
 		Write a package (archive) file rather than an object file
 	-race
 		Compile with race detector enabled.
+	-s
+		Warn about composite literals that can be simplified.
+	-shared
+		Generate code that can be linked into a shared library.
+	-traceprofile file
+		Write an execution trace to file.
 	-trimpath prefix
 		Remove prefix from recorded source file paths.
-	-u
-		Disallow importing packages not marked as safe; implies -nolocalimports.
 
-There are also a number of debugging flags; run the command with no arguments
-for a usage message.
+Flags related to debugging information:
+
+	-dwarf
+		Generate DWARF symbols.
+	-dwarflocationlists
+		Add location lists to DWARF in optimized mode.
+	-gendwarfinl int
+		Generate DWARF inline info records (default 2).
+
+Flags to debug the compiler itself:
+
+	-E
+		Debug symbol export.
+	-K
+		Debug missing line numbers.
+	-d list
+		Print debug information about items in list. Try -d help for further information.
+	-live
+		Debug liveness analysis.
+	-v
+		Increase debug verbosity.
+	-%
+		Debug non-static initializers.
+	-W
+		Debug parse tree after type checking.
+	-f
+		Debug stack frames.
+	-i
+		Debug line number stack.
+	-j
+		Debug runtime-initialized variables.
+	-r
+		Debug generated wrappers.
+	-w
+		Debug type checking.
 
 Compiler Directives
 
@@ -125,7 +177,7 @@
 // For a //line comment, this is the first character of the next line, and
 // for a /*line comment this is the character position immediately following the closing */.
 // If no filename is given, the recorded filename is empty if there is also no column number;
-// otherwise is is the most recently recorded filename (actual filename or filename specified
+// otherwise it is the most recently recorded filename (actual filename or filename specified
 // by previous line directive).
 // If a line directive doesn't specify a column number, the column is "unknown" until
 // the next directive and the compiler does not report column numbers for that range.
@@ -146,7 +198,7 @@
 // will report positions in the original input to the generator.
 /*
 The line directive is an historical special case; all other directives are of the form
-//go:name and must start at the begnning of a line, indicating that the directive is defined
+//go:name and must start at the beginning of a line, indicating that the directive is defined
 by the Go toolchain.
 
 	//go:noescape
diff --git a/src/cmd/compile/fmt_test.go b/src/cmd/compile/fmt_test.go
index eb2d3c1..51079e3 100644
--- a/src/cmd/compile/fmt_test.go
+++ b/src/cmd/compile/fmt_test.go
@@ -9,18 +9,24 @@
 // TestFormats finds potential (Printf, etc.) format strings.
 // If they are used in a call, the format verbs are verified
 // based on the matching argument type against a precomputed
-// table of valid formats. The knownFormats table can be used
-// to automatically rewrite format strings with the -u flag.
+// map of valid formats (knownFormats). This map can be used to
+// automatically rewrite format strings across all compiler
+// files with the -r flag.
 //
-// A new knownFormats table based on the found formats is printed
-// when the test is run in verbose mode (-v flag). The table
-// needs to be updated whenever a new (type, format) combination
-// is found and the format verb is not 'v' or 'T' (as in "%v" or
-// "%T").
+// The format map needs to be updated whenever a new (type,
+// format) combination is found and the format verb is not
+// 'v' or 'T' (as in "%v" or "%T"). To update the map auto-
+// matically from the compiler source's use of format strings,
+// use the -u flag. (Whether formats are valid for the values
+// to be formatted must be verified manually, of course.)
 //
-// Run as: go test -run Formats [-u][-v]
+// The -v flag prints out the names of all functions called
+// with a format string, the names of files that were not
+// processed, and any format rewrites made (with -r).
 //
-// Known bugs:
+// Run as: go test -run Formats [-r][-u][-v]
+//
+// Known shortcomings:
 // - indexed format strings ("%[2]s", etc.) are not supported
 //   (the test will fail)
 // - format strings that are not simple string literals cannot
@@ -45,6 +51,7 @@
 	"go/token"
 	"go/types"
 	"internal/testenv"
+	"io"
 	"io/ioutil"
 	"log"
 	"os"
@@ -56,7 +63,10 @@
 	"unicode/utf8"
 )
 
-var update = flag.Bool("u", false, "update format strings")
+var (
+	rewrite = flag.Bool("r", false, "rewrite format strings")
+	update  = flag.Bool("u", false, "update known formats")
+)
 
 // The following variables collect information across all processed files.
 var (
@@ -173,11 +183,11 @@
 
 	// write dirty files back
 	var filesUpdated bool
-	if len(updatedFiles) > 0 && *update {
+	if len(updatedFiles) > 0 && *rewrite {
 		for _, file := range updatedFiles {
 			var buf bytes.Buffer
 			if err := format.Node(&buf, fset, file.ast); err != nil {
-				t.Errorf("WARNING: formatting %s failed: %v", file.name, err)
+				t.Errorf("WARNING: gofmt %s failed: %v", file.name, err)
 				continue
 			}
 			if err := ioutil.WriteFile(file.name, buf.Bytes(), 0x666); err != nil {
@@ -189,7 +199,7 @@
 		}
 	}
 
-	// report all function names containing a format string
+	// report the names of all functions called with a format string
 	if len(callSites) > 0 && testing.Verbose() {
 		set := make(map[string]bool)
 		for _, p := range callSites {
@@ -199,23 +209,33 @@
 		for s := range set {
 			list = append(list, s)
 		}
-		fmt.Println("\nFunctions")
-		printList(list)
+		fmt.Println("\nFunctions called with a format string")
+		writeList(os.Stdout, list)
 	}
 
-	// report all formats found
-	if len(foundFormats) > 0 && testing.Verbose() {
+	// update formats
+	if len(foundFormats) > 0 && *update {
 		var list []string
 		for s := range foundFormats {
 			list = append(list, fmt.Sprintf("%q: \"\",", s))
 		}
-		fmt.Println("\nvar knownFormats = map[string]string{")
-		printList(list)
-		fmt.Println("}")
+		var buf bytes.Buffer
+		buf.WriteString(knownFormatsHeader)
+		writeList(&buf, list)
+		buf.WriteString("}\n")
+		out, err := format.Source(buf.Bytes())
+		const outfile = "fmtmap_test.go"
+		if err != nil {
+			t.Errorf("WARNING: gofmt %s failed: %v", outfile, err)
+			out = buf.Bytes() // continue with unformatted source
+		}
+		if err = ioutil.WriteFile(outfile, out, 0644); err != nil {
+			t.Errorf("WARNING: updating format map failed: %v", err)
+		}
 	}
 
 	// check that knownFormats is up to date
-	if !testing.Verbose() && !*update {
+	if !*rewrite && !*update {
 		var mismatch bool
 		for s := range foundFormats {
 			if _, ok := knownFormats[s]; !ok {
@@ -232,7 +252,7 @@
 			}
 		}
 		if mismatch {
-			t.Errorf("knownFormats is out of date; please 'go test -v fmt_test.go > foo', then extract new definition of knownFormats from foo")
+			t.Errorf("format map is out of date; run 'go test -u' to update and manually verify correctness of change'")
 		}
 	}
 
@@ -256,7 +276,7 @@
 			list = append(list, fmt.Sprintf("%s: %s", posString(lit), nodeString(lit)))
 		}
 		fmt.Println("\nWARNING: Potentially missed format strings")
-		printList(list)
+		writeList(os.Stdout, list)
 		t.Fail()
 	}
 
@@ -365,11 +385,11 @@
 	}
 }
 
-// printList prints list in sorted order.
-func printList(list []string) {
+// writeList writes list in sorted order to w.
+func writeList(w io.Writer, list []string) {
 	sort.Strings(list)
 	for _, s := range list {
-		fmt.Println("\t", s)
+		fmt.Fprintln(w, "\t", s)
 	}
 }
 
@@ -542,7 +562,7 @@
 	// verify that knownFormats entries are correctly formatted
 	for key, val := range knownFormats {
 		// key must be "typename format", and format starts with a '%'
-		// (formats containing '*' alone are not collected in this table)
+		// (formats containing '*' alone are not collected in this map)
 		i := strings.Index(key, "%")
 		if i < 0 || !oneFormat(key[i:]) {
 			log.Fatalf("incorrect knownFormats key: %q", key)
@@ -554,183 +574,26 @@
 	}
 }
 
+const knownFormatsHeader = `// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file implements the knownFormats map which records the valid
+// formats for a given type. The valid formats must correspond to
+// supported compiler formats implemented in fmt.go, or whatever
+// other format verbs are implemented for the given type. The map may
+// also be used to change the use of a format verb across all compiler
+// sources automatically (for instance, if the implementation of fmt.go
+// changes), by using the -r option together with the new formats in the
+// map. To generate this file automatically from the existing source,
+// run: go test -run Formats -u.
+//
+// See the package comment in fmt_test.go for additional information.
+
+package main_test
+
 // knownFormats entries are of the form "typename format" -> "newformat".
 // An absent entry means that the format is not recognized as valid.
 // An empty new format means that the format should remain unchanged.
-// To print out a new table, run: go test -run Formats -v.
 var knownFormats = map[string]string{
-	"*bytes.Buffer %s":                                "",
-	"*cmd/compile/internal/gc.Mpflt %v":               "",
-	"*cmd/compile/internal/gc.Mpint %v":               "",
-	"*cmd/compile/internal/gc.Node %#v":               "",
-	"*cmd/compile/internal/gc.Node %+S":               "",
-	"*cmd/compile/internal/gc.Node %+v":               "",
-	"*cmd/compile/internal/gc.Node %0j":               "",
-	"*cmd/compile/internal/gc.Node %L":                "",
-	"*cmd/compile/internal/gc.Node %S":                "",
-	"*cmd/compile/internal/gc.Node %j":                "",
-	"*cmd/compile/internal/gc.Node %p":                "",
-	"*cmd/compile/internal/gc.Node %v":                "",
-	"*cmd/compile/internal/ssa.Block %s":              "",
-	"*cmd/compile/internal/ssa.Block %v":              "",
-	"*cmd/compile/internal/ssa.Func %s":               "",
-	"*cmd/compile/internal/ssa.Func %v":               "",
-	"*cmd/compile/internal/ssa.Register %s":           "",
-	"*cmd/compile/internal/ssa.Register %v":           "",
-	"*cmd/compile/internal/ssa.SparseTreeNode %v":     "",
-	"*cmd/compile/internal/ssa.Value %s":              "",
-	"*cmd/compile/internal/ssa.Value %v":              "",
-	"*cmd/compile/internal/ssa.sparseTreeMapEntry %v": "",
-	"*cmd/compile/internal/types.Field %p":            "",
-	"*cmd/compile/internal/types.Field %v":            "",
-	"*cmd/compile/internal/types.Sym %+v":             "",
-	"*cmd/compile/internal/types.Sym %0S":             "",
-	"*cmd/compile/internal/types.Sym %S":              "",
-	"*cmd/compile/internal/types.Sym %p":              "",
-	"*cmd/compile/internal/types.Sym %v":              "",
-	"*cmd/compile/internal/types.Type %#v":            "",
-	"*cmd/compile/internal/types.Type %+v":            "",
-	"*cmd/compile/internal/types.Type %-S":            "",
-	"*cmd/compile/internal/types.Type %0S":            "",
-	"*cmd/compile/internal/types.Type %L":             "",
-	"*cmd/compile/internal/types.Type %S":             "",
-	"*cmd/compile/internal/types.Type %p":             "",
-	"*cmd/compile/internal/types.Type %s":             "",
-	"*cmd/compile/internal/types.Type %v":             "",
-	"*cmd/internal/obj.Addr %v":                       "",
-	"*cmd/internal/obj.LSym %v":                       "",
-	"*math/big.Int %#x":                               "",
-	"*math/big.Int %s":                                "",
-	"*math/big.Int %v":                                "",
-	"[16]byte %x":                                     "",
-	"[]*cmd/compile/internal/gc.Node %v":              "",
-	"[]*cmd/compile/internal/ssa.Block %v":            "",
-	"[]*cmd/compile/internal/ssa.Value %v":            "",
-	"[][]string %q":                                   "",
-	"[]byte %s":                                       "",
-	"[]byte %x":                                       "",
-	"[]cmd/compile/internal/ssa.Edge %v":              "",
-	"[]cmd/compile/internal/ssa.ID %v":                "",
-	"[]cmd/compile/internal/ssa.posetNode %v":         "",
-	"[]cmd/compile/internal/ssa.posetUndo %v":         "",
-	"[]cmd/compile/internal/syntax.token %s":          "",
-	"[]string %v":                                     "",
-	"[]uint32 %v":                                     "",
-	"bool %v":                                         "",
-	"byte %08b":                                       "",
-	"byte %c":                                         "",
-	"byte %v":                                         "",
-	"cmd/compile/internal/arm.shift %d":               "",
-	"cmd/compile/internal/gc.Class %d":                "",
-	"cmd/compile/internal/gc.Class %s":                "",
-	"cmd/compile/internal/gc.Class %v":                "",
-	"cmd/compile/internal/gc.Ctype %d":                "",
-	"cmd/compile/internal/gc.Ctype %v":                "",
-	"cmd/compile/internal/gc.Level %d":                "",
-	"cmd/compile/internal/gc.Level %v":                "",
-	"cmd/compile/internal/gc.Nodes %#v":               "",
-	"cmd/compile/internal/gc.Nodes %+v":               "",
-	"cmd/compile/internal/gc.Nodes %.v":               "",
-	"cmd/compile/internal/gc.Nodes %v":                "",
-	"cmd/compile/internal/gc.Op %#v":                  "",
-	"cmd/compile/internal/gc.Op %v":                   "",
-	"cmd/compile/internal/gc.Val %#v":                 "",
-	"cmd/compile/internal/gc.Val %T":                  "",
-	"cmd/compile/internal/gc.Val %v":                  "",
-	"cmd/compile/internal/gc.fmtMode %d":              "",
-	"cmd/compile/internal/gc.initKind %d":             "",
-	"cmd/compile/internal/gc.itag %v":                 "",
-	"cmd/compile/internal/ssa.BranchPrediction %d":    "",
-	"cmd/compile/internal/ssa.Edge %v":                "",
-	"cmd/compile/internal/ssa.GCNode %v":              "",
-	"cmd/compile/internal/ssa.ID %d":                  "",
-	"cmd/compile/internal/ssa.ID %v":                  "",
-	"cmd/compile/internal/ssa.LocPair %s":             "",
-	"cmd/compile/internal/ssa.LocalSlot %s":           "",
-	"cmd/compile/internal/ssa.LocalSlot %v":           "",
-	"cmd/compile/internal/ssa.Location %T":            "",
-	"cmd/compile/internal/ssa.Location %s":            "",
-	"cmd/compile/internal/ssa.Op %s":                  "",
-	"cmd/compile/internal/ssa.Op %v":                  "",
-	"cmd/compile/internal/ssa.ValAndOff %s":           "",
-	"cmd/compile/internal/ssa.domain %v":              "",
-	"cmd/compile/internal/ssa.posetNode %v":           "",
-	"cmd/compile/internal/ssa.posetTestOp %v":         "",
-	"cmd/compile/internal/ssa.rbrank %d":              "",
-	"cmd/compile/internal/ssa.regMask %d":             "",
-	"cmd/compile/internal/ssa.register %d":            "",
-	"cmd/compile/internal/syntax.Expr %#v":            "",
-	"cmd/compile/internal/syntax.Node %T":             "",
-	"cmd/compile/internal/syntax.Operator %s":         "",
-	"cmd/compile/internal/syntax.Pos %s":              "",
-	"cmd/compile/internal/syntax.Pos %v":              "",
-	"cmd/compile/internal/syntax.position %s":         "",
-	"cmd/compile/internal/syntax.token %q":            "",
-	"cmd/compile/internal/syntax.token %s":            "",
-	"cmd/compile/internal/types.EType %d":             "",
-	"cmd/compile/internal/types.EType %s":             "",
-	"cmd/compile/internal/types.EType %v":             "",
-	"error %v":                                        "",
-	"float64 %.2f":                                    "",
-	"float64 %.3f":                                    "",
-	"float64 %.6g":                                    "",
-	"float64 %g":                                      "",
-	"int %-12d":                                       "",
-	"int %-6d":                                        "",
-	"int %-8o":                                        "",
-	"int %02d":                                        "",
-	"int %6d":                                         "",
-	"int %c":                                          "",
-	"int %d":                                          "",
-	"int %v":                                          "",
-	"int %x":                                          "",
-	"int16 %d":                                        "",
-	"int16 %x":                                        "",
-	"int32 %d":                                        "",
-	"int32 %v":                                        "",
-	"int32 %x":                                        "",
-	"int64 %+d":                                       "",
-	"int64 %-10d":                                     "",
-	"int64 %.5d":                                      "",
-	"int64 %X":                                        "",
-	"int64 %d":                                        "",
-	"int64 %v":                                        "",
-	"int64 %x":                                        "",
-	"int8 %d":                                         "",
-	"int8 %x":                                         "",
-	"interface{} %#v":                                 "",
-	"interface{} %T":                                  "",
-	"interface{} %q":                                  "",
-	"interface{} %s":                                  "",
-	"interface{} %v":                                  "",
-	"map[*cmd/compile/internal/gc.Node]*cmd/compile/internal/ssa.Value %v": "",
-	"map[cmd/compile/internal/ssa.ID]uint32 %v":                            "",
-	"reflect.Type %s":                                                      "",
-	"rune %#U":                                                             "",
-	"rune %c":                                                              "",
-	"string %-*s":                                                          "",
-	"string %-16s":                                                         "",
-	"string %-6s":                                                          "",
-	"string %.*s":                                                          "",
-	"string %q":                                                            "",
-	"string %s":                                                            "",
-	"string %v":                                                            "",
-	"time.Duration %d":                                                     "",
-	"time.Duration %v":                                                     "",
-	"uint %04x":                                                            "",
-	"uint %5d":                                                             "",
-	"uint %d":                                                              "",
-	"uint %x":                                                              "",
-	"uint16 %d":                                                            "",
-	"uint16 %v":                                                            "",
-	"uint16 %x":                                                            "",
-	"uint32 %d":                                                            "",
-	"uint32 %v":                                                            "",
-	"uint32 %x":                                                            "",
-	"uint64 %08x":                                                          "",
-	"uint64 %d":                                                            "",
-	"uint64 %x":                                                            "",
-	"uint8 %d":                                                             "",
-	"uint8 %x":                                                             "",
-	"uintptr %d":                                                           "",
-}
+`
diff --git a/src/cmd/compile/fmtmap_test.go b/src/cmd/compile/fmtmap_test.go
new file mode 100644
index 0000000..81ba20f
--- /dev/null
+++ b/src/cmd/compile/fmtmap_test.go
@@ -0,0 +1,204 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file implements the knownFormats map which records the valid
+// formats for a given type. The valid formats must correspond to
+// supported compiler formats implemented in fmt.go, or whatever
+// other format verbs are implemented for the given type. The map may
+// also be used to change the use of a format verb across all compiler
+// sources automatically (for instance, if the implementation of fmt.go
+// changes), by using the -r option together with the new formats in the
+// map. To generate this file automatically from the existing source,
+// run: go test -run Formats -u.
+//
+// See the package comment in fmt_test.go for additional information.
+
+package main_test
+
+// knownFormats entries are of the form "typename format" -> "newformat".
+// An absent entry means that the format is not recognized as valid.
+// An empty new format means that the format should remain unchanged.
+var knownFormats = map[string]string{
+	"*bytes.Buffer %s":                                "",
+	"*cmd/compile/internal/gc.Mpflt %v":               "",
+	"*cmd/compile/internal/gc.Mpint %v":               "",
+	"*cmd/compile/internal/gc.Node %#v":               "",
+	"*cmd/compile/internal/gc.Node %+S":               "",
+	"*cmd/compile/internal/gc.Node %+v":               "",
+	"*cmd/compile/internal/gc.Node %0j":               "",
+	"*cmd/compile/internal/gc.Node %L":                "",
+	"*cmd/compile/internal/gc.Node %S":                "",
+	"*cmd/compile/internal/gc.Node %j":                "",
+	"*cmd/compile/internal/gc.Node %p":                "",
+	"*cmd/compile/internal/gc.Node %v":                "",
+	"*cmd/compile/internal/ssa.Block %s":              "",
+	"*cmd/compile/internal/ssa.Block %v":              "",
+	"*cmd/compile/internal/ssa.Func %s":               "",
+	"*cmd/compile/internal/ssa.Func %v":               "",
+	"*cmd/compile/internal/ssa.Register %s":           "",
+	"*cmd/compile/internal/ssa.Register %v":           "",
+	"*cmd/compile/internal/ssa.SparseTreeNode %v":     "",
+	"*cmd/compile/internal/ssa.Value %s":              "",
+	"*cmd/compile/internal/ssa.Value %v":              "",
+	"*cmd/compile/internal/ssa.sparseTreeMapEntry %v": "",
+	"*cmd/compile/internal/types.Field %p":            "",
+	"*cmd/compile/internal/types.Field %v":            "",
+	"*cmd/compile/internal/types.Sym %0S":             "",
+	"*cmd/compile/internal/types.Sym %S":              "",
+	"*cmd/compile/internal/types.Sym %p":              "",
+	"*cmd/compile/internal/types.Sym %v":              "",
+	"*cmd/compile/internal/types.Type %#L":            "",
+	"*cmd/compile/internal/types.Type %#v":            "",
+	"*cmd/compile/internal/types.Type %+v":            "",
+	"*cmd/compile/internal/types.Type %-S":            "",
+	"*cmd/compile/internal/types.Type %0S":            "",
+	"*cmd/compile/internal/types.Type %L":             "",
+	"*cmd/compile/internal/types.Type %S":             "",
+	"*cmd/compile/internal/types.Type %p":             "",
+	"*cmd/compile/internal/types.Type %s":             "",
+	"*cmd/compile/internal/types.Type %v":             "",
+	"*cmd/internal/obj.Addr %v":                       "",
+	"*cmd/internal/obj.LSym %v":                       "",
+	"*math/big.Float %f":                              "",
+	"*math/big.Int %#x":                               "",
+	"*math/big.Int %s":                                "",
+	"*math/big.Int %v":                                "",
+	"[16]byte %x":                                     "",
+	"[]*cmd/compile/internal/gc.Node %v":              "",
+	"[]*cmd/compile/internal/ssa.Block %v":            "",
+	"[]*cmd/compile/internal/ssa.Value %v":            "",
+	"[][]string %q":                                   "",
+	"[]byte %s":                                       "",
+	"[]byte %x":                                       "",
+	"[]cmd/compile/internal/ssa.Edge %v":              "",
+	"[]cmd/compile/internal/ssa.ID %v":                "",
+	"[]cmd/compile/internal/ssa.posetNode %v":         "",
+	"[]cmd/compile/internal/ssa.posetUndo %v":         "",
+	"[]cmd/compile/internal/syntax.token %s":          "",
+	"[]string %v":                                     "",
+	"[]uint32 %v":                                     "",
+	"bool %v":                                         "",
+	"byte %08b":                                       "",
+	"byte %c":                                         "",
+	"byte %v":                                         "",
+	"cmd/compile/internal/arm.shift %d":               "",
+	"cmd/compile/internal/gc.Class %d":                "",
+	"cmd/compile/internal/gc.Class %s":                "",
+	"cmd/compile/internal/gc.Class %v":                "",
+	"cmd/compile/internal/gc.Ctype %d":                "",
+	"cmd/compile/internal/gc.Ctype %v":                "",
+	"cmd/compile/internal/gc.Level %d":                "",
+	"cmd/compile/internal/gc.Level %v":                "",
+	"cmd/compile/internal/gc.Nodes %#v":               "",
+	"cmd/compile/internal/gc.Nodes %+v":               "",
+	"cmd/compile/internal/gc.Nodes %.v":               "",
+	"cmd/compile/internal/gc.Nodes %v":                "",
+	"cmd/compile/internal/gc.Op %#v":                  "",
+	"cmd/compile/internal/gc.Op %v":                   "",
+	"cmd/compile/internal/gc.Val %#v":                 "",
+	"cmd/compile/internal/gc.Val %T":                  "",
+	"cmd/compile/internal/gc.Val %v":                  "",
+	"cmd/compile/internal/gc.fmtMode %d":              "",
+	"cmd/compile/internal/gc.initKind %d":             "",
+	"cmd/compile/internal/gc.itag %v":                 "",
+	"cmd/compile/internal/ssa.BranchPrediction %d":    "",
+	"cmd/compile/internal/ssa.Edge %v":                "",
+	"cmd/compile/internal/ssa.GCNode %v":              "",
+	"cmd/compile/internal/ssa.ID %d":                  "",
+	"cmd/compile/internal/ssa.ID %v":                  "",
+	"cmd/compile/internal/ssa.LocPair %s":             "",
+	"cmd/compile/internal/ssa.LocalSlot %s":           "",
+	"cmd/compile/internal/ssa.LocalSlot %v":           "",
+	"cmd/compile/internal/ssa.Location %T":            "",
+	"cmd/compile/internal/ssa.Location %s":            "",
+	"cmd/compile/internal/ssa.Op %s":                  "",
+	"cmd/compile/internal/ssa.Op %v":                  "",
+	"cmd/compile/internal/ssa.ValAndOff %s":           "",
+	"cmd/compile/internal/ssa.domain %v":              "",
+	"cmd/compile/internal/ssa.posetNode %v":           "",
+	"cmd/compile/internal/ssa.posetTestOp %v":         "",
+	"cmd/compile/internal/ssa.rbrank %d":              "",
+	"cmd/compile/internal/ssa.regMask %d":             "",
+	"cmd/compile/internal/ssa.register %d":            "",
+	"cmd/compile/internal/ssa.relation %s":            "",
+	"cmd/compile/internal/syntax.Error %q":            "",
+	"cmd/compile/internal/syntax.Expr %#v":            "",
+	"cmd/compile/internal/syntax.Node %T":             "",
+	"cmd/compile/internal/syntax.Operator %s":         "",
+	"cmd/compile/internal/syntax.Pos %s":              "",
+	"cmd/compile/internal/syntax.Pos %v":              "",
+	"cmd/compile/internal/syntax.position %s":         "",
+	"cmd/compile/internal/syntax.token %q":            "",
+	"cmd/compile/internal/syntax.token %s":            "",
+	"cmd/compile/internal/types.EType %d":             "",
+	"cmd/compile/internal/types.EType %s":             "",
+	"cmd/compile/internal/types.EType %v":             "",
+	"cmd/internal/obj.ABI %v":                         "",
+	"error %v":                                        "",
+	"float64 %.2f":                                    "",
+	"float64 %.3f":                                    "",
+	"float64 %.6g":                                    "",
+	"float64 %g":                                      "",
+	"int %-12d":                                       "",
+	"int %-6d":                                        "",
+	"int %-8o":                                        "",
+	"int %02d":                                        "",
+	"int %6d":                                         "",
+	"int %c":                                          "",
+	"int %d":                                          "",
+	"int %v":                                          "",
+	"int %x":                                          "",
+	"int16 %d":                                        "",
+	"int16 %x":                                        "",
+	"int32 %d":                                        "",
+	"int32 %v":                                        "",
+	"int32 %x":                                        "",
+	"int64 %+d":                                       "",
+	"int64 %-10d":                                     "",
+	"int64 %.5d":                                      "",
+	"int64 %X":                                        "",
+	"int64 %d":                                        "",
+	"int64 %v":                                        "",
+	"int64 %x":                                        "",
+	"int8 %d":                                         "",
+	"int8 %x":                                         "",
+	"interface{} %#v":                                 "",
+	"interface{} %T":                                  "",
+	"interface{} %p":                                  "",
+	"interface{} %q":                                  "",
+	"interface{} %s":                                  "",
+	"interface{} %v":                                  "",
+	"map[*cmd/compile/internal/gc.Node]*cmd/compile/internal/ssa.Value %v": "",
+	"map[cmd/compile/internal/ssa.ID]uint32 %v":                            "",
+	"math/big.Accuracy %s":                                                 "",
+	"reflect.Type %s":                                                      "",
+	"rune %#U":                                                             "",
+	"rune %c":                                                              "",
+	"string %-*s":                                                          "",
+	"string %-16s":                                                         "",
+	"string %-6s":                                                          "",
+	"string %.*s":                                                          "",
+	"string %q":                                                            "",
+	"string %s":                                                            "",
+	"string %v":                                                            "",
+	"time.Duration %d":                                                     "",
+	"time.Duration %v":                                                     "",
+	"uint %04x":                                                            "",
+	"uint %5d":                                                             "",
+	"uint %d":                                                              "",
+	"uint %x":                                                              "",
+	"uint16 %d":                                                            "",
+	"uint16 %v":                                                            "",
+	"uint16 %x":                                                            "",
+	"uint32 %#x":                                                           "",
+	"uint32 %d":                                                            "",
+	"uint32 %v":                                                            "",
+	"uint32 %x":                                                            "",
+	"uint64 %08x":                                                          "",
+	"uint64 %d":                                                            "",
+	"uint64 %x":                                                            "",
+	"uint8 %d":                                                             "",
+	"uint8 %x":                                                             "",
+	"uintptr %d":                                                           "",
+}
diff --git a/src/cmd/compile/internal/amd64/galign.go b/src/cmd/compile/internal/amd64/galign.go
index 58c4699..f6bb961 100644
--- a/src/cmd/compile/internal/amd64/galign.go
+++ b/src/cmd/compile/internal/amd64/galign.go
@@ -24,6 +24,7 @@
 	arch.ZeroRange = zerorange
 	arch.ZeroAuto = zeroAuto
 	arch.Ginsnop = ginsnop
+	arch.Ginsnopdefer = ginsnop
 
 	arch.SSAMarkMoves = ssaMarkMoves
 	arch.SSAGenValue = ssaGenValue
diff --git a/src/cmd/compile/internal/amd64/ggen.go b/src/cmd/compile/internal/amd64/ggen.go
index df0a69a..ee4f872 100644
--- a/src/cmd/compile/internal/amd64/ggen.go
+++ b/src/cmd/compile/internal/amd64/ggen.go
@@ -141,7 +141,7 @@
 	}
 }
 
-func ginsnop(pp *gc.Progs) {
+func ginsnop(pp *gc.Progs) *obj.Prog {
 	// This is actually not the x86 NOP anymore,
 	// but at the point where it gets used, AX is dead
 	// so it's okay if we lose the high bits.
@@ -150,4 +150,5 @@
 	p.From.Reg = x86.REG_AX
 	p.To.Type = obj.TYPE_REG
 	p.To.Reg = x86.REG_AX
+	return p
 }
diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go
index 307cdc5..a2c7d5d 100644
--- a/src/cmd/compile/internal/amd64/ssa.go
+++ b/src/cmd/compile/internal/amd64/ssa.go
@@ -229,24 +229,27 @@
 		// Result[0] (the quotient) is in AX.
 		// Result[1] (the remainder) is in DX.
 		r := v.Args[1].Reg()
+		var j1 *obj.Prog
 
 		// CPU faults upon signed overflow, which occurs when the most
 		// negative int is divided by -1. Handle divide by -1 as a special case.
-		var c *obj.Prog
-		switch v.Op {
-		case ssa.OpAMD64DIVQ:
-			c = s.Prog(x86.ACMPQ)
-		case ssa.OpAMD64DIVL:
-			c = s.Prog(x86.ACMPL)
-		case ssa.OpAMD64DIVW:
-			c = s.Prog(x86.ACMPW)
+		if ssa.NeedsFixUp(v) {
+			var c *obj.Prog
+			switch v.Op {
+			case ssa.OpAMD64DIVQ:
+				c = s.Prog(x86.ACMPQ)
+			case ssa.OpAMD64DIVL:
+				c = s.Prog(x86.ACMPL)
+			case ssa.OpAMD64DIVW:
+				c = s.Prog(x86.ACMPW)
+			}
+			c.From.Type = obj.TYPE_REG
+			c.From.Reg = r
+			c.To.Type = obj.TYPE_CONST
+			c.To.Offset = -1
+			j1 = s.Prog(x86.AJEQ)
+			j1.To.Type = obj.TYPE_BRANCH
 		}
-		c.From.Type = obj.TYPE_REG
-		c.From.Reg = r
-		c.To.Type = obj.TYPE_CONST
-		c.To.Offset = -1
-		j1 := s.Prog(x86.AJEQ)
-		j1.To.Type = obj.TYPE_BRANCH
 
 		// Sign extend dividend.
 		switch v.Op {
@@ -263,36 +266,38 @@
 		p.From.Type = obj.TYPE_REG
 		p.From.Reg = r
 
-		// Skip over -1 fixup code.
-		j2 := s.Prog(obj.AJMP)
-		j2.To.Type = obj.TYPE_BRANCH
+		if j1 != nil {
+			// Skip over -1 fixup code.
+			j2 := s.Prog(obj.AJMP)
+			j2.To.Type = obj.TYPE_BRANCH
 
-		// Issue -1 fixup code.
-		// n / -1 = -n
-		var n1 *obj.Prog
-		switch v.Op {
-		case ssa.OpAMD64DIVQ:
-			n1 = s.Prog(x86.ANEGQ)
-		case ssa.OpAMD64DIVL:
-			n1 = s.Prog(x86.ANEGL)
-		case ssa.OpAMD64DIVW:
-			n1 = s.Prog(x86.ANEGW)
+			// Issue -1 fixup code.
+			// n / -1 = -n
+			var n1 *obj.Prog
+			switch v.Op {
+			case ssa.OpAMD64DIVQ:
+				n1 = s.Prog(x86.ANEGQ)
+			case ssa.OpAMD64DIVL:
+				n1 = s.Prog(x86.ANEGL)
+			case ssa.OpAMD64DIVW:
+				n1 = s.Prog(x86.ANEGW)
+			}
+			n1.To.Type = obj.TYPE_REG
+			n1.To.Reg = x86.REG_AX
+
+			// n % -1 == 0
+			n2 := s.Prog(x86.AXORL)
+			n2.From.Type = obj.TYPE_REG
+			n2.From.Reg = x86.REG_DX
+			n2.To.Type = obj.TYPE_REG
+			n2.To.Reg = x86.REG_DX
+
+			// TODO(khr): issue only the -1 fixup code we need.
+			// For instance, if only the quotient is used, no point in zeroing the remainder.
+
+			j1.To.Val = n1
+			j2.To.Val = s.Pc()
 		}
-		n1.To.Type = obj.TYPE_REG
-		n1.To.Reg = x86.REG_AX
-
-		// n % -1 == 0
-		n2 := s.Prog(x86.AXORL)
-		n2.From.Type = obj.TYPE_REG
-		n2.From.Reg = x86.REG_DX
-		n2.To.Type = obj.TYPE_REG
-		n2.To.Reg = x86.REG_DX
-
-		// TODO(khr): issue only the -1 fixup code we need.
-		// For instance, if only the quotient is used, no point in zeroing the remainder.
-
-		j1.To.Val = n1
-		j2.To.Val = s.Pc()
 
 	case ssa.OpAMD64HMULQ, ssa.OpAMD64HMULL, ssa.OpAMD64HMULQU, ssa.OpAMD64HMULLU:
 		// the frontend rewrites constant division by 8/16/32 bit integers into
@@ -315,6 +320,13 @@
 			m.To.Reg = x86.REG_DX
 		}
 
+	case ssa.OpAMD64MULQU, ssa.OpAMD64MULLU:
+		// Arg[0] is already in AX as it's the only register we allow
+		// results lo in AX
+		p := s.Prog(v.Op.Asm())
+		p.From.Type = obj.TYPE_REG
+		p.From.Reg = v.Args[1].Reg()
+
 	case ssa.OpAMD64MULQU2:
 		// Arg[0] is already in AX as it's the only register we allow
 		// results hi in DX, lo in AX
@@ -348,6 +360,41 @@
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = r
 
+	case ssa.OpAMD64ADDQcarry, ssa.OpAMD64ADCQ:
+		r := v.Reg0()
+		r0 := v.Args[0].Reg()
+		r1 := v.Args[1].Reg()
+		switch r {
+		case r0:
+			p := s.Prog(v.Op.Asm())
+			p.From.Type = obj.TYPE_REG
+			p.From.Reg = r1
+			p.To.Type = obj.TYPE_REG
+			p.To.Reg = r
+		case r1:
+			p := s.Prog(v.Op.Asm())
+			p.From.Type = obj.TYPE_REG
+			p.From.Reg = r0
+			p.To.Type = obj.TYPE_REG
+			p.To.Reg = r
+		default:
+			v.Fatalf("output not in same register as an input %s", v.LongString())
+		}
+
+	case ssa.OpAMD64SUBQborrow, ssa.OpAMD64SBBQ:
+		p := s.Prog(v.Op.Asm())
+		p.From.Type = obj.TYPE_REG
+		p.From.Reg = v.Args[1].Reg()
+		p.To.Type = obj.TYPE_REG
+		p.To.Reg = v.Reg0()
+
+	case ssa.OpAMD64ADDQconstcarry, ssa.OpAMD64ADCQconst, ssa.OpAMD64SUBQconstborrow, ssa.OpAMD64SBBQconst:
+		p := s.Prog(v.Op.Asm())
+		p.From.Type = obj.TYPE_CONST
+		p.From.Offset = v.AuxInt
+		p.To.Type = obj.TYPE_REG
+		p.To.Reg = v.Reg0()
+
 	case ssa.OpAMD64ADDQconst, ssa.OpAMD64ADDLconst:
 		r := v.Reg()
 		a := v.Args[0].Reg()
@@ -524,6 +571,7 @@
 	case ssa.OpAMD64LEAQ1, ssa.OpAMD64LEAQ2, ssa.OpAMD64LEAQ4, ssa.OpAMD64LEAQ8,
 		ssa.OpAMD64LEAL1, ssa.OpAMD64LEAL2, ssa.OpAMD64LEAL4, ssa.OpAMD64LEAL8,
 		ssa.OpAMD64LEAW1, ssa.OpAMD64LEAW2, ssa.OpAMD64LEAW4, ssa.OpAMD64LEAW8:
+		o := v.Reg()
 		r := v.Args[0].Reg()
 		i := v.Args[1].Reg()
 		p := s.Prog(v.Op.Asm())
@@ -543,9 +591,24 @@
 		p.From.Type = obj.TYPE_MEM
 		p.From.Reg = r
 		p.From.Index = i
-		gc.AddAux(&p.From, v)
 		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
+		p.To.Reg = o
+		if v.AuxInt != 0 && v.Aux == nil {
+			// Emit an additional LEA to add the displacement instead of creating a slow 3 operand LEA.
+			switch v.Op {
+			case ssa.OpAMD64LEAQ1, ssa.OpAMD64LEAQ2, ssa.OpAMD64LEAQ4, ssa.OpAMD64LEAQ8:
+				p = s.Prog(x86.ALEAQ)
+			case ssa.OpAMD64LEAL1, ssa.OpAMD64LEAL2, ssa.OpAMD64LEAL4, ssa.OpAMD64LEAL8:
+				p = s.Prog(x86.ALEAL)
+			case ssa.OpAMD64LEAW1, ssa.OpAMD64LEAW2, ssa.OpAMD64LEAW4, ssa.OpAMD64LEAW8:
+				p = s.Prog(x86.ALEAW)
+			}
+			p.From.Type = obj.TYPE_MEM
+			p.From.Reg = o
+			p.To.Type = obj.TYPE_REG
+			p.To.Reg = o
+		}
+		gc.AddAux(&p.From, v)
 	case ssa.OpAMD64LEAQ, ssa.OpAMD64LEAL, ssa.OpAMD64LEAW:
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_MEM
@@ -567,7 +630,11 @@
 		p.From.Reg = v.Args[0].Reg()
 		p.To.Type = obj.TYPE_CONST
 		p.To.Offset = v.AuxInt
-	case ssa.OpAMD64BTLconst, ssa.OpAMD64BTQconst:
+	case ssa.OpAMD64BTLconst, ssa.OpAMD64BTQconst,
+		ssa.OpAMD64TESTQconst, ssa.OpAMD64TESTLconst, ssa.OpAMD64TESTWconst, ssa.OpAMD64TESTBconst,
+		ssa.OpAMD64BTSLconst, ssa.OpAMD64BTSQconst,
+		ssa.OpAMD64BTCLconst, ssa.OpAMD64BTCQconst,
+		ssa.OpAMD64BTRLconst, ssa.OpAMD64BTRQconst:
 		op := v.Op
 		if op == ssa.OpAMD64BTQconst && v.AuxInt < 32 {
 			// Emit 32-bit version because it's shorter
@@ -578,15 +645,6 @@
 		p.From.Offset = v.AuxInt
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = v.Args[0].Reg()
-	case ssa.OpAMD64TESTQconst, ssa.OpAMD64TESTLconst, ssa.OpAMD64TESTWconst, ssa.OpAMD64TESTBconst,
-		ssa.OpAMD64BTSLconst, ssa.OpAMD64BTSQconst,
-		ssa.OpAMD64BTCLconst, ssa.OpAMD64BTCQconst,
-		ssa.OpAMD64BTRLconst, ssa.OpAMD64BTRQconst:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_CONST
-		p.From.Offset = v.AuxInt
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Args[0].Reg()
 	case ssa.OpAMD64CMPQload, ssa.OpAMD64CMPLload, ssa.OpAMD64CMPWload, ssa.OpAMD64CMPBload:
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_MEM
@@ -642,118 +700,102 @@
 		gc.AddAux(&p.From, v)
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = v.Reg()
-	case ssa.OpAMD64MOVQloadidx8, ssa.OpAMD64MOVSDloadidx8, ssa.OpAMD64MOVLloadidx8:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_MEM
-		p.From.Reg = v.Args[0].Reg()
-		gc.AddAux(&p.From, v)
-		p.From.Scale = 8
-		p.From.Index = v.Args[1].Reg()
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
-	case ssa.OpAMD64MOVLloadidx4, ssa.OpAMD64MOVSSloadidx4:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_MEM
-		p.From.Reg = v.Args[0].Reg()
-		gc.AddAux(&p.From, v)
-		p.From.Scale = 4
-		p.From.Index = v.Args[1].Reg()
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
-	case ssa.OpAMD64MOVWloadidx2:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_MEM
-		p.From.Reg = v.Args[0].Reg()
-		gc.AddAux(&p.From, v)
-		p.From.Scale = 2
-		p.From.Index = v.Args[1].Reg()
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
-	case ssa.OpAMD64MOVBloadidx1, ssa.OpAMD64MOVWloadidx1, ssa.OpAMD64MOVLloadidx1, ssa.OpAMD64MOVQloadidx1, ssa.OpAMD64MOVSSloadidx1, ssa.OpAMD64MOVSDloadidx1:
+	case ssa.OpAMD64MOVBloadidx1, ssa.OpAMD64MOVWloadidx1, ssa.OpAMD64MOVLloadidx1, ssa.OpAMD64MOVQloadidx1, ssa.OpAMD64MOVSSloadidx1, ssa.OpAMD64MOVSDloadidx1,
+		ssa.OpAMD64MOVQloadidx8, ssa.OpAMD64MOVSDloadidx8, ssa.OpAMD64MOVLloadidx8, ssa.OpAMD64MOVLloadidx4, ssa.OpAMD64MOVSSloadidx4, ssa.OpAMD64MOVWloadidx2:
 		r := v.Args[0].Reg()
 		i := v.Args[1].Reg()
-		if i == x86.REG_SP {
-			r, i = i, r
-		}
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_MEM
+		switch v.Op {
+		case ssa.OpAMD64MOVBloadidx1, ssa.OpAMD64MOVWloadidx1, ssa.OpAMD64MOVLloadidx1, ssa.OpAMD64MOVQloadidx1, ssa.OpAMD64MOVSSloadidx1, ssa.OpAMD64MOVSDloadidx1:
+			if i == x86.REG_SP {
+				r, i = i, r
+			}
+			p.From.Scale = 1
+		case ssa.OpAMD64MOVQloadidx8, ssa.OpAMD64MOVSDloadidx8, ssa.OpAMD64MOVLloadidx8:
+			p.From.Scale = 8
+		case ssa.OpAMD64MOVLloadidx4, ssa.OpAMD64MOVSSloadidx4:
+			p.From.Scale = 4
+		case ssa.OpAMD64MOVWloadidx2:
+			p.From.Scale = 2
+		}
 		p.From.Reg = r
-		p.From.Scale = 1
 		p.From.Index = i
 		gc.AddAux(&p.From, v)
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = v.Reg()
-	case ssa.OpAMD64MOVQstore, ssa.OpAMD64MOVSSstore, ssa.OpAMD64MOVSDstore, ssa.OpAMD64MOVLstore, ssa.OpAMD64MOVWstore, ssa.OpAMD64MOVBstore, ssa.OpAMD64MOVOstore:
+	case ssa.OpAMD64MOVQstore, ssa.OpAMD64MOVSSstore, ssa.OpAMD64MOVSDstore, ssa.OpAMD64MOVLstore, ssa.OpAMD64MOVWstore, ssa.OpAMD64MOVBstore, ssa.OpAMD64MOVOstore,
+		ssa.OpAMD64BTCQmodify, ssa.OpAMD64BTCLmodify, ssa.OpAMD64BTRQmodify, ssa.OpAMD64BTRLmodify, ssa.OpAMD64BTSQmodify, ssa.OpAMD64BTSLmodify,
+		ssa.OpAMD64ADDQmodify, ssa.OpAMD64SUBQmodify, ssa.OpAMD64ANDQmodify, ssa.OpAMD64ORQmodify, ssa.OpAMD64XORQmodify,
+		ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify:
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_REG
 		p.From.Reg = v.Args[1].Reg()
 		p.To.Type = obj.TYPE_MEM
 		p.To.Reg = v.Args[0].Reg()
 		gc.AddAux(&p.To, v)
-	case ssa.OpAMD64MOVQstoreidx8, ssa.OpAMD64MOVSDstoreidx8, ssa.OpAMD64MOVLstoreidx8:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_REG
-		p.From.Reg = v.Args[2].Reg()
-		p.To.Type = obj.TYPE_MEM
-		p.To.Reg = v.Args[0].Reg()
-		p.To.Scale = 8
-		p.To.Index = v.Args[1].Reg()
-		gc.AddAux(&p.To, v)
-	case ssa.OpAMD64MOVSSstoreidx4, ssa.OpAMD64MOVLstoreidx4:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_REG
-		p.From.Reg = v.Args[2].Reg()
-		p.To.Type = obj.TYPE_MEM
-		p.To.Reg = v.Args[0].Reg()
-		p.To.Scale = 4
-		p.To.Index = v.Args[1].Reg()
-		gc.AddAux(&p.To, v)
-	case ssa.OpAMD64MOVWstoreidx2:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_REG
-		p.From.Reg = v.Args[2].Reg()
-		p.To.Type = obj.TYPE_MEM
-		p.To.Reg = v.Args[0].Reg()
-		p.To.Scale = 2
-		p.To.Index = v.Args[1].Reg()
-		gc.AddAux(&p.To, v)
-	case ssa.OpAMD64MOVBstoreidx1, ssa.OpAMD64MOVWstoreidx1, ssa.OpAMD64MOVLstoreidx1, ssa.OpAMD64MOVQstoreidx1, ssa.OpAMD64MOVSSstoreidx1, ssa.OpAMD64MOVSDstoreidx1:
+	case ssa.OpAMD64MOVBstoreidx1, ssa.OpAMD64MOVWstoreidx1, ssa.OpAMD64MOVLstoreidx1, ssa.OpAMD64MOVQstoreidx1, ssa.OpAMD64MOVSSstoreidx1, ssa.OpAMD64MOVSDstoreidx1,
+		ssa.OpAMD64MOVQstoreidx8, ssa.OpAMD64MOVSDstoreidx8, ssa.OpAMD64MOVLstoreidx8, ssa.OpAMD64MOVSSstoreidx4, ssa.OpAMD64MOVLstoreidx4, ssa.OpAMD64MOVWstoreidx2:
 		r := v.Args[0].Reg()
 		i := v.Args[1].Reg()
-		if i == x86.REG_SP {
-			r, i = i, r
-		}
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_REG
 		p.From.Reg = v.Args[2].Reg()
 		p.To.Type = obj.TYPE_MEM
+		switch v.Op {
+		case ssa.OpAMD64MOVBstoreidx1, ssa.OpAMD64MOVWstoreidx1, ssa.OpAMD64MOVLstoreidx1, ssa.OpAMD64MOVQstoreidx1, ssa.OpAMD64MOVSSstoreidx1, ssa.OpAMD64MOVSDstoreidx1:
+			if i == x86.REG_SP {
+				r, i = i, r
+			}
+			p.To.Scale = 1
+		case ssa.OpAMD64MOVQstoreidx8, ssa.OpAMD64MOVSDstoreidx8, ssa.OpAMD64MOVLstoreidx8:
+			p.To.Scale = 8
+		case ssa.OpAMD64MOVSSstoreidx4, ssa.OpAMD64MOVLstoreidx4:
+			p.To.Scale = 4
+		case ssa.OpAMD64MOVWstoreidx2:
+			p.To.Scale = 2
+		}
 		p.To.Reg = r
-		p.To.Scale = 1
 		p.To.Index = i
 		gc.AddAux(&p.To, v)
 	case ssa.OpAMD64ADDQconstmodify, ssa.OpAMD64ADDLconstmodify:
 		sc := v.AuxValAndOff()
 		off := sc.Off()
 		val := sc.Val()
-		if val == 1 {
+		if val == 1 || val == -1 {
 			var asm obj.As
 			if v.Op == ssa.OpAMD64ADDQconstmodify {
-				asm = x86.AINCQ
+				if val == 1 {
+					asm = x86.AINCQ
+				} else {
+					asm = x86.ADECQ
+				}
 			} else {
-				asm = x86.AINCL
+				if val == 1 {
+					asm = x86.AINCL
+				} else {
+					asm = x86.ADECL
+				}
 			}
 			p := s.Prog(asm)
 			p.To.Type = obj.TYPE_MEM
 			p.To.Reg = v.Args[0].Reg()
 			gc.AddAux2(&p.To, v, off)
-		} else {
-			p := s.Prog(v.Op.Asm())
-			p.From.Type = obj.TYPE_CONST
-			p.From.Offset = val
-			p.To.Type = obj.TYPE_MEM
-			p.To.Reg = v.Args[0].Reg()
-			gc.AddAux2(&p.To, v, off)
+			break
 		}
+		fallthrough
+	case ssa.OpAMD64ANDQconstmodify, ssa.OpAMD64ANDLconstmodify, ssa.OpAMD64ORQconstmodify, ssa.OpAMD64ORLconstmodify,
+		ssa.OpAMD64BTCQconstmodify, ssa.OpAMD64BTCLconstmodify, ssa.OpAMD64BTSQconstmodify, ssa.OpAMD64BTSLconstmodify,
+		ssa.OpAMD64BTRQconstmodify, ssa.OpAMD64BTRLconstmodify, ssa.OpAMD64XORQconstmodify, ssa.OpAMD64XORLconstmodify:
+		sc := v.AuxValAndOff()
+		off := sc.Off()
+		val := sc.Val()
+		p := s.Prog(v.Op.Asm())
+		p.From.Type = obj.TYPE_CONST
+		p.From.Offset = val
+		p.To.Type = obj.TYPE_MEM
+		p.To.Reg = v.Args[0].Reg()
+		gc.AddAux2(&p.To, v, off)
 	case ssa.OpAMD64MOVQstoreconst, ssa.OpAMD64MOVLstoreconst, ssa.OpAMD64MOVWstoreconst, ssa.OpAMD64MOVBstoreconst:
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_CONST
@@ -795,14 +837,14 @@
 		// Break false dependency on destination register.
 		opregreg(s, x86.AXORPS, r, r)
 		opregreg(s, v.Op.Asm(), r, v.Args[0].Reg())
-	case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i:
-		p := s.Prog(x86.AMOVQ)
-		p.From.Type = obj.TYPE_REG
-		p.From.Reg = v.Args[0].Reg()
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
-	case ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i:
-		p := s.Prog(x86.AMOVL)
+	case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i, ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i:
+		var p *obj.Prog
+		switch v.Op {
+		case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i:
+			p = s.Prog(x86.AMOVQ)
+		case ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i:
+			p = s.Prog(x86.AMOVL)
+		}
 		p.From.Type = obj.TYPE_REG
 		p.From.Reg = v.Args[0].Reg()
 		p.To.Type = obj.TYPE_REG
@@ -810,7 +852,8 @@
 	case ssa.OpAMD64ADDQload, ssa.OpAMD64ADDLload, ssa.OpAMD64SUBQload, ssa.OpAMD64SUBLload,
 		ssa.OpAMD64ANDQload, ssa.OpAMD64ANDLload, ssa.OpAMD64ORQload, ssa.OpAMD64ORLload,
 		ssa.OpAMD64XORQload, ssa.OpAMD64XORLload, ssa.OpAMD64ADDSDload, ssa.OpAMD64ADDSSload,
-		ssa.OpAMD64SUBSDload, ssa.OpAMD64SUBSSload, ssa.OpAMD64MULSDload, ssa.OpAMD64MULSSload:
+		ssa.OpAMD64SUBSDload, ssa.OpAMD64SUBSSload, ssa.OpAMD64MULSDload, ssa.OpAMD64MULSSload,
+		ssa.OpAMD64DIVSDload, ssa.OpAMD64DIVSSload:
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_MEM
 		p.From.Reg = v.Args[1].Reg()
@@ -946,24 +989,27 @@
 		p := s.Prog(v.Op.Asm())
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = r
-	case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ:
+
+	case ssa.OpAMD64NEGLflags:
+		r := v.Reg0()
+		if r != v.Args[0].Reg() {
+			v.Fatalf("input[0] and output not in same register %s", v.LongString())
+		}
+		p := s.Prog(v.Op.Asm())
+		p.To.Type = obj.TYPE_REG
+		p.To.Reg = r
+
+	case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ, ssa.OpAMD64BSFL, ssa.OpAMD64BSRL, ssa.OpAMD64SQRTSD:
 		p := s.Prog(v.Op.Asm())
 		p.From.Type = obj.TYPE_REG
 		p.From.Reg = v.Args[0].Reg()
 		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg0()
-	case ssa.OpAMD64BSFL, ssa.OpAMD64BSRL:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_REG
-		p.From.Reg = v.Args[0].Reg()
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
-	case ssa.OpAMD64SQRTSD:
-		p := s.Prog(v.Op.Asm())
-		p.From.Type = obj.TYPE_REG
-		p.From.Reg = v.Args[0].Reg()
-		p.To.Type = obj.TYPE_REG
-		p.To.Reg = v.Reg()
+		switch v.Op {
+		case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ:
+			p.To.Reg = v.Reg0()
+		case ssa.OpAMD64BSFL, ssa.OpAMD64BSRL, ssa.OpAMD64SQRTSD:
+			p.To.Reg = v.Reg()
+		}
 	case ssa.OpAMD64ROUNDSD:
 		p := s.Prog(v.Op.Asm())
 		val := v.AuxInt
@@ -998,7 +1044,8 @@
 		ssa.OpAMD64SETGF, ssa.OpAMD64SETGEF,
 		ssa.OpAMD64SETB, ssa.OpAMD64SETBE,
 		ssa.OpAMD64SETORD, ssa.OpAMD64SETNAN,
-		ssa.OpAMD64SETA, ssa.OpAMD64SETAE:
+		ssa.OpAMD64SETA, ssa.OpAMD64SETAE,
+		ssa.OpAMD64SETO:
 		p := s.Prog(v.Op.Asm())
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = v.Reg()
@@ -1141,6 +1188,8 @@
 	ssa.BlockAMD64GE:  {x86.AJGE, x86.AJLT},
 	ssa.BlockAMD64LE:  {x86.AJLE, x86.AJGT},
 	ssa.BlockAMD64GT:  {x86.AJGT, x86.AJLE},
+	ssa.BlockAMD64OS:  {x86.AJOS, x86.AJOC},
+	ssa.BlockAMD64OC:  {x86.AJOC, x86.AJOS},
 	ssa.BlockAMD64ULT: {x86.AJCS, x86.AJCC},
 	ssa.BlockAMD64UGE: {x86.AJCC, x86.AJCS},
 	ssa.BlockAMD64UGT: {x86.AJHI, x86.AJLS},
@@ -1202,6 +1251,7 @@
 	case ssa.BlockAMD64EQ, ssa.BlockAMD64NE,
 		ssa.BlockAMD64LT, ssa.BlockAMD64GE,
 		ssa.BlockAMD64LE, ssa.BlockAMD64GT,
+		ssa.BlockAMD64OS, ssa.BlockAMD64OC,
 		ssa.BlockAMD64ULT, ssa.BlockAMD64UGT,
 		ssa.BlockAMD64ULE, ssa.BlockAMD64UGE:
 		jmp := blockJump[b.Kind]
diff --git a/src/cmd/compile/internal/arm/galign.go b/src/cmd/compile/internal/arm/galign.go
index 241edaf..8469dbd 100644
--- a/src/cmd/compile/internal/arm/galign.go
+++ b/src/cmd/compile/internal/arm/galign.go
@@ -19,6 +19,7 @@
 	arch.ZeroRange = zerorange
 	arch.ZeroAuto = zeroAuto
 	arch.Ginsnop = ginsnop
+	arch.Ginsnopdefer = ginsnop
 
 	arch.SSAMarkMoves = func(s *gc.SSAGenState, b *ssa.Block) {}
 	arch.SSAGenValue = ssaGenValue
diff --git a/src/cmd/compile/internal/arm/ggen.go b/src/cmd/compile/internal/arm/ggen.go
index b2fc272..f525517 100644
--- a/src/cmd/compile/internal/arm/ggen.go
+++ b/src/cmd/compile/internal/arm/ggen.go
@@ -68,11 +68,12 @@
 	}
 }
 
-func ginsnop(pp *gc.Progs) {
+func ginsnop(pp *gc.Progs) *obj.Prog {
 	p := pp.Prog(arm.AAND)
 	p.From.Type = obj.TYPE_REG
 	p.From.Reg = arm.REG_R0
 	p.To.Type = obj.TYPE_REG
 	p.To.Reg = arm.REG_R0
 	p.Scond = arm.C_SCOND_EQ
+	return p
 }
diff --git a/src/cmd/compile/internal/arm/ssa.go b/src/cmd/compile/internal/arm/ssa.go
index 9862734..9a8fabf 100644
--- a/src/cmd/compile/internal/arm/ssa.go
+++ b/src/cmd/compile/internal/arm/ssa.go
@@ -7,6 +7,7 @@
 import (
 	"fmt"
 	"math"
+	"math/bits"
 
 	"cmd/compile/internal/gc"
 	"cmd/compile/internal/ssa"
@@ -119,6 +120,28 @@
 	return p
 }
 
+// find a (lsb, width) pair for BFC
+// lsb must be in [0, 31], width must be in [1, 32 - lsb]
+// return (0xffffffff, 0) if v is not a binary like 0...01...10...0
+func getBFC(v uint32) (uint32, uint32) {
+	var m, l uint32
+	// BFC is not applicable with zero
+	if v == 0 {
+		return 0xffffffff, 0
+	}
+	// find the lowest set bit, for example l=2 for 0x3ffffffc
+	l = uint32(bits.TrailingZeros32(v))
+	// m-1 represents the highest set bit index, for example m=30 for 0x3ffffffc
+	m = 32 - uint32(bits.LeadingZeros32(v))
+	// check if v is a binary like 0...01...10...0
+	if (1<<m)-(1<<l) == v {
+		// it must be m > l for non-zero v
+		return l, m - l
+	}
+	// invalid
+	return 0xffffffff, 0
+}
+
 func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
 	switch v.Op {
 	case ssa.OpCopy, ssa.OpARMMOVWreg:
@@ -267,16 +290,38 @@
 		p.Reg = v.Args[0].Reg()
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = v.Reg()
+	case ssa.OpARMANDconst, ssa.OpARMBICconst:
+		// try to optimize ANDconst and BICconst to BFC, which saves bytes and ticks
+		// BFC is only available on ARMv7, and its result and source are in the same register
+		if objabi.GOARM == 7 && v.Reg() == v.Args[0].Reg() {
+			var val uint32
+			if v.Op == ssa.OpARMANDconst {
+				val = ^uint32(v.AuxInt)
+			} else { // BICconst
+				val = uint32(v.AuxInt)
+			}
+			lsb, width := getBFC(val)
+			// omit BFC for ARM's imm12
+			if 8 < width && width < 24 {
+				p := s.Prog(arm.ABFC)
+				p.From.Type = obj.TYPE_CONST
+				p.From.Offset = int64(width)
+				p.SetFrom3(obj.Addr{Type: obj.TYPE_CONST, Offset: int64(lsb)})
+				p.To.Type = obj.TYPE_REG
+				p.To.Reg = v.Reg()
+				break
+			}
+		}
+		// fall back to ordinary form
+		fallthrough
 	case ssa.OpARMADDconst,
 		ssa.OpARMADCconst,
 		ssa.OpARMSUBconst,
 		ssa.OpARMSBCconst,
 		ssa.OpARMRSBconst,
 		ssa.OpARMRSCconst,
-		ssa.OpARMANDconst,
 		ssa.OpARMORconst,
 		ssa.OpARMXORconst,
-		ssa.OpARMBICconst,
 		ssa.OpARMSLLconst,
 		ssa.OpARMSRLconst,
 		ssa.OpARMSRAconst:
diff --git a/src/cmd/compile/internal/arm64/galign.go b/src/cmd/compile/internal/arm64/galign.go
index a64be8e..f01fe8a 100644
--- a/src/cmd/compile/internal/arm64/galign.go
+++ b/src/cmd/compile/internal/arm64/galign.go
@@ -19,6 +19,7 @@
 	arch.ZeroRange = zerorange
 	arch.ZeroAuto = zeroAuto
 	arch.Ginsnop = ginsnop
+	arch.Ginsnopdefer = ginsnop
 
 	arch.SSAMarkMoves = func(s *gc.SSAGenState, b *ssa.Block) {}
 	arch.SSAGenValue = ssaGenValue
diff --git a/src/cmd/compile/internal/arm64/ggen.go b/src/cmd/compile/internal/arm64/ggen.go
index f7b3851..9d8fe53 100644
--- a/src/cmd/compile/internal/arm64/ggen.go
+++ b/src/cmd/compile/internal/arm64/ggen.go
@@ -14,10 +14,10 @@
 var darwin = objabi.GOOS == "darwin"
 
 func padframe(frame int64) int64 {
-	// arm64 requires that the frame size (not counting saved LR)
-	// be empty or be 8 mod 16. If not, pad it.
-	if frame != 0 && frame%16 != 8 {
-		frame += 8
+	// arm64 requires that the frame size (not counting saved FP&LR)
+	// be 16 bytes aligned. If not, pad it.
+	if frame%16 != 0 {
+		frame += 16 - (frame % 16)
 	}
 	return frame
 }
@@ -79,7 +79,8 @@
 	}
 }
 
-func ginsnop(pp *gc.Progs) {
+func ginsnop(pp *gc.Progs) *obj.Prog {
 	p := pp.Prog(arm64.AHINT)
 	p.From.Type = obj.TYPE_CONST
+	return p
 }
diff --git a/src/cmd/compile/internal/arm64/ssa.go b/src/cmd/compile/internal/arm64/ssa.go
index c396ba0..87703dd 100644
--- a/src/cmd/compile/internal/arm64/ssa.go
+++ b/src/cmd/compile/internal/arm64/ssa.go
@@ -195,7 +195,9 @@
 		ssa.OpARM64FNMULS,
 		ssa.OpARM64FNMULD,
 		ssa.OpARM64FDIVS,
-		ssa.OpARM64FDIVD:
+		ssa.OpARM64FDIVD,
+		ssa.OpARM64ROR,
+		ssa.OpARM64RORW:
 		r := v.Reg()
 		r1 := v.Args[0].Reg()
 		r2 := v.Args[1].Reg()
@@ -212,7 +214,11 @@
 		ssa.OpARM64FMSUBS,
 		ssa.OpARM64FMSUBD,
 		ssa.OpARM64FNMSUBS,
-		ssa.OpARM64FNMSUBD:
+		ssa.OpARM64FNMSUBD,
+		ssa.OpARM64MADD,
+		ssa.OpARM64MADDW,
+		ssa.OpARM64MSUB,
+		ssa.OpARM64MSUBW:
 		rt := v.Reg()
 		ra := v.Args[0].Reg()
 		rm := v.Args[1].Reg()
@@ -249,6 +255,12 @@
 		p.Reg = v.Args[1].Reg()
 		p.To.Type = obj.TYPE_REG
 		p.To.Reg = v.Reg()
+	case ssa.OpARM64MVNshiftLL, ssa.OpARM64NEGshiftLL:
+		genshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_LL, v.AuxInt)
+	case ssa.OpARM64MVNshiftRL, ssa.OpARM64NEGshiftRL:
+		genshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_LR, v.AuxInt)
+	case ssa.OpARM64MVNshiftRA, ssa.OpARM64NEGshiftRA:
+		genshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_AR, v.AuxInt)
 	case ssa.OpARM64ADDshiftLL,
 		ssa.OpARM64SUBshiftLL,
 		ssa.OpARM64ANDshiftLL,
@@ -311,11 +323,11 @@
 		p.From.Type = obj.TYPE_CONST
 		p.From.Offset = v.AuxInt
 		p.Reg = v.Args[0].Reg()
-	case ssa.OpARM64CMPshiftLL:
+	case ssa.OpARM64CMPshiftLL, ssa.OpARM64CMNshiftLL, ssa.OpARM64TSTshiftLL:
 		genshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_LL, v.AuxInt)
-	case ssa.OpARM64CMPshiftRL:
+	case ssa.OpARM64CMPshiftRL, ssa.OpARM64CMNshiftRL, ssa.OpARM64TSTshiftRL:
 		genshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_LR, v.AuxInt)
-	case ssa.OpARM64CMPshiftRA:
+	case ssa.OpARM64CMPshiftRA, ssa.OpARM64CMNshiftRA, ssa.OpARM64TSTshiftRA:
 		genshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_AR, v.AuxInt)
 	case ssa.OpARM64MOVDaddr:
 		p := s.Prog(arm64.AMOVD)
@@ -369,6 +381,8 @@
 		ssa.OpARM64MOVWloadidx,
 		ssa.OpARM64MOVWUloadidx,
 		ssa.OpARM64MOVDloadidx,
+		ssa.OpARM64FMOVSloadidx,
+		ssa.OpARM64FMOVDloadidx,
 		ssa.OpARM64MOVHloadidx2,
 		ssa.OpARM64MOVHUloadidx2,
 		ssa.OpARM64MOVWloadidx4,
@@ -404,6 +418,8 @@
 		ssa.OpARM64MOVHstoreidx,
 		ssa.OpARM64MOVWstoreidx,
 		ssa.OpARM64MOVDstoreidx,
+		ssa.OpARM64FMOVSstoreidx,
+		ssa.OpARM64FMOVDstoreidx,
 		ssa.OpARM64MOVHstoreidx2,
 		ssa.OpARM64MOVWstoreidx4,
 		ssa.OpARM64MOVDstoreidx8:
@@ -688,8 +704,11 @@
 		fallthrough
 	case ssa.OpARM64MVN,
 		ssa.OpARM64NEG,
+		ssa.OpARM64FABSD,
 		ssa.OpARM64FMOVDfpgp,
 		ssa.OpARM64FMOVDgpfp,
+		ssa.OpARM64FMOVSfpgp,
+		ssa.OpARM64FMOVSgpfp,
 		ssa.OpARM64FNEGS,
 		ssa.OpARM64FNEGD,
 		ssa.OpARM64FSQRTD,
@@ -720,6 +739,7 @@
 		ssa.OpARM64CLZW,
 		ssa.OpARM64FRINTAD,
 		ssa.OpARM64FRINTMD,
+		ssa.OpARM64FRINTND,
 		ssa.OpARM64FRINTPD,
 		ssa.OpARM64FRINTZD:
 		p := s.Prog(v.Op.Asm())
diff --git a/src/cmd/compile/internal/gc/alg.go b/src/cmd/compile/internal/gc/alg.go
index b7d8853..2710e04 100644
--- a/src/cmd/compile/internal/gc/alg.go
+++ b/src/cmd/compile/internal/gc/alg.go
@@ -102,7 +102,7 @@
 	case TINT8, TUINT8, TINT16, TUINT16,
 		TINT32, TUINT32, TINT64, TUINT64,
 		TINT, TUINT, TUINTPTR,
-		TBOOL, TPTR32, TPTR64,
+		TBOOL, TPTR,
 		TCHAN, TUNSAFEPTR:
 		return AMEM, nil
 
@@ -217,7 +217,7 @@
 		// pure memory.
 		hashel := hashfor(t.Elem())
 
-		n := nod(ORANGE, nil, nod(OIND, np, nil))
+		n := nod(ORANGE, nil, nod(ODEREF, np, nil))
 		ni := newname(lookup("i"))
 		ni.Type = types.Types[TINT]
 		n.List.Set1(ni)
@@ -290,28 +290,18 @@
 	funcbody()
 
 	fn.Func.SetDupok(true)
-	fn = typecheck(fn, Etop)
+	fn = typecheck(fn, ctxStmt)
 
 	Curfn = fn
-	typecheckslice(fn.Nbody.Slice(), Etop)
+	typecheckslice(fn.Nbody.Slice(), ctxStmt)
 	Curfn = nil
 
 	if debug_dclstack != 0 {
 		testdclstack()
 	}
 
-	// Disable safemode while compiling this code: the code we
-	// generate internally can refer to unsafe.Pointer.
-	// In this case it can happen if we need to generate an ==
-	// for a struct containing a reflect.Value, which itself has
-	// an unexported field of type unsafe.Pointer.
-	old_safemode := safemode
-	safemode = false
-
 	fn.Func.SetNilCheckDisabled(true)
 	funccompile(fn)
-
-	safemode = old_safemode
 }
 
 func hashfor(t *types.Type) *Node {
@@ -340,6 +330,7 @@
 
 	n := newname(sym)
 	n.SetClass(PFUNC)
+	n.Sym.SetFunc(true)
 	n.Type = functype(nil, []*Node{
 		anonfield(types.NewPtr(t)),
 		anonfield(types.Types[TUINTPTR]),
@@ -384,7 +375,7 @@
 		// pure memory. Even if we unrolled the range loop,
 		// each iteration would be a function call, so don't bother
 		// unrolling.
-		nrange := nod(ORANGE, nil, nod(OIND, np, nil))
+		nrange := nod(ORANGE, nil, nod(ODEREF, np, nil))
 
 		ni := newname(lookup("i"))
 		ni.Type = types.Types[TINT]
@@ -474,32 +465,22 @@
 	funcbody()
 
 	fn.Func.SetDupok(true)
-	fn = typecheck(fn, Etop)
+	fn = typecheck(fn, ctxStmt)
 
 	Curfn = fn
-	typecheckslice(fn.Nbody.Slice(), Etop)
+	typecheckslice(fn.Nbody.Slice(), ctxStmt)
 	Curfn = nil
 
 	if debug_dclstack != 0 {
 		testdclstack()
 	}
 
-	// Disable safemode while compiling this code: the code we
-	// generate internally can refer to unsafe.Pointer.
-	// In this case it can happen if we need to generate an ==
-	// for a struct containing a reflect.Value, which itself has
-	// an unexported field of type unsafe.Pointer.
-	old_safemode := safemode
-	safemode = false
-
 	// Disable checknils while compiling this code.
 	// We are comparing a struct or an array,
 	// neither of which can be nil, and our comparisons
 	// are shallow.
 	fn.Func.SetNilCheckDisabled(true)
 	funccompile(fn)
-
-	safemode = old_safemode
 }
 
 // eqfield returns the node
@@ -516,8 +497,8 @@
 func eqmem(p *Node, q *Node, field *types.Sym, size int64) *Node {
 	nx := nod(OADDR, nodSym(OXDOT, p, field), nil)
 	ny := nod(OADDR, nodSym(OXDOT, q, field), nil)
-	nx = typecheck(nx, Erv)
-	ny = typecheck(ny, Erv)
+	nx = typecheck(nx, ctxExpr)
+	ny = typecheck(ny, ctxExpr)
 
 	fn, needsize := eqmemfunc(size, nx.Type.Elem())
 	call := nod(OCALL, fn, nil)
diff --git a/src/cmd/compile/internal/gc/align.go b/src/cmd/compile/internal/gc/align.go
index 9e752fc..87a7de5 100644
--- a/src/cmd/compile/internal/gc/align.go
+++ b/src/cmd/compile/internal/gc/align.go
@@ -208,7 +208,7 @@
 	}
 
 	t.Width = -2
-	t.Align = 0
+	t.Align = 0 // 0 means use t.Width, below
 
 	et := t.Etype
 	switch et {
@@ -222,7 +222,7 @@
 		}
 	}
 
-	w := int64(0)
+	var w int64
 	switch et {
 	default:
 		Fatalf("dowidth: unknown type: %v", t)
@@ -250,12 +250,8 @@
 		w = 16
 		t.Align = uint8(Widthreg)
 
-	case TPTR32:
-		w = 4
-		checkwidth(t.Elem())
-
-	case TPTR64:
-		w = 8
+	case TPTR:
+		w = int64(Widthptr)
 		checkwidth(t.Elem())
 
 	case TUNSAFEPTR:
@@ -370,7 +366,7 @@
 
 	t.Width = w
 	if t.Align == 0 {
-		if w > 8 || w&(w-1) != 0 || w == 0 {
+		if w == 0 || w > 8 || w&(w-1) != 0 {
 			Fatalf("invalid alignment for %v", t)
 		}
 		t.Align = uint8(w)
@@ -427,12 +423,11 @@
 		return
 	}
 
-	if t.Deferwidth() {
-		return
+	// if type has not yet been pushed on deferredTypeStack yet, do it now
+	if !t.Deferwidth() {
+		t.SetDeferwidth(true)
+		deferredTypeStack = append(deferredTypeStack, t)
 	}
-	t.SetDeferwidth(true)
-
-	deferredTypeStack = append(deferredTypeStack, t)
 }
 
 func defercheckwidth() {
@@ -447,6 +442,7 @@
 	if defercalc == 0 {
 		Fatalf("resumecheckwidth")
 	}
+
 	for len(deferredTypeStack) > 0 {
 		t := deferredTypeStack[len(deferredTypeStack)-1]
 		deferredTypeStack = deferredTypeStack[:len(deferredTypeStack)-1]
diff --git a/src/cmd/compile/internal/gc/bexport.go b/src/cmd/compile/internal/gc/bexport.go
index d0b1804..7c09ab5 100644
--- a/src/cmd/compile/internal/gc/bexport.go
+++ b/src/cmd/compile/internal/gc/bexport.go
@@ -2,444 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Binary package export.
-
-/*
-1) Export data encoding principles:
-
-The export data is a serialized description of the graph of exported
-"objects": constants, types, variables, and functions. Aliases may be
-directly reexported, and unaliased types may be indirectly reexported
-(as part of the type of a directly exported object). More generally,
-objects referred to from inlined function bodies can be reexported.
-We need to know which package declares these reexported objects, and
-therefore packages are also part of the export graph.
-
-The roots of the graph are two lists of objects. The 1st list (phase 1,
-see Export) contains all objects that are exported at the package level.
-These objects are the full representation of the package's API, and they
-are the only information a platform-independent tool (e.g., go/types)
-needs to know to type-check against a package.
-
-The 2nd list of objects contains all objects referred to from exported
-inlined function bodies. These objects are needed by the compiler to
-make sense of the function bodies; the exact list contents are compiler-
-specific.
-
-Finally, the export data contains a list of representations for inlined
-function bodies. The format of this representation is compiler specific.
-
-The graph is serialized in in-order fashion, starting with the roots.
-Each object in the graph is serialized by writing its fields sequentially.
-If the field is a pointer to another object, that object is serialized in
-place, recursively. Otherwise the field is written in place. Non-pointer
-fields are all encoded as integer or string values.
-
-Some objects (packages, types) may be referred to more than once. When
-reaching an object that was not serialized before, an integer _index_
-is assigned to it, starting at 0. In this case, the encoding starts
-with an integer _tag_ < 0. The tag value indicates the kind of object
-that follows and that this is the first time that we see this object.
-If the object was already serialized, the encoding is simply the object
-index >= 0. An importer can trivially determine if an object needs to
-be read in for the first time (tag < 0) and entered into the respective
-object table, or if the object was seen already (index >= 0), in which
-case the index is used to look up the object in the respective table.
-
-Before exporting or importing, the type tables are populated with the
-predeclared types (int, string, error, unsafe.Pointer, etc.). This way
-they are automatically encoded with a known and fixed type index.
-
-2) Encoding format:
-
-The export data starts with two newline-terminated strings: a version
-string and either an empty string, or "debug", when emitting the debug
-format. These strings are followed by version-specific encoding options.
-
-(The Go1.7 version starts with a couple of bytes specifying the format.
-That format encoding is no longer used but is supported to avoid spurious
-errors when importing old installed package files.)
-
-This header is followed by the package object for the exported package,
-two lists of objects, and the list of inlined function bodies.
-
-The encoding of objects is straight-forward: Constants, variables, and
-functions start with their name, type, and possibly a value. Named types
-record their name and package so that they can be canonicalized: If the
-same type was imported before via another import, the importer must use
-the previously imported type pointer so that we have exactly one version
-(i.e., one pointer) for each named type (and read but discard the current
-type encoding). Unnamed types simply encode their respective fields.
-Aliases are encoded starting with their name followed by the qualified
-identifier denoting the original (aliased) object, which was exported
-earlier.
-
-In the encoding, some lists start with the list length. Some lists are
-terminated with an end marker (usually for lists where we may not know
-the length a priori).
-
-Integers use variable-length encoding for compact representation.
-
-Strings are canonicalized similar to objects that may occur multiple times:
-If the string was exported already, it is represented by its index only.
-Otherwise, the export data starts with the negative string length (negative,
-so we can distinguish from string index), followed by the string bytes.
-The empty string is mapped to index 0. (The initial format string is an
-exception; it is encoded as the string bytes followed by a newline).
-
-The exporter and importer are completely symmetric in implementation: For
-each encoding routine there is a matching and symmetric decoding routine.
-This symmetry makes it very easy to change or extend the format: If a new
-field needs to be encoded, a symmetric change can be made to exporter and
-importer.
-
-3) Making changes to the encoding format:
-
-Any change to the encoding format requires a respective change in the
-exporter below and a corresponding symmetric change to the importer in
-bimport.go.
-
-Furthermore, it requires a corresponding change to go/internal/gcimporter
-and golang.org/x/tools/go/gcimporter15. Changes to the latter must preserve
-compatibility with both the last release of the compiler, and with the
-corresponding compiler at tip. That change is necessarily more involved,
-as it must switch based on the version number in the export data file.
-
-It is recommended to turn on debugFormat temporarily when working on format
-changes as it will help finding encoding/decoding inconsistencies quickly.
-*/
-
 package gc
 
 import (
-	"bufio"
-	"bytes"
 	"cmd/compile/internal/types"
-	"cmd/internal/src"
-	"encoding/binary"
-	"fmt"
-	"math/big"
-	"sort"
-	"strings"
 )
 
-// If debugFormat is set, each integer and string value is preceded by a marker
-// and position information in the encoding. This mechanism permits an importer
-// to recognize immediately when it is out of sync. The importer recognizes this
-// mode automatically (i.e., it can import export data produced with debugging
-// support even if debugFormat is not set at the time of import). This mode will
-// lead to massively larger export data (by a factor of 2 to 3) and should only
-// be enabled during development and debugging.
-//
-// NOTE: This flag is the first flag to enable if importing dies because of
-// (suspected) format errors, and whenever a change is made to the format.
-const debugFormat = false // default: false
-
-// Current export format version. Increase with each format change.
-// 6: package height (CL 105038)
-// 5: improved position encoding efficiency (issue 20080, CL 41619)
-// 4: type name objects support type aliases, uses aliasTag
-// 3: Go1.8 encoding (same as version 2, aliasTag defined but never used)
-// 2: removed unused bool in ODCL export (compiler only)
-// 1: header format change (more regular), export package for _ struct fields
-// 0: Go1.7 encoding
-const exportVersion = 6
-
-// exportInlined enables the export of inlined function bodies and related
-// dependencies. The compiler should work w/o any loss of functionality with
-// the flag disabled, but the generated code will lose access to inlined
-// function bodies across packages, leading to performance bugs.
-// Leave for debugging.
-const exportInlined = true // default: true
-
-// trackAllTypes enables cycle tracking for all types, not just named
-// types. The existing compiler invariants assume that unnamed types
-// that are not completely set up are not used, or else there are spurious
-// errors.
-// If disabled, only named types are tracked, possibly leading to slightly
-// less efficient encoding in rare cases. It also prevents the export of
-// some corner-case type declarations (but those were not handled correctly
-// with the former textual export format either).
-// Note that when a type is only seen once, as many unnamed types are,
-// it is less efficient to track it, since we then also record an index for it.
-// See CLs 41622 and 41623 for some data and discussion.
-// TODO(gri) enable selectively and remove once issues caused by it are fixed
-const trackAllTypes = false
-
 type exporter struct {
-	out *bufio.Writer
-
-	// object -> index maps, indexed in order of serialization
-	strIndex  map[string]int
-	pathIndex map[string]int
-	pkgIndex  map[*types.Pkg]int
-	typIndex  map[*types.Type]int
-	funcList  []*Func
-
 	marked map[*types.Type]bool // types already seen by markType
-
-	// position encoding
-	posInfoFormat bool
-	prevFile      string
-	prevLine      int
-
-	// debugging support
-	written int // bytes written
-	indent  int // for p.trace
-	trace   bool
-}
-
-// export writes the exportlist for localpkg to out and returns the number of bytes written.
-func export(out *bufio.Writer, trace bool) int {
-	p := exporter{
-		out:           out,
-		strIndex:      map[string]int{"": 0}, // empty string is mapped to 0
-		pathIndex:     map[string]int{"": 0}, // empty path is mapped to 0
-		pkgIndex:      make(map[*types.Pkg]int),
-		typIndex:      make(map[*types.Type]int),
-		posInfoFormat: true,
-		trace:         trace,
-	}
-
-	// write version info
-	// The version string must start with "version %d" where %d is the version
-	// number. Additional debugging information may follow after a blank; that
-	// text is ignored by the importer.
-	p.rawStringln(fmt.Sprintf("version %d", exportVersion))
-	var debug string
-	if debugFormat {
-		debug = "debug"
-	}
-	p.rawStringln(debug) // cannot use p.bool since it's affected by debugFormat; also want to see this clearly
-	p.bool(trackAllTypes)
-	p.bool(p.posInfoFormat)
-
-	// --- generic export data ---
-
-	// populate type map with predeclared "known" types
-	predecl := predeclared()
-	for index, typ := range predecl {
-		p.typIndex[typ] = index
-	}
-	if len(p.typIndex) != len(predecl) {
-		Fatalf("exporter: duplicate entries in type map?")
-	}
-
-	// write package data
-	if localpkg.Path != "" {
-		Fatalf("exporter: local package path not empty: %q", localpkg.Path)
-	}
-	p.pkg(localpkg)
-	if p.trace {
-		p.tracef("\n")
-	}
-
-	// export objects
-	//
-	// We've already added all exported (package-level) objects to
-	// exportlist. These objects represent all information
-	// required to import this package and type-check against it;
-	// i.e., this is the platform-independent export data. The
-	// format is generic in the sense that different compilers can
-	// use the same representation.
-	//
-	// However, due to inlineable function and their dependencies,
-	// we may need to export (or possibly reexport) additional
-	// objects. We handle these objects separately. This data is
-	// platform-specific as it depends on the inlining decisions
-	// of the compiler and the representation of the inlined
-	// function bodies.
-
-	// Remember initial exportlist length.
-	numglobals := len(exportlist)
-
-	// Phase 0: Mark all inlineable functions that an importing
-	// package could call. This is done by tracking down all
-	// inlineable methods reachable from exported declarations.
-	//
-	// Along the way, we add to exportlist any function and
-	// variable declarations needed by the inline bodies.
-	if exportInlined {
-		p.marked = make(map[*types.Type]bool)
-		for _, n := range exportlist {
-			sym := n.Sym
-			p.markType(asNode(sym.Def).Type)
-		}
-		p.marked = nil
-	}
-
-	// Phase 1: Export package-level objects.
-	objcount := 0
-	for _, n := range exportlist[:numglobals] {
-		sym := n.Sym
-
-		// TODO(gri) Closures have dots in their names;
-		// e.g., TestFloatZeroValue.func1 in math/big tests.
-		if strings.Contains(sym.Name, ".") {
-			Fatalf("exporter: unexpected symbol: %v", sym)
-		}
-
-		if sym.Def == nil {
-			Fatalf("exporter: unknown export symbol: %v", sym)
-		}
-
-		// TODO(gri) Optimization: Probably worthwhile collecting
-		// long runs of constants and export them "in bulk" (saving
-		// tags and types, and making import faster).
-
-		if p.trace {
-			p.tracef("\n")
-		}
-		p.obj(sym)
-		objcount++
-	}
-
-	// indicate end of list
-	if p.trace {
-		p.tracef("\n")
-	}
-	p.tag(endTag)
-
-	// for self-verification only (redundant)
-	p.int(objcount)
-
-	// --- compiler-specific export data ---
-
-	if p.trace {
-		p.tracef("\n--- compiler-specific export data ---\n[ ")
-		if p.indent != 0 {
-			Fatalf("exporter: incorrect indentation")
-		}
-	}
-
-	// write compiler-specific flags
-	if p.trace {
-		p.tracef("\n")
-	}
-
-	// Phase 2: Export objects added to exportlist during phase 0.
-	objcount = 0
-	for _, n := range exportlist[numglobals:] {
-		sym := n.Sym
-
-		// TODO(gri) The rest of this loop body is identical with
-		// the loop body above. Leave alone for now since there
-		// are different optimization opportunities, but factor
-		// eventually.
-
-		// TODO(gri) Closures have dots in their names;
-		// e.g., TestFloatZeroValue.func1 in math/big tests.
-		if strings.Contains(sym.Name, ".") {
-			Fatalf("exporter: unexpected symbol: %v", sym)
-		}
-
-		if sym.Def == nil {
-			Fatalf("exporter: unknown export symbol: %v", sym)
-		}
-
-		// TODO(gri) Optimization: Probably worthwhile collecting
-		// long runs of constants and export them "in bulk" (saving
-		// tags and types, and making import faster).
-
-		if p.trace {
-			p.tracef("\n")
-		}
-
-		if IsAlias(sym) {
-			Fatalf("exporter: unexpected type alias %v in inlined function body", sym)
-		}
-
-		p.obj(sym)
-		objcount++
-	}
-
-	// indicate end of list
-	if p.trace {
-		p.tracef("\n")
-	}
-	p.tag(endTag)
-
-	// for self-verification only (redundant)
-	p.int(objcount)
-
-	// --- inlined function bodies ---
-
-	if p.trace {
-		p.tracef("\n--- inlined function bodies ---\n")
-		if p.indent != 0 {
-			Fatalf("exporter: incorrect indentation")
-		}
-	}
-
-	// write inlineable function bodies
-	// Don't use range since funcList may grow.
-	objcount = 0
-	for i := 0; i < len(p.funcList); i++ {
-		if f := p.funcList[i]; f.ExportInline() {
-			// function has inlineable body:
-			// write index and body
-			if p.trace {
-				p.tracef("\n----\nfunc { %#v }\n", asNodes(f.Inl.Body))
-			}
-			p.int(i)
-			p.int(int(f.Inl.Cost))
-			p.stmtList(asNodes(f.Inl.Body))
-			if p.trace {
-				p.tracef("\n")
-			}
-			objcount++
-		}
-	}
-
-	// indicate end of list
-	if p.trace {
-		p.tracef("\n")
-	}
-	p.int(-1) // invalid index terminates list
-
-	// for self-verification only (redundant)
-	p.int(objcount)
-
-	if p.trace {
-		p.tracef("\n--- end ---\n")
-	}
-
-	// --- end of export data ---
-
-	return p.written
-}
-
-func (p *exporter) pkg(pkg *types.Pkg) {
-	if pkg == nil {
-		Fatalf("exporter: unexpected nil pkg")
-	}
-
-	// if we saw the package before, write its index (>= 0)
-	if i, ok := p.pkgIndex[pkg]; ok {
-		p.index('P', i)
-		return
-	}
-
-	// otherwise, remember the package, write the package tag (< 0) and package data
-	if p.trace {
-		p.tracef("P%d = { ", len(p.pkgIndex))
-		defer p.tracef("} ")
-	}
-	p.pkgIndex[pkg] = len(p.pkgIndex)
-
-	p.tag(packageTag)
-	p.string(pkg.Name)
-	p.path(pkg.Path)
-	p.int(pkg.Height)
-}
-
-func unidealType(typ *types.Type, val Val) *types.Type {
-	// Untyped (ideal) constants get their own type. This decouples
-	// the constant type from the encoding of the constant value.
-	if typ == nil || typ.IsUntyped() {
-		typ = untype(val.Ctype())
-	}
-	return typ
 }
 
 // markType recursively visits types reachable from t to identify
@@ -473,7 +43,7 @@
 	// the user already needs some way to construct values of
 	// those types.
 	switch t.Etype {
-	case TPTR32, TPTR64, TARRAY, TSLICE, TCHAN:
+	case TPTR, TARRAY, TSLICE, TCHAN:
 		// TODO(mdempsky): Skip marking element type for
 		// send-only channels?
 		p.markType(t.Elem())
@@ -508,1287 +78,11 @@
 	}
 }
 
-func (p *exporter) obj(sym *types.Sym) {
-	// Exported objects may be from different packages because they
-	// may be re-exported via an exported alias or as dependencies in
-	// exported inlined function bodies. Thus, exported object names
-	// must be fully qualified.
-	//
-	// (This can only happen for aliased objects or during phase 2
-	// (exportInlined enabled) of object export. Unaliased Objects
-	// exported in phase 1 (compiler-indendepent objects) are by
-	// definition only the objects from the current package and not
-	// pulled in via inlined function bodies. In that case the package
-	// qualifier is not needed. Possible space optimization.)
-
-	n := asNode(sym.Def)
-	switch n.Op {
-	case OLITERAL:
-		// constant
-		// TODO(gri) determine if we need the typecheck call here
-		n = typecheck(n, Erv)
-		if n == nil || n.Op != OLITERAL {
-			Fatalf("exporter: dumpexportconst: oconst nil: %v", sym)
-		}
-
-		p.tag(constTag)
-		p.pos(n.Pos)
-		// TODO(gri) In inlined functions, constants are used directly
-		// so they should never occur as re-exported objects. We may
-		// not need the qualified name here. See also comment above.
-		// Possible space optimization.
-		p.qualifiedName(sym)
-		p.typ(unidealType(n.Type, n.Val()))
-		p.value(n.Val())
-
-	case OTYPE:
-		// named type
-		t := n.Type
-		if t.Etype == TFORW {
-			Fatalf("exporter: export of incomplete type %v", sym)
-		}
-
-		if IsAlias(sym) {
-			p.tag(aliasTag)
-			p.pos(n.Pos)
-			p.qualifiedName(sym)
-		} else {
-			p.tag(typeTag)
-		}
-		p.typ(t)
-
-	case ONAME:
-		// variable or function
-		n = typecheck(n, Erv|Ecall)
-		if n == nil || n.Type == nil {
-			Fatalf("exporter: variable/function exported but not defined: %v", sym)
-		}
-
-		if n.Type.Etype == TFUNC && n.Class() == PFUNC {
-			// function
-			p.tag(funcTag)
-			p.pos(n.Pos)
-			p.qualifiedName(sym)
-
-			sig := asNode(sym.Def).Type
-
-			// Theoretically, we only need numbered
-			// parameters if we're supplying an inline
-			// function body. However, it's possible to
-			// import a function from a package that
-			// didn't supply the inline body, and then
-			// another that did. In this case, we would
-			// need to rename the parameters during
-			// import, which is a little sketchy.
-			//
-			// For simplicity, just always number
-			// parameters.
-			p.paramList(sig.Params(), true)
-			p.paramList(sig.Results(), true)
-
-			p.funcList = append(p.funcList, asNode(sym.Def).Func)
-		} else {
-			// variable
-			p.tag(varTag)
-			p.pos(n.Pos)
-			p.qualifiedName(sym)
-			p.typ(asNode(sym.Def).Type)
-		}
-
-	default:
-		Fatalf("exporter: unexpected export symbol: %v %v", n.Op, sym)
-	}
-}
-
 // deltaNewFile is a magic line delta offset indicating a new file.
 // We use -64 because it is rare; see issue 20080 and CL 41619.
 // -64 is the smallest int that fits in a single byte as a varint.
 const deltaNewFile = -64
 
-func (p *exporter) pos(pos src.XPos) {
-	if !p.posInfoFormat {
-		return
-	}
-
-	file, line := fileLine(pos)
-	if file == p.prevFile {
-		// common case: write line delta
-		// delta == deltaNewFile means different file
-		// if the actual line delta is deltaNewFile,
-		// follow up with a negative int to indicate that.
-		// only non-negative ints can follow deltaNewFile
-		// when writing a new file.
-		delta := line - p.prevLine
-		p.int(delta)
-		if delta == deltaNewFile {
-			p.int(-1) // -1 means no file change
-		}
-	} else {
-		// different file
-		p.int(deltaNewFile)
-		p.int(line) // line >= 0
-		p.path(file)
-		p.prevFile = file
-	}
-	p.prevLine = line
-}
-
-func (p *exporter) path(s string) {
-	if i, ok := p.pathIndex[s]; ok {
-		// Note: Using p.index(i) here requires the use of p.tag(-len(c)) below
-		//       to get matching debug markers ('t'). But in trace mode p.tag
-		//       assumes that the tag argument is a valid tag that can be looked
-		//       up in the tagString list, rather then some arbitrary slice length.
-		//       Use p.int instead.
-		p.int(i) // i >= 0
-		return
-	}
-	p.pathIndex[s] = len(p.pathIndex)
-	c := strings.Split(s, "/")
-	p.int(-len(c)) // -len(c) < 0
-	for _, x := range c {
-		p.string(x)
-	}
-}
-
-func fileLine(pos0 src.XPos) (file string, line int) {
-	pos := Ctxt.PosTable.Pos(pos0)
-	file = pos.Base().AbsFilename()
-	line = int(pos.RelLine())
-	return
-}
-
-func (p *exporter) typ(t *types.Type) {
-	if t == nil {
-		Fatalf("exporter: nil type")
-	}
-
-	// Possible optimization: Anonymous pointer types *T where
-	// T is a named type are common. We could canonicalize all
-	// such types *T to a single type PT = *T. This would lead
-	// to at most one *T entry in typIndex, and all future *T's
-	// would be encoded as the respective index directly. Would
-	// save 1 byte (pointerTag) per *T and reduce the typIndex
-	// size (at the cost of a canonicalization map). We can do
-	// this later, without encoding format change.
-
-	// if we saw the type before, write its index (>= 0)
-	if i, ok := p.typIndex[t]; ok {
-		p.index('T', i)
-		return
-	}
-
-	// otherwise, remember the type, write the type tag (< 0) and type data
-	if trackAllTypes {
-		if p.trace {
-			p.tracef("T%d = {>\n", len(p.typIndex))
-			defer p.tracef("<\n} ")
-		}
-		p.typIndex[t] = len(p.typIndex)
-	}
-
-	// pick off named types
-	if tsym := t.Sym; tsym != nil {
-		if !trackAllTypes {
-			// if we don't track all types, track named types now
-			p.typIndex[t] = len(p.typIndex)
-		}
-
-		// Predeclared types should have been found in the type map.
-		if t.Orig == t {
-			Fatalf("exporter: predeclared type missing from type map?")
-		}
-
-		n := typenod(t)
-		if n.Type != t {
-			Fatalf("exporter: named type definition incorrectly set up")
-		}
-
-		p.tag(namedTag)
-		p.pos(n.Pos)
-		p.qualifiedName(tsym)
-
-		// write underlying type
-		p.typ(t.Orig)
-
-		// interfaces don't have associated methods
-		if t.Orig.IsInterface() {
-			return
-		}
-
-		// sort methods for reproducible export format
-		// TODO(gri) Determine if they are already sorted
-		// in which case we can drop this step.
-		var methods []*types.Field
-		methods = append(methods, t.Methods().Slice()...)
-		sort.Sort(methodbyname(methods))
-		p.int(len(methods))
-
-		if p.trace && len(methods) > 0 {
-			p.tracef("associated methods {>")
-		}
-
-		for _, m := range methods {
-			if p.trace {
-				p.tracef("\n")
-			}
-			if strings.Contains(m.Sym.Name, ".") {
-				Fatalf("invalid symbol name: %s (%v)", m.Sym.Name, m.Sym)
-			}
-
-			p.pos(m.Pos)
-			p.fieldSym(m.Sym, false)
-
-			sig := m.Type
-			mfn := asNode(sig.FuncType().Nname)
-
-			// See comment in (*exporter).obj about
-			// numbered parameters.
-			p.paramList(sig.Recvs(), true)
-			p.paramList(sig.Params(), true)
-			p.paramList(sig.Results(), true)
-			p.bool(m.Nointerface()) // record go:nointerface pragma value (see also #16243)
-
-			p.funcList = append(p.funcList, mfn.Func)
-		}
-
-		if p.trace && len(methods) > 0 {
-			p.tracef("<\n} ")
-		}
-
-		return
-	}
-
-	// otherwise we have a type literal
-	switch t.Etype {
-	case TARRAY:
-		if t.IsDDDArray() {
-			Fatalf("array bounds should be known at export time: %v", t)
-		}
-		p.tag(arrayTag)
-		p.int64(t.NumElem())
-		p.typ(t.Elem())
-
-	case TSLICE:
-		p.tag(sliceTag)
-		p.typ(t.Elem())
-
-	case TDDDFIELD:
-		// see p.param use of TDDDFIELD
-		p.tag(dddTag)
-		p.typ(t.DDDField())
-
-	case TSTRUCT:
-		p.tag(structTag)
-		p.fieldList(t)
-
-	case TPTR32, TPTR64: // could use Tptr but these are constants
-		p.tag(pointerTag)
-		p.typ(t.Elem())
-
-	case TFUNC:
-		p.tag(signatureTag)
-		p.paramList(t.Params(), false)
-		p.paramList(t.Results(), false)
-
-	case TINTER:
-		p.tag(interfaceTag)
-		p.methodList(t)
-
-	case TMAP:
-		p.tag(mapTag)
-		p.typ(t.Key())
-		p.typ(t.Elem())
-
-	case TCHAN:
-		p.tag(chanTag)
-		p.int(int(t.ChanDir()))
-		p.typ(t.Elem())
-
-	default:
-		Fatalf("exporter: unexpected type: %v (Etype = %d)", t, t.Etype)
-	}
-}
-
-func (p *exporter) qualifiedName(sym *types.Sym) {
-	p.string(sym.Name)
-	p.pkg(sym.Pkg)
-}
-
-func (p *exporter) fieldList(t *types.Type) {
-	if p.trace && t.NumFields() > 0 {
-		p.tracef("fields {>")
-		defer p.tracef("<\n} ")
-	}
-
-	p.int(t.NumFields())
-	for _, f := range t.Fields().Slice() {
-		if p.trace {
-			p.tracef("\n")
-		}
-		p.field(f)
-	}
-}
-
-func (p *exporter) field(f *types.Field) {
-	p.pos(f.Pos)
-	p.fieldName(f)
-	p.typ(f.Type)
-	p.string(f.Note)
-}
-
-func (p *exporter) methodList(t *types.Type) {
-	var embeddeds, methods []*types.Field
-
-	for _, m := range t.Methods().Slice() {
-		if m.Sym != nil {
-			methods = append(methods, m)
-		} else {
-			embeddeds = append(embeddeds, m)
-		}
-	}
-
-	if p.trace && len(embeddeds) > 0 {
-		p.tracef("embeddeds {>")
-	}
-	p.int(len(embeddeds))
-	for _, m := range embeddeds {
-		if p.trace {
-			p.tracef("\n")
-		}
-		p.pos(m.Pos)
-		p.typ(m.Type)
-	}
-	if p.trace && len(embeddeds) > 0 {
-		p.tracef("<\n} ")
-	}
-
-	if p.trace && len(methods) > 0 {
-		p.tracef("methods {>")
-	}
-	p.int(len(methods))
-	for _, m := range methods {
-		if p.trace {
-			p.tracef("\n")
-		}
-		p.method(m)
-	}
-	if p.trace && len(methods) > 0 {
-		p.tracef("<\n} ")
-	}
-}
-
-func (p *exporter) method(m *types.Field) {
-	p.pos(m.Pos)
-	p.methodName(m.Sym)
-	p.paramList(m.Type.Params(), false)
-	p.paramList(m.Type.Results(), false)
-}
-
-func (p *exporter) fieldName(t *types.Field) {
-	name := t.Sym.Name
-	if t.Embedded != 0 {
-		// anonymous field - we distinguish between 3 cases:
-		// 1) field name matches base type name and is exported
-		// 2) field name matches base type name and is not exported
-		// 3) field name doesn't match base type name (alias name)
-		bname := basetypeName(t.Type)
-		if name == bname {
-			if types.IsExported(name) {
-				name = "" // 1) we don't need to know the field name or package
-			} else {
-				name = "?" // 2) use unexported name "?" to force package export
-			}
-		} else {
-			// 3) indicate alias and export name as is
-			// (this requires an extra "@" but this is a rare case)
-			p.string("@")
-		}
-	}
-	p.string(name)
-	if name != "" && !types.IsExported(name) {
-		p.pkg(t.Sym.Pkg)
-	}
-}
-
-// methodName is like qualifiedName but it doesn't record the package for exported names.
-func (p *exporter) methodName(sym *types.Sym) {
-	p.string(sym.Name)
-	if !types.IsExported(sym.Name) {
-		p.pkg(sym.Pkg)
-	}
-}
-
-func basetypeName(t *types.Type) string {
-	s := t.Sym
-	if s == nil && t.IsPtr() {
-		s = t.Elem().Sym // deref
-	}
-	if s != nil {
-		return s.Name
-	}
-	return "" // unnamed type
-}
-
-func (p *exporter) paramList(params *types.Type, numbered bool) {
-	if !params.IsFuncArgStruct() {
-		Fatalf("exporter: parameter list expected")
-	}
-
-	// use negative length to indicate unnamed parameters
-	// (look at the first parameter only since either all
-	// names are present or all are absent)
-	//
-	// TODO(gri) If we don't have an exported function
-	// body, the parameter names are irrelevant for the
-	// compiler (though they may be of use for other tools).
-	// Possible space optimization.
-	n := params.NumFields()
-	if n > 0 && parName(params.Field(0), numbered) == "" {
-		n = -n
-	}
-	p.int(n)
-	for _, q := range params.Fields().Slice() {
-		p.param(q, n, numbered)
-	}
-}
-
-func (p *exporter) param(q *types.Field, n int, numbered bool) {
-	t := q.Type
-	if q.Isddd() {
-		// create a fake type to encode ... just for the p.typ call
-		t = types.NewDDDField(t.Elem())
-	}
-	p.typ(t)
-	if n > 0 {
-		name := parName(q, numbered)
-		if name == "" {
-			// Sometimes we see an empty name even for n > 0.
-			// This appears to happen for interface methods
-			// with _ (blank) parameter names. Make sure we
-			// have a proper name and package so we don't crash
-			// during import (see also issue #15470).
-			// (parName uses "" instead of "?" as in fmt.go)
-			// TODO(gri) review parameter name encoding
-			name = "_"
-		}
-		p.string(name)
-		if name != "_" {
-			// Because of (re-)exported inlined functions
-			// the importpkg may not be the package to which this
-			// function (and thus its parameter) belongs. We need to
-			// supply the parameter package here. We need the package
-			// when the function is inlined so we can properly resolve
-			// the name. The _ (blank) parameter cannot be accessed, so
-			// we don't need to export a package.
-			//
-			// TODO(gri) This is compiler-specific. Try using importpkg
-			// here and then update the symbols if we find an inlined
-			// body only. Otherwise, the parameter name is ignored and
-			// the package doesn't matter. This would remove an int
-			// (likely 1 byte) for each named parameter.
-			p.pkg(q.Sym.Pkg)
-		}
-	}
-	// TODO(gri) This is compiler-specific (escape info).
-	// Move into compiler-specific section eventually?
-	// (Not having escape info causes tests to fail, e.g. runtime GCInfoTest)
-	p.string(q.Note)
-}
-
-func parName(f *types.Field, numbered bool) string {
-	s := origSym(f.Sym)
-	if s == nil {
-		return ""
-	}
-
-	if s.Name == "_" {
-		return "_"
-	}
-
-	// print symbol with Vargen number or not as desired
-	name := s.Name
-	if strings.Contains(name, ".") {
-		Fatalf("invalid symbol name: %s", name)
-	}
-
-	// Functions that can be inlined use numbered parameters so we can distinguish them
-	// from other names in their context after inlining (i.e., the parameter numbering
-	// is a form of parameter rewriting). See issue 4326 for an example and test case.
-	if numbered {
-		if n := asNode(f.Nname); !strings.Contains(name, "·") && n != nil && n.Name.Vargen > 0 {
-			name = fmt.Sprintf("%s·%d", name, n.Name.Vargen) // append Vargen
-		}
-	} else {
-		if i := strings.Index(name, "·"); i > 0 {
-			name = name[:i] // cut off Vargen
-		}
-	}
-	return name
-}
-
-func (p *exporter) value(x Val) {
-	if p.trace {
-		p.tracef("= ")
-	}
-
-	switch x := x.U.(type) {
-	case bool:
-		tag := falseTag
-		if x {
-			tag = trueTag
-		}
-		p.tag(tag)
-
-	case *Mpint:
-		if minintval[TINT64].Cmp(x) <= 0 && x.Cmp(maxintval[TINT64]) <= 0 {
-			// common case: x fits into an int64 - use compact encoding
-			p.tag(int64Tag)
-			p.int64(x.Int64())
-			return
-		}
-		// uncommon case: large x - use float encoding
-		// (powers of 2 will be encoded efficiently with exponent)
-		f := newMpflt()
-		f.SetInt(x)
-		p.tag(floatTag)
-		p.float(f)
-
-	case *Mpflt:
-		p.tag(floatTag)
-		p.float(x)
-
-	case *Mpcplx:
-		p.tag(complexTag)
-		p.float(&x.Real)
-		p.float(&x.Imag)
-
-	case string:
-		p.tag(stringTag)
-		p.string(x)
-
-	case *NilVal:
-		// not a constant but used in exported function bodies
-		p.tag(nilTag)
-
-	default:
-		Fatalf("exporter: unexpected value %v (%T)", x, x)
-	}
-}
-
-func (p *exporter) float(x *Mpflt) {
-	// extract sign (there is no -0)
-	f := &x.Val
-	sign := f.Sign()
-	if sign == 0 {
-		// x == 0
-		p.int(0)
-		return
-	}
-	// x != 0
-
-	// extract exponent such that 0.5 <= m < 1.0
-	var m big.Float
-	exp := f.MantExp(&m)
-
-	// extract mantissa as *big.Int
-	// - set exponent large enough so mant satisfies mant.IsInt()
-	// - get *big.Int from mant
-	m.SetMantExp(&m, int(m.MinPrec()))
-	mant, acc := m.Int(nil)
-	if acc != big.Exact {
-		Fatalf("exporter: internal error")
-	}
-
-	p.int(sign)
-	p.int(exp)
-	p.string(string(mant.Bytes()))
-}
-
-// ----------------------------------------------------------------------------
-// Inlined function bodies
-
-// Approach: More or less closely follow what fmt.go is doing for FExp mode
-// but instead of emitting the information textually, emit the node tree in
-// binary form.
-
-// TODO(gri) Improve tracing output. The current format is difficult to read.
-
-// stmtList may emit more (or fewer) than len(list) nodes.
-func (p *exporter) stmtList(list Nodes) {
-	if p.trace {
-		if list.Len() == 0 {
-			p.tracef("{}")
-		} else {
-			p.tracef("{>")
-			defer p.tracef("<\n}")
-		}
-	}
-
-	for _, n := range list.Slice() {
-		if p.trace {
-			p.tracef("\n")
-		}
-		// TODO inlining produces expressions with ninits. we can't export these yet.
-		// (from fmt.go:1461ff)
-		p.node(n)
-	}
-
-	p.op(OEND)
-}
-
-func (p *exporter) node(n *Node) {
-	if opprec[n.Op] < 0 {
-		p.stmt(n)
-	} else {
-		p.expr(n)
-	}
-}
-
-func (p *exporter) exprList(list Nodes) {
-	if p.trace {
-		if list.Len() == 0 {
-			p.tracef("{}")
-		} else {
-			p.tracef("{>")
-			defer p.tracef("<\n}")
-		}
-	}
-
-	for _, n := range list.Slice() {
-		if p.trace {
-			p.tracef("\n")
-		}
-		p.expr(n)
-	}
-
-	p.op(OEND)
-}
-
-func (p *exporter) elemList(list Nodes) {
-	if p.trace {
-		p.tracef("[ ")
-	}
-	p.int(list.Len())
-	if p.trace {
-		if list.Len() == 0 {
-			p.tracef("] {}")
-		} else {
-			p.tracef("] {>")
-			defer p.tracef("<\n}")
-		}
-	}
-
-	for _, n := range list.Slice() {
-		if p.trace {
-			p.tracef("\n")
-		}
-		p.fieldSym(n.Sym, false)
-		p.expr(n.Left)
-	}
-}
-
-func (p *exporter) expr(n *Node) {
-	if p.trace {
-		p.tracef("( ")
-		defer p.tracef(") ")
-	}
-
-	// from nodefmt (fmt.go)
-	//
-	// nodefmt reverts nodes back to their original - we don't need to do
-	// it because we are not bound to produce valid Go syntax when exporting
-	//
-	// if (fmtmode != FExp || n.Op != OLITERAL) && n.Orig != nil {
-	// 	n = n.Orig
-	// }
-
-	// from exprfmt (fmt.go)
-	for n != nil && n.Implicit() && (n.Op == OIND || n.Op == OADDR) {
-		n = n.Left
-	}
-
-	switch op := n.Op; op {
-	// expressions
-	// (somewhat closely following the structure of exprfmt in fmt.go)
-	case OPAREN:
-		p.expr(n.Left) // unparen
-
-	// case ODDDARG:
-	//	unimplemented - handled by default case
-
-	case OLITERAL:
-		if n.Val().Ctype() == CTNIL && n.Orig != nil && n.Orig != n {
-			p.expr(n.Orig)
-			break
-		}
-		p.op(OLITERAL)
-		p.pos(n.Pos)
-		p.typ(unidealType(n.Type, n.Val()))
-		p.value(n.Val())
-
-	case ONAME:
-		// Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method,
-		// but for export, this should be rendered as (*pkg.T).meth.
-		// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
-		if n.isMethodExpression() {
-			p.op(OXDOT)
-			p.pos(n.Pos)
-			p.expr(n.Left) // n.Left.Op == OTYPE
-			p.fieldSym(n.Right.Sym, true)
-			break
-		}
-
-		p.op(ONAME)
-		p.pos(n.Pos)
-		p.sym(n)
-
-	// case OPACK, ONONAME:
-	// 	should have been resolved by typechecking - handled by default case
-
-	case OTYPE:
-		p.op(OTYPE)
-		p.pos(n.Pos)
-		p.typ(n.Type)
-
-	// case OTARRAY, OTMAP, OTCHAN, OTSTRUCT, OTINTER, OTFUNC:
-	// 	should have been resolved by typechecking - handled by default case
-
-	// case OCLOSURE:
-	//	unimplemented - handled by default case
-
-	// case OCOMPLIT:
-	// 	should have been resolved by typechecking - handled by default case
-
-	case OPTRLIT:
-		p.op(OPTRLIT)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.bool(n.Implicit())
-
-	case OSTRUCTLIT:
-		p.op(OSTRUCTLIT)
-		p.pos(n.Pos)
-		p.typ(n.Type)
-		p.elemList(n.List) // special handling of field names
-
-	case OARRAYLIT, OSLICELIT, OMAPLIT:
-		p.op(OCOMPLIT)
-		p.pos(n.Pos)
-		p.typ(n.Type)
-		p.exprList(n.List)
-
-	case OKEY:
-		p.op(OKEY)
-		p.pos(n.Pos)
-		p.exprsOrNil(n.Left, n.Right)
-
-	// case OSTRUCTKEY:
-	//	unreachable - handled in case OSTRUCTLIT by elemList
-
-	// case OCALLPART:
-	//	unimplemented - handled by default case
-
-	case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH:
-		p.op(OXDOT)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.fieldSym(n.Sym, true)
-
-	case ODOTTYPE, ODOTTYPE2:
-		p.op(ODOTTYPE)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.typ(n.Type)
-
-	case OINDEX, OINDEXMAP:
-		p.op(OINDEX)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.expr(n.Right)
-
-	case OSLICE, OSLICESTR, OSLICEARR:
-		p.op(OSLICE)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		low, high, _ := n.SliceBounds()
-		p.exprsOrNil(low, high)
-
-	case OSLICE3, OSLICE3ARR:
-		p.op(OSLICE3)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		low, high, max := n.SliceBounds()
-		p.exprsOrNil(low, high)
-		p.expr(max)
-
-	case OCOPY, OCOMPLEX:
-		// treated like other builtin calls (see e.g., OREAL)
-		p.op(op)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.expr(n.Right)
-		p.op(OEND)
-
-	case OCONV, OCONVIFACE, OCONVNOP, OARRAYBYTESTR, OARRAYRUNESTR, OSTRARRAYBYTE, OSTRARRAYRUNE, ORUNESTR:
-		p.op(OCONV)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.typ(n.Type)
-
-	case OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN:
-		p.op(op)
-		p.pos(n.Pos)
-		if n.Left != nil {
-			p.expr(n.Left)
-			p.op(OEND)
-		} else {
-			p.exprList(n.List) // emits terminating OEND
-		}
-		// only append() calls may contain '...' arguments
-		if op == OAPPEND {
-			p.bool(n.Isddd())
-		} else if n.Isddd() {
-			Fatalf("exporter: unexpected '...' with %v call", op)
-		}
-
-	case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OGETG:
-		p.op(OCALL)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.exprList(n.List)
-		p.bool(n.Isddd())
-
-	case OMAKEMAP, OMAKECHAN, OMAKESLICE:
-		p.op(op) // must keep separate from OMAKE for importer
-		p.pos(n.Pos)
-		p.typ(n.Type)
-		switch {
-		default:
-			// empty list
-			p.op(OEND)
-		case n.List.Len() != 0: // pre-typecheck
-			p.exprList(n.List) // emits terminating OEND
-		case n.Right != nil:
-			p.expr(n.Left)
-			p.expr(n.Right)
-			p.op(OEND)
-		case n.Left != nil && (n.Op == OMAKESLICE || !n.Left.Type.IsUntyped()):
-			p.expr(n.Left)
-			p.op(OEND)
-		}
-
-	// unary expressions
-	case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV:
-		p.op(op)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-
-	// binary expressions
-	case OADD, OAND, OANDAND, OANDNOT, ODIV, OEQ, OGE, OGT, OLE, OLT,
-		OLSH, OMOD, OMUL, ONE, OOR, OOROR, ORSH, OSEND, OSUB, OXOR:
-		p.op(op)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.expr(n.Right)
-
-	case OADDSTR:
-		p.op(OADDSTR)
-		p.pos(n.Pos)
-		p.exprList(n.List)
-
-	case OCMPSTR, OCMPIFACE:
-		p.op(n.SubOp())
-		p.pos(n.Pos)
-		p.expr(n.Left)
-		p.expr(n.Right)
-
-	case ODCLCONST:
-		// if exporting, DCLCONST should just be removed as its usage
-		// has already been replaced with literals
-		// TODO(gri) these should not be exported in the first place
-		// TODO(gri) why is this considered an expression in fmt.go?
-		p.op(ODCLCONST)
-		p.pos(n.Pos)
-
-	default:
-		Fatalf("cannot export %v (%d) node\n"+
-			"==> please file an issue and assign to gri@\n", n.Op, int(n.Op))
-	}
-}
-
-// Caution: stmt will emit more than one node for statement nodes n that have a non-empty
-// n.Ninit and where n cannot have a natural init section (such as in "if", "for", etc.).
-func (p *exporter) stmt(n *Node) {
-	if p.trace {
-		p.tracef("( ")
-		defer p.tracef(") ")
-	}
-
-	if n.Ninit.Len() > 0 && !stmtwithinit(n.Op) {
-		if p.trace {
-			p.tracef("( /* Ninits */ ")
-		}
-
-		// can't use stmtList here since we don't want the final OEND
-		for _, n := range n.Ninit.Slice() {
-			p.stmt(n)
-		}
-
-		if p.trace {
-			p.tracef(") ")
-		}
-	}
-
-	switch op := n.Op; op {
-	case ODCL:
-		p.op(ODCL)
-		p.pos(n.Left.Pos) // use declared variable's pos
-		p.sym(n.Left)
-		p.typ(n.Left.Type)
-
-	// case ODCLFIELD:
-	//	unimplemented - handled by default case
-
-	case OAS:
-		// Don't export "v = <N>" initializing statements, hope they're always
-		// preceded by the DCL which will be re-parsed and typecheck to reproduce
-		// the "v = <N>" again.
-		if n.Right != nil {
-			p.op(OAS)
-			p.pos(n.Pos)
-			p.expr(n.Left)
-			p.expr(n.Right)
-		}
-
-	case OASOP:
-		p.op(OASOP)
-		p.pos(n.Pos)
-		p.op(n.SubOp())
-		p.expr(n.Left)
-		if p.bool(!n.Implicit()) {
-			p.expr(n.Right)
-		}
-
-	case OAS2, OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
-		p.op(OAS2)
-		p.pos(n.Pos)
-		p.exprList(n.List)
-		p.exprList(n.Rlist)
-
-	case ORETURN:
-		p.op(ORETURN)
-		p.pos(n.Pos)
-		p.exprList(n.List)
-
-	// case ORETJMP:
-	// 	unreachable - generated by compiler for trampolin routines
-
-	case OPROC, ODEFER:
-		p.op(op)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-
-	case OIF:
-		p.op(OIF)
-		p.pos(n.Pos)
-		p.stmtList(n.Ninit)
-		p.expr(n.Left)
-		p.stmtList(n.Nbody)
-		p.stmtList(n.Rlist)
-
-	case OFOR:
-		p.op(OFOR)
-		p.pos(n.Pos)
-		p.stmtList(n.Ninit)
-		p.exprsOrNil(n.Left, n.Right)
-		p.stmtList(n.Nbody)
-
-	case ORANGE:
-		p.op(ORANGE)
-		p.pos(n.Pos)
-		p.stmtList(n.List)
-		p.expr(n.Right)
-		p.stmtList(n.Nbody)
-
-	case OSELECT, OSWITCH:
-		p.op(op)
-		p.pos(n.Pos)
-		p.stmtList(n.Ninit)
-		p.exprsOrNil(n.Left, nil)
-		p.stmtList(n.List)
-
-	case OCASE, OXCASE:
-		p.op(OXCASE)
-		p.pos(n.Pos)
-		p.stmtList(n.List)
-		p.stmtList(n.Nbody)
-
-	case OFALL:
-		p.op(OFALL)
-		p.pos(n.Pos)
-
-	case OBREAK, OCONTINUE:
-		p.op(op)
-		p.pos(n.Pos)
-		p.exprsOrNil(n.Left, nil)
-
-	case OEMPTY:
-		// nothing to emit
-
-	case OGOTO, OLABEL:
-		p.op(op)
-		p.pos(n.Pos)
-		p.expr(n.Left)
-
-	default:
-		Fatalf("exporter: CANNOT EXPORT: %v\nPlease notify gri@\n", n.Op)
-	}
-}
-
-func (p *exporter) exprsOrNil(a, b *Node) {
-	ab := 0
-	if a != nil {
-		ab |= 1
-	}
-	if b != nil {
-		ab |= 2
-	}
-	p.int(ab)
-	if ab&1 != 0 {
-		p.expr(a)
-	}
-	if ab&2 != 0 {
-		p.node(b)
-	}
-}
-
-func (p *exporter) fieldSym(s *types.Sym, short bool) {
-	name := s.Name
-
-	// remove leading "type." in method names ("(T).m" -> "m")
-	if short {
-		if i := strings.LastIndex(name, "."); i >= 0 {
-			name = name[i+1:]
-		}
-	}
-
-	// we should never see a _ (blank) here - these are accessible ("read") fields
-	// TODO(gri) can we assert this with an explicit check?
-	p.string(name)
-	if !types.IsExported(name) {
-		p.pkg(s.Pkg)
-	}
-}
-
-// sym must encode the _ (blank) identifier as a single string "_" since
-// encoding for some nodes is based on this assumption (e.g. ONAME nodes).
-func (p *exporter) sym(n *Node) {
-	s := n.Sym
-	if s.Pkg != nil {
-		if len(s.Name) > 0 && s.Name[0] == '.' {
-			Fatalf("exporter: exporting synthetic symbol %s", s.Name)
-		}
-	}
-
-	if p.trace {
-		p.tracef("{ SYM ")
-		defer p.tracef("} ")
-	}
-
-	name := s.Name
-
-	// remove leading "type." in method names ("(T).m" -> "m")
-	if i := strings.LastIndex(name, "."); i >= 0 {
-		name = name[i+1:]
-	}
-
-	if strings.Contains(name, "·") && n.Name.Vargen > 0 {
-		Fatalf("exporter: unexpected · in symbol name")
-	}
-
-	if i := n.Name.Vargen; i > 0 {
-		name = fmt.Sprintf("%s·%d", name, i)
-	}
-
-	p.string(name)
-	if name != "_" {
-		p.pkg(s.Pkg)
-	}
-	// Fixes issue #18167.
-	p.string(s.Linkname)
-}
-
-func (p *exporter) bool(b bool) bool {
-	if p.trace {
-		p.tracef("[")
-		defer p.tracef("= %v] ", b)
-	}
-
-	x := 0
-	if b {
-		x = 1
-	}
-	p.int(x)
-	return b
-}
-
-func (p *exporter) op(op Op) {
-	if p.trace {
-		p.tracef("[")
-		defer p.tracef("= %v] ", op)
-	}
-
-	p.int(int(op))
-}
-
-// ----------------------------------------------------------------------------
-// Low-level encoders
-
-func (p *exporter) index(marker byte, index int) {
-	if index < 0 {
-		Fatalf("exporter: invalid index < 0")
-	}
-	if debugFormat {
-		p.marker('t')
-	}
-	if p.trace {
-		p.tracef("%c%d ", marker, index)
-	}
-	p.rawInt64(int64(index))
-}
-
-func (p *exporter) tag(tag int) {
-	if tag >= 0 {
-		Fatalf("exporter: invalid tag >= 0")
-	}
-	if debugFormat {
-		p.marker('t')
-	}
-	if p.trace {
-		p.tracef("%s ", tagString[-tag])
-	}
-	p.rawInt64(int64(tag))
-}
-
-func (p *exporter) int(x int) {
-	p.int64(int64(x))
-}
-
-func (p *exporter) int64(x int64) {
-	if debugFormat {
-		p.marker('i')
-	}
-	if p.trace {
-		p.tracef("%d ", x)
-	}
-	p.rawInt64(x)
-}
-
-func (p *exporter) string(s string) {
-	if debugFormat {
-		p.marker('s')
-	}
-	if p.trace {
-		p.tracef("%q ", s)
-	}
-	// if we saw the string before, write its index (>= 0)
-	// (the empty string is mapped to 0)
-	if i, ok := p.strIndex[s]; ok {
-		p.rawInt64(int64(i))
-		return
-	}
-	// otherwise, remember string and write its negative length and bytes
-	p.strIndex[s] = len(p.strIndex)
-	p.rawInt64(-int64(len(s)))
-	for i := 0; i < len(s); i++ {
-		p.rawByte(s[i])
-	}
-}
-
-// marker emits a marker byte and position information which makes
-// it easy for a reader to detect if it is "out of sync". Used only
-// if debugFormat is set.
-func (p *exporter) marker(m byte) {
-	p.rawByte(m)
-	// Uncomment this for help tracking down the location
-	// of an incorrect marker when running in debugFormat.
-	// if p.trace {
-	// 	p.tracef("#%d ", p.written)
-	// }
-	p.rawInt64(int64(p.written))
-}
-
-// rawInt64 should only be used by low-level encoders.
-func (p *exporter) rawInt64(x int64) {
-	var tmp [binary.MaxVarintLen64]byte
-	n := binary.PutVarint(tmp[:], x)
-	for i := 0; i < n; i++ {
-		p.rawByte(tmp[i])
-	}
-}
-
-// rawStringln should only be used to emit the initial version string.
-func (p *exporter) rawStringln(s string) {
-	for i := 0; i < len(s); i++ {
-		p.rawByte(s[i])
-	}
-	p.rawByte('\n')
-}
-
-// rawByte is the bottleneck interface to write to p.out.
-// rawByte escapes b as follows (any encoding does that
-// hides '$'):
-//
-//	'$'  => '|' 'S'
-//	'|'  => '|' '|'
-//
-// Necessary so other tools can find the end of the
-// export data by searching for "$$".
-// rawByte should only be used by low-level encoders.
-func (p *exporter) rawByte(b byte) {
-	switch b {
-	case '$':
-		// write '$' as '|' 'S'
-		b = 'S'
-		fallthrough
-	case '|':
-		// write '|' as '|' '|'
-		p.out.WriteByte('|')
-		p.written++
-	}
-	p.out.WriteByte(b)
-	p.written++
-}
-
-// tracef is like fmt.Printf but it rewrites the format string
-// to take care of indentation.
-func (p *exporter) tracef(format string, args ...interface{}) {
-	if strings.ContainsAny(format, "<>\n") {
-		var buf bytes.Buffer
-		for i := 0; i < len(format); i++ {
-			// no need to deal with runes
-			ch := format[i]
-			switch ch {
-			case '>':
-				p.indent++
-				continue
-			case '<':
-				p.indent--
-				continue
-			}
-			buf.WriteByte(ch)
-			if ch == '\n' {
-				for j := p.indent; j > 0; j-- {
-					buf.WriteString(".  ")
-				}
-			}
-		}
-		format = buf.String()
-	}
-	fmt.Printf(format, args...)
-}
-
 // ----------------------------------------------------------------------------
 // Export format
 
@@ -1829,44 +123,6 @@
 	aliasTag
 )
 
-// Debugging support.
-// (tagString is only used when tracing is enabled)
-var tagString = [...]string{
-	// Objects
-	-packageTag: "package",
-	-constTag:   "const",
-	-typeTag:    "type",
-	-varTag:     "var",
-	-funcTag:    "func",
-	-endTag:     "end",
-
-	// Types
-	-namedTag:     "named type",
-	-arrayTag:     "array",
-	-sliceTag:     "slice",
-	-dddTag:       "ddd",
-	-structTag:    "struct",
-	-pointerTag:   "pointer",
-	-signatureTag: "signature",
-	-interfaceTag: "interface",
-	-mapTag:       "map",
-	-chanTag:      "chan",
-
-	// Values
-	-falseTag:    "false",
-	-trueTag:     "true",
-	-int64Tag:    "int64",
-	-floatTag:    "float",
-	-fractionTag: "fraction",
-	-complexTag:  "complex",
-	-stringTag:   "string",
-	-nilTag:      "nil",
-	-unknownTag:  "unknown",
-
-	// Type aliases
-	-aliasTag: "alias",
-}
-
 // untype returns the "pseudo" untyped type for a Ctype (import/export use only).
 // (we can't use an pre-initialized array because we must be sure all types are
 // set up)
diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go
index c19f548..7aabae7 100644
--- a/src/cmd/compile/internal/gc/bimport.go
+++ b/src/cmd/compile/internal/gc/bimport.go
@@ -2,340 +2,19 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Binary package import.
-// See bexport.go for the export data format and how
-// to make a format change.
-
 package gc
 
 import (
-	"bufio"
 	"cmd/compile/internal/types"
 	"cmd/internal/src"
-	"encoding/binary"
-	"fmt"
-	"math/big"
-	"strconv"
-	"strings"
 )
 
-// The overall structure of Import is symmetric to Export: For each
-// export method in bexport.go there is a matching and symmetric method
-// in bimport.go. Changing the export format requires making symmetric
-// changes to bimport.go and bexport.go.
-
-type importer struct {
-	in      *bufio.Reader
-	imp     *types.Pkg // imported package
-	buf     []byte     // reused for reading strings
-	version int        // export format version
-
-	// object lists, in order of deserialization
-	strList       []string
-	pathList      []string
-	pkgList       []*types.Pkg
-	typList       []*types.Type
-	funcList      []*Node // nil entry means already declared
-	trackAllTypes bool
-
-	// for delayed type verification
-	cmpList []struct{ pt, t *types.Type }
-
-	// position encoding
-	posInfoFormat bool
-	prevFile      string
-	prevLine      int
-	posBase       *src.PosBase
-
-	// debugging support
-	debugFormat bool
-	read        int // bytes read
-}
-
-// Import populates imp from the serialized package data read from in.
-func Import(imp *types.Pkg, in *bufio.Reader) {
-	inimport = true
-	defer func() { inimport = false }()
-
-	p := importer{
-		in:       in,
-		imp:      imp,
-		version:  -1,           // unknown version
-		strList:  []string{""}, // empty string is mapped to 0
-		pathList: []string{""}, // empty path is mapped to 0
-	}
-
-	// read version info
-	var versionstr string
-	if b := p.rawByte(); b == 'c' || b == 'd' {
-		// Go1.7 encoding; first byte encodes low-level
-		// encoding format (compact vs debug).
-		// For backward-compatibility only (avoid problems with
-		// old installed packages). Newly compiled packages use
-		// the extensible format string.
-		// TODO(gri) Remove this support eventually; after Go1.8.
-		if b == 'd' {
-			p.debugFormat = true
-		}
-		p.trackAllTypes = p.rawByte() == 'a'
-		p.posInfoFormat = p.bool()
-		versionstr = p.string()
-		if versionstr == "v1" {
-			p.version = 0
-		}
-	} else {
-		// Go1.8 extensible encoding
-		// read version string and extract version number (ignore anything after the version number)
-		versionstr = p.rawStringln(b)
-		if s := strings.SplitN(versionstr, " ", 3); len(s) >= 2 && s[0] == "version" {
-			if v, err := strconv.Atoi(s[1]); err == nil && v > 0 {
-				p.version = v
-			}
-		}
-	}
-
-	// read version specific flags - extend as necessary
-	switch p.version {
-	// case 7:
-	// 	...
-	//	fallthrough
-	case 6, 5, 4, 3, 2, 1:
-		p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
-		p.trackAllTypes = p.bool()
-		p.posInfoFormat = p.bool()
-	case 0:
-		// Go1.7 encoding format - nothing to do here
-	default:
-		p.formatErrorf("unknown export format version %d (%q)", p.version, versionstr)
-	}
-
-	// --- generic export data ---
-
-	// populate typList with predeclared "known" types
-	p.typList = append(p.typList, predeclared()...)
-
-	// read package data
-	p.pkg()
-
-	// defer some type-checking until all types are read in completely
-	tcok := typecheckok
-	typecheckok = true
-	defercheckwidth()
-
-	// read objects
-
-	// phase 1
-	objcount := 0
-	for {
-		tag := p.tagOrIndex()
-		if tag == endTag {
-			break
-		}
-		p.obj(tag)
-		objcount++
-	}
-
-	// self-verification
-	if count := p.int(); count != objcount {
-		p.formatErrorf("got %d objects; want %d", objcount, count)
-	}
-
-	// --- compiler-specific export data ---
-
-	// read compiler-specific flags
-
-	// phase 2
-	objcount = 0
-	for {
-		tag := p.tagOrIndex()
-		if tag == endTag {
-			break
-		}
-		p.obj(tag)
-		objcount++
-	}
-
-	// self-verification
-	if count := p.int(); count != objcount {
-		p.formatErrorf("got %d objects; want %d", objcount, count)
-	}
-
-	// read inlineable functions bodies
-	if dclcontext != PEXTERN {
-		p.formatErrorf("unexpected context %d", dclcontext)
-	}
-
-	objcount = 0
-	for i0 := -1; ; {
-		i := p.int() // index of function with inlineable body
-		if i < 0 {
-			break
-		}
-
-		// don't process the same function twice
-		if i <= i0 {
-			p.formatErrorf("index not increasing: %d <= %d", i, i0)
-		}
-		i0 = i
-
-		if Curfn != nil {
-			p.formatErrorf("unexpected Curfn %v", Curfn)
-		}
-
-		// Note: In the original code, funchdr and funcbody are called for
-		// all functions (that were not yet imported). Now, we are calling
-		// them only for functions with inlineable bodies. funchdr does
-		// parameter renaming which doesn't matter if we don't have a body.
-
-		inlCost := p.int()
-		if f := p.funcList[i]; f != nil && f.Func.Inl == nil {
-			// function not yet imported - read body and set it
-			funchdr(f)
-			body := p.stmtList()
-			funcbody()
-			f.Func.Inl = &Inline{
-				Cost: int32(inlCost),
-				Body: body,
-			}
-			importlist = append(importlist, f)
-			if Debug['E'] > 0 && Debug['m'] > 2 {
-				if Debug['m'] > 3 {
-					fmt.Printf("inl body for %v: %+v\n", f, asNodes(body))
-				} else {
-					fmt.Printf("inl body for %v: %v\n", f, asNodes(body))
-				}
-			}
-		} else {
-			// function already imported - read body but discard declarations
-			dclcontext = PDISCARD // throw away any declarations
-			p.stmtList()
-			dclcontext = PEXTERN
-		}
-
-		objcount++
-	}
-
-	// self-verification
-	if count := p.int(); count != objcount {
-		p.formatErrorf("got %d functions; want %d", objcount, count)
-	}
-
-	if dclcontext != PEXTERN {
-		p.formatErrorf("unexpected context %d", dclcontext)
-	}
-
-	p.verifyTypes()
-
-	// --- end of export data ---
-
-	typecheckok = tcok
-	resumecheckwidth()
-
-	if debug_dclstack != 0 {
-		testdclstack()
-	}
-}
-
-func (p *importer) formatErrorf(format string, args ...interface{}) {
-	if debugFormat {
-		Fatalf(format, args...)
-	}
-
-	yyerror("cannot import %q due to version skew - reinstall package (%s)",
-		p.imp.Path, fmt.Sprintf(format, args...))
-	errorexit()
-}
-
-func (p *importer) verifyTypes() {
-	for _, pair := range p.cmpList {
-		pt := pair.pt
-		t := pair.t
-		if !eqtype(pt.Orig, t) {
-			p.formatErrorf("inconsistent definition for type %v during import\n\t%L (in %q)\n\t%L (in %q)", pt.Sym, pt, pt.Sym.Importdef.Path, t, p.imp.Path)
-		}
-	}
-}
-
 // numImport tracks how often a package with a given name is imported.
 // It is used to provide a better error message (by using the package
 // path to disambiguate) if a package that appears multiple times with
 // the same name appears in an error message.
 var numImport = make(map[string]int)
 
-func (p *importer) pkg() *types.Pkg {
-	// if the package was seen before, i is its index (>= 0)
-	i := p.tagOrIndex()
-	if i >= 0 {
-		return p.pkgList[i]
-	}
-
-	// otherwise, i is the package tag (< 0)
-	if i != packageTag {
-		p.formatErrorf("expected package tag, found tag = %d", i)
-	}
-
-	// read package data
-	name := p.string()
-	var path string
-	if p.version >= 5 {
-		path = p.path()
-	} else {
-		path = p.string()
-	}
-	var height int
-	if p.version >= 6 {
-		height = p.int()
-	}
-
-	// we should never see an empty package name
-	if name == "" {
-		p.formatErrorf("empty package name for path %q", path)
-	}
-
-	// we should never see a bad import path
-	if isbadimport(path, true) {
-		p.formatErrorf("bad package path %q for package %s", path, name)
-	}
-
-	// an empty path denotes the package we are currently importing;
-	// it must be the first package we see
-	if (path == "") != (len(p.pkgList) == 0) {
-		p.formatErrorf("package path %q for pkg index %d", path, len(p.pkgList))
-	}
-
-	if p.version >= 6 {
-		if height < 0 || height >= types.MaxPkgHeight {
-			p.formatErrorf("bad package height %v for package %s", height, name)
-		}
-
-		// reexported packages should always have a lower height than
-		// the main package
-		if len(p.pkgList) != 0 && height >= p.imp.Height {
-			p.formatErrorf("package %q (height %d) reexports package %q (height %d)", p.imp.Path, p.imp.Height, path, height)
-		}
-	}
-
-	// add package to pkgList
-	pkg := p.imp
-	if path != "" {
-		pkg = types.NewPkg(path, "")
-	}
-	if pkg.Name == "" {
-		pkg.Name = name
-		numImport[name]++
-	} else if pkg.Name != name {
-		yyerror("conflicting package names %s and %s for path %q", pkg.Name, name, path)
-	}
-	if myimportpath != "" && path == myimportpath {
-		yyerror("import %q: package depends on %q (import cycle)", p.imp.Path, path)
-		errorexit()
-	}
-	pkg.Height = height
-	p.pkgList = append(p.pkgList, pkg)
-
-	return pkg
-}
-
 func idealType(typ *types.Type) *types.Type {
 	switch typ {
 	case types.Idealint, types.Idealrune, types.Idealfloat, types.Idealcomplex:
@@ -345,1013 +24,11 @@
 	return typ
 }
 
-func (p *importer) obj(tag int) {
-	switch tag {
-	case constTag:
-		pos := p.pos()
-		sym := p.qualifiedName()
-		typ := p.typ()
-		val := p.value(typ)
-		importconst(p.imp, pos, sym, idealType(typ), val)
-
-	case aliasTag:
-		pos := p.pos()
-		sym := p.qualifiedName()
-		typ := p.typ()
-		importalias(p.imp, pos, sym, typ)
-
-	case typeTag:
-		p.typ()
-
-	case varTag:
-		pos := p.pos()
-		sym := p.qualifiedName()
-		typ := p.typ()
-		importvar(p.imp, pos, sym, typ)
-
-	case funcTag:
-		pos := p.pos()
-		sym := p.qualifiedName()
-		params := p.paramList()
-		result := p.paramList()
-
-		sig := functypefield(nil, params, result)
-		importfunc(p.imp, pos, sym, sig)
-		p.funcList = append(p.funcList, asNode(sym.Def))
-
-	default:
-		p.formatErrorf("unexpected object (tag = %d)", tag)
-	}
-}
-
-func (p *importer) pos() src.XPos {
-	if !p.posInfoFormat {
-		return src.NoXPos
-	}
-
-	file := p.prevFile
-	line := p.prevLine
-	delta := p.int()
-	line += delta
-	if p.version >= 5 {
-		if delta == deltaNewFile {
-			if n := p.int(); n >= 0 {
-				// file changed
-				file = p.path()
-				line = n
-			}
-		}
-	} else {
-		if delta == 0 {
-			if n := p.int(); n >= 0 {
-				// file changed
-				file = p.prevFile[:n] + p.string()
-				line = p.int()
-			}
-		}
-	}
-	if file != p.prevFile {
-		p.prevFile = file
-		p.posBase = src.NewFileBase(file, file)
-	}
-	p.prevLine = line
-
-	pos := src.MakePos(p.posBase, uint(line), 0)
-	xpos := Ctxt.PosTable.XPos(pos)
-	return xpos
-}
-
-func (p *importer) path() string {
-	// if the path was seen before, i is its index (>= 0)
-	// (the empty string is at index 0)
-	i := p.int()
-	if i >= 0 {
-		return p.pathList[i]
-	}
-	// otherwise, i is the negative path length (< 0)
-	a := make([]string, -i)
-	for n := range a {
-		a[n] = p.string()
-	}
-	s := strings.Join(a, "/")
-	p.pathList = append(p.pathList, s)
-	return s
-}
-
-func (p *importer) newtyp(etype types.EType) *types.Type {
-	t := types.New(etype)
-	if p.trackAllTypes {
-		p.typList = append(p.typList, t)
-	}
-	return t
-}
-
-// importtype declares that pt, an imported named type, has underlying type t.
-func (p *importer) importtype(pt, t *types.Type) {
-	if pt.Etype == TFORW {
-		copytype(typenod(pt), t)
-		checkwidth(pt)
-	} else {
-		// pt.Orig and t must be identical.
-		if p.trackAllTypes {
-			// If we track all types, t may not be fully set up yet.
-			// Collect the types and verify identity later.
-			p.cmpList = append(p.cmpList, struct{ pt, t *types.Type }{pt, t})
-		} else if !eqtype(pt.Orig, t) {
-			yyerror("inconsistent definition for type %v during import\n\t%L (in %q)\n\t%L (in %q)", pt.Sym, pt, pt.Sym.Importdef.Path, t, p.imp.Path)
-		}
-	}
-
-	if Debug['E'] != 0 {
-		fmt.Printf("import type %v %L\n", pt, t)
-	}
-}
-
-func (p *importer) typ() *types.Type {
-	// if the type was seen before, i is its index (>= 0)
-	i := p.tagOrIndex()
-	if i >= 0 {
-		return p.typList[i]
-	}
-
-	// otherwise, i is the type tag (< 0)
-	var t *types.Type
-	switch i {
-	case namedTag:
-		pos := p.pos()
-		tsym := p.qualifiedName()
-
-		t = importtype(p.imp, pos, tsym)
-		p.typList = append(p.typList, t)
-		dup := !t.IsKind(types.TFORW) // type already imported
-
-		// read underlying type
-		t0 := p.typ()
-		p.importtype(t, t0)
-
-		// interfaces don't have associated methods
-		if t0.IsInterface() {
-			break
-		}
-
-		// set correct import context (since p.typ() may be called
-		// while importing the body of an inlined function)
-		savedContext := dclcontext
-		dclcontext = PEXTERN
-
-		// read associated methods
-		for i := p.int(); i > 0; i-- {
-			mpos := p.pos()
-			sym := p.fieldSym()
-
-			// during import unexported method names should be in the type's package
-			if !types.IsExported(sym.Name) && sym.Pkg != tsym.Pkg {
-				Fatalf("imported method name %+v in wrong package %s\n", sym, tsym.Pkg.Name)
-			}
-
-			recv := p.paramList() // TODO(gri) do we need a full param list for the receiver?
-			params := p.paramList()
-			result := p.paramList()
-			nointerface := p.bool()
-
-			mt := functypefield(recv[0], params, result)
-			oldm := addmethod(sym, mt, false, nointerface)
-
-			if dup {
-				// An earlier import already declared this type and its methods.
-				// Discard the duplicate method declaration.
-				n := asNode(oldm.Type.Nname())
-				p.funcList = append(p.funcList, n)
-				continue
-			}
-
-			n := newfuncnamel(mpos, methodSym(recv[0].Type, sym))
-			n.Type = mt
-			n.SetClass(PFUNC)
-			checkwidth(n.Type)
-			p.funcList = append(p.funcList, n)
-
-			// (comment from parser.go)
-			// inl.C's inlnode in on a dotmeth node expects to find the inlineable body as
-			// (dotmeth's type).Nname.Inl, and dotmeth's type has been pulled
-			// out by typecheck's lookdot as this $$.ttype. So by providing
-			// this back link here we avoid special casing there.
-			mt.SetNname(asTypesNode(n))
-
-			if Debug['E'] > 0 {
-				fmt.Printf("import [%q] meth %v \n", p.imp.Path, n)
-			}
-		}
-
-		dclcontext = savedContext
-
-	case arrayTag:
-		t = p.newtyp(TARRAY)
-		bound := p.int64()
-		elem := p.typ()
-		t.Extra = &types.Array{Elem: elem, Bound: bound}
-
-	case sliceTag:
-		t = p.newtyp(TSLICE)
-		elem := p.typ()
-		t.Extra = types.Slice{Elem: elem}
-
-	case dddTag:
-		t = p.newtyp(TDDDFIELD)
-		t.Extra = types.DDDField{T: p.typ()}
-
-	case structTag:
-		t = p.newtyp(TSTRUCT)
-		t.SetFields(p.fieldList())
-		checkwidth(t)
-
-	case pointerTag:
-		t = p.newtyp(types.Tptr)
-		t.Extra = types.Ptr{Elem: p.typ()}
-
-	case signatureTag:
-		t = p.newtyp(TFUNC)
-		params := p.paramList()
-		result := p.paramList()
-		functypefield0(t, nil, params, result)
-
-	case interfaceTag:
-		if ml := p.methodList(); len(ml) == 0 {
-			t = types.Types[TINTER]
-		} else {
-			t = p.newtyp(TINTER)
-			t.SetInterface(ml)
-		}
-
-	case mapTag:
-		t = p.newtyp(TMAP)
-		mt := t.MapType()
-		mt.Key = p.typ()
-		mt.Elem = p.typ()
-
-	case chanTag:
-		t = p.newtyp(TCHAN)
-		ct := t.ChanType()
-		ct.Dir = types.ChanDir(p.int())
-		ct.Elem = p.typ()
-
-	default:
-		p.formatErrorf("unexpected type (tag = %d)", i)
-	}
-
-	if t == nil {
-		p.formatErrorf("nil type (type tag = %d)", i)
-	}
-
-	return t
-}
-
-func (p *importer) qualifiedName() *types.Sym {
-	name := p.string()
-	pkg := p.pkg()
-	return pkg.Lookup(name)
-}
-
-func (p *importer) fieldList() (fields []*types.Field) {
-	if n := p.int(); n > 0 {
-		fields = make([]*types.Field, n)
-		for i := range fields {
-			fields[i] = p.field()
-		}
-	}
-	return
-}
-
-func (p *importer) field() *types.Field {
-	pos := p.pos()
-	sym, alias := p.fieldName()
-	typ := p.typ()
-	note := p.string()
-
-	f := types.NewField()
-	if sym.Name == "" {
-		// anonymous field: typ must be T or *T and T must be a type name
-		s := typ.Sym
-		if s == nil && typ.IsPtr() {
-			s = typ.Elem().Sym // deref
-		}
-		sym = sym.Pkg.Lookup(s.Name)
-		f.Embedded = 1
-	} else if alias {
-		// anonymous field: we have an explicit name because it's a type alias
-		f.Embedded = 1
-	}
-
-	f.Pos = pos
-	f.Sym = sym
-	f.Type = typ
-	f.Note = note
-
-	return f
-}
-
-func (p *importer) methodList() (methods []*types.Field) {
-	for n := p.int(); n > 0; n-- {
-		f := types.NewField()
-		f.Pos = p.pos()
-		f.Type = p.typ()
-		methods = append(methods, f)
-	}
-
-	for n := p.int(); n > 0; n-- {
-		methods = append(methods, p.method())
-	}
-
-	return
-}
-
-func (p *importer) method() *types.Field {
-	pos := p.pos()
-	sym := p.methodName()
-	params := p.paramList()
-	result := p.paramList()
-
-	f := types.NewField()
-	f.Pos = pos
-	f.Sym = sym
-	f.Type = functypefield(fakeRecvField(), params, result)
-	return f
-}
-
-func (p *importer) fieldName() (*types.Sym, bool) {
-	name := p.string()
-	if p.version == 0 && name == "_" {
-		// version 0 didn't export a package for _ field names
-		// but used the builtin package instead
-		return builtinpkg.Lookup(name), false
-	}
-	pkg := localpkg
-	alias := false
-	switch name {
-	case "":
-		// 1) field name matches base type name and is exported: nothing to do
-	case "?":
-		// 2) field name matches base type name and is not exported: need package
-		name = ""
-		pkg = p.pkg()
-	case "@":
-		// 3) field name doesn't match base type name (alias name): need name and possibly package
-		name = p.string()
-		alias = true
-		fallthrough
-	default:
-		if !types.IsExported(name) {
-			pkg = p.pkg()
-		}
-	}
-	return pkg.Lookup(name), alias
-}
-
-func (p *importer) methodName() *types.Sym {
-	name := p.string()
-	if p.version == 0 && name == "_" {
-		// version 0 didn't export a package for _ method names
-		// but used the builtin package instead
-		return builtinpkg.Lookup(name)
-	}
-	pkg := localpkg
-	if !types.IsExported(name) {
-		pkg = p.pkg()
-	}
-	return pkg.Lookup(name)
-}
-
-func (p *importer) paramList() []*types.Field {
-	i := p.int()
-	if i == 0 {
-		return nil
-	}
-	// negative length indicates unnamed parameters
-	named := true
-	if i < 0 {
-		i = -i
-		named = false
-	}
-	// i > 0
-	fs := make([]*types.Field, i)
-	for i := range fs {
-		fs[i] = p.param(named)
-	}
-	return fs
-}
-
-func (p *importer) param(named bool) *types.Field {
-	f := types.NewField()
-	// TODO(mdempsky): Need param position.
-	f.Pos = lineno
-	f.Type = p.typ()
-	if f.Type.Etype == TDDDFIELD {
-		// TDDDFIELD indicates wrapped ... slice type
-		f.Type = types.NewSlice(f.Type.DDDField())
-		f.SetIsddd(true)
-	}
-
-	if named {
-		name := p.string()
-		if name == "" {
-			p.formatErrorf("expected named parameter")
-		}
-		// TODO(gri) Supply function/method package rather than
-		// encoding the package for each parameter repeatedly.
-		pkg := localpkg
-		if name != "_" {
-			pkg = p.pkg()
-		}
-		f.Sym = pkg.Lookup(name)
-	}
-
-	// TODO(gri) This is compiler-specific (escape info).
-	// Move into compiler-specific section eventually?
-	f.Note = p.string()
-
-	return f
-}
-
-func (p *importer) value(typ *types.Type) (x Val) {
-	switch tag := p.tagOrIndex(); tag {
-	case falseTag:
-		x.U = false
-
-	case trueTag:
-		x.U = true
-
-	case int64Tag:
-		u := new(Mpint)
-		u.SetInt64(p.int64())
-		u.Rune = typ == types.Idealrune
-		x.U = u
-
-	case floatTag:
-		f := newMpflt()
-		p.float(f)
-		if typ == types.Idealint || typ.IsInteger() || typ.IsPtr() || typ.IsUnsafePtr() {
-			// uncommon case: large int encoded as float
-			//
-			// This happens for unsigned typed integers
-			// and (on 64-bit platforms) pointers because
-			// of values in the range [2^63, 2^64).
-			u := new(Mpint)
-			u.SetFloat(f)
-			x.U = u
-			break
-		}
-		x.U = f
-
-	case complexTag:
-		u := new(Mpcplx)
-		p.float(&u.Real)
-		p.float(&u.Imag)
-		x.U = u
-
-	case stringTag:
-		x.U = p.string()
-
-	case unknownTag:
-		p.formatErrorf("unknown constant (importing package with errors)")
-
-	case nilTag:
-		x.U = new(NilVal)
-
-	default:
-		p.formatErrorf("unexpected value tag %d", tag)
-	}
-
-	// verify ideal type
-	if typ.IsUntyped() && untype(x.Ctype()) != typ {
-		p.formatErrorf("value %v and type %v don't match", x, typ)
-	}
-
-	return
-}
-
-func (p *importer) float(x *Mpflt) {
-	sign := p.int()
-	if sign == 0 {
-		x.SetFloat64(0)
-		return
-	}
-
-	exp := p.int()
-	mant := new(big.Int).SetBytes([]byte(p.string()))
-
-	m := x.Val.SetInt(mant)
-	m.SetMantExp(m, exp-mant.BitLen())
-	if sign < 0 {
-		m.Neg(m)
-	}
-}
-
-// ----------------------------------------------------------------------------
-// Inlined function bodies
-
-// Approach: Read nodes and use them to create/declare the same data structures
-// as done originally by the (hidden) parser by closely following the parser's
-// original code. In other words, "parsing" the import data (which happens to
-// be encoded in binary rather textual form) is the best way at the moment to
-// re-establish the syntax tree's invariants. At some future point we might be
-// able to avoid this round-about way and create the rewritten nodes directly,
-// possibly avoiding a lot of duplicate work (name resolution, type checking).
-//
-// Refined nodes (e.g., ODOTPTR as a refinement of OXDOT) are exported as their
-// unrefined nodes (since this is what the importer uses). The respective case
-// entries are unreachable in the importer.
-
-func (p *importer) stmtList() []*Node {
-	var list []*Node
-	for {
-		n := p.node()
-		if n == nil {
-			break
-		}
-		// OBLOCK nodes may be created when importing ODCL nodes - unpack them
-		if n.Op == OBLOCK {
-			list = append(list, n.List.Slice()...)
-		} else {
-			list = append(list, n)
-		}
-	}
-	return list
-}
-
-func (p *importer) exprList() []*Node {
-	var list []*Node
-	for {
-		n := p.expr()
-		if n == nil {
-			break
-		}
-		list = append(list, n)
-	}
-	return list
-}
-
-func (p *importer) elemList() []*Node {
-	c := p.int()
-	list := make([]*Node, c)
-	for i := range list {
-		s := p.fieldSym()
-		list[i] = nodSym(OSTRUCTKEY, p.expr(), s)
-	}
-	return list
-}
-
-func (p *importer) expr() *Node {
-	n := p.node()
-	if n != nil && n.Op == OBLOCK {
-		Fatalf("unexpected block node: %v", n)
-	}
-	return n
-}
-
 func npos(pos src.XPos, n *Node) *Node {
 	n.Pos = pos
 	return n
 }
 
-// TODO(gri) split into expr and stmt
-func (p *importer) node() *Node {
-	switch op := p.op(); op {
-	// expressions
-	// case OPAREN:
-	// 	unreachable - unpacked by exporter
-
-	// case ODDDARG:
-	//	unimplemented
-
-	case OLITERAL:
-		pos := p.pos()
-		typ := p.typ()
-		n := npos(pos, nodlit(p.value(typ)))
-		n.Type = idealType(typ)
-		return n
-
-	case ONAME:
-		return npos(p.pos(), mkname(p.sym()))
-
-	// case OPACK, ONONAME:
-	// 	unreachable - should have been resolved by typechecking
-
-	case OTYPE:
-		return npos(p.pos(), typenod(p.typ()))
-
-	// case OTARRAY, OTMAP, OTCHAN, OTSTRUCT, OTINTER, OTFUNC:
-	//      unreachable - should have been resolved by typechecking
-
-	// case OCLOSURE:
-	//	unimplemented
-
-	case OPTRLIT:
-		pos := p.pos()
-		n := npos(pos, p.expr())
-		if !p.bool() /* !implicit, i.e. '&' operator */ {
-			if n.Op == OCOMPLIT {
-				// Special case for &T{...}: turn into (*T){...}.
-				n.Right = nodl(pos, OIND, n.Right, nil)
-				n.Right.SetImplicit(true)
-			} else {
-				n = nodl(pos, OADDR, n, nil)
-			}
-		}
-		return n
-
-	case OSTRUCTLIT:
-		// TODO(mdempsky): Export position information for OSTRUCTKEY nodes.
-		savedlineno := lineno
-		lineno = p.pos()
-		n := nodl(lineno, OCOMPLIT, nil, typenod(p.typ()))
-		n.List.Set(p.elemList()) // special handling of field names
-		lineno = savedlineno
-		return n
-
-	// case OARRAYLIT, OSLICELIT, OMAPLIT:
-	// 	unreachable - mapped to case OCOMPLIT below by exporter
-
-	case OCOMPLIT:
-		n := nodl(p.pos(), OCOMPLIT, nil, typenod(p.typ()))
-		n.List.Set(p.exprList())
-		return n
-
-	case OKEY:
-		pos := p.pos()
-		left, right := p.exprsOrNil()
-		return nodl(pos, OKEY, left, right)
-
-	// case OSTRUCTKEY:
-	//	unreachable - handled in case OSTRUCTLIT by elemList
-
-	// case OCALLPART:
-	//	unimplemented
-
-	// case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH:
-	// 	unreachable - mapped to case OXDOT below by exporter
-
-	case OXDOT:
-		// see parser.new_dotname
-		return npos(p.pos(), nodSym(OXDOT, p.expr(), p.fieldSym()))
-
-	// case ODOTTYPE, ODOTTYPE2:
-	// 	unreachable - mapped to case ODOTTYPE below by exporter
-
-	case ODOTTYPE:
-		n := nodl(p.pos(), ODOTTYPE, p.expr(), nil)
-		n.Type = p.typ()
-		return n
-
-	// case OINDEX, OINDEXMAP, OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR:
-	// 	unreachable - mapped to cases below by exporter
-
-	case OINDEX:
-		return nodl(p.pos(), op, p.expr(), p.expr())
-
-	case OSLICE, OSLICE3:
-		n := nodl(p.pos(), op, p.expr(), nil)
-		low, high := p.exprsOrNil()
-		var max *Node
-		if n.Op.IsSlice3() {
-			max = p.expr()
-		}
-		n.SetSliceBounds(low, high, max)
-		return n
-
-	// case OCONV, OCONVIFACE, OCONVNOP, OARRAYBYTESTR, OARRAYRUNESTR, OSTRARRAYBYTE, OSTRARRAYRUNE, ORUNESTR:
-	// 	unreachable - mapped to OCONV case below by exporter
-
-	case OCONV:
-		n := nodl(p.pos(), OCONV, p.expr(), nil)
-		n.Type = p.typ()
-		return n
-
-	case OCOPY, OCOMPLEX, OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN:
-		n := npos(p.pos(), builtinCall(op))
-		n.List.Set(p.exprList())
-		if op == OAPPEND {
-			n.SetIsddd(p.bool())
-		}
-		return n
-
-	// case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OGETG:
-	// 	unreachable - mapped to OCALL case below by exporter
-
-	case OCALL:
-		n := nodl(p.pos(), OCALL, p.expr(), nil)
-		n.List.Set(p.exprList())
-		n.SetIsddd(p.bool())
-		return n
-
-	case OMAKEMAP, OMAKECHAN, OMAKESLICE:
-		n := npos(p.pos(), builtinCall(OMAKE))
-		n.List.Append(typenod(p.typ()))
-		n.List.Append(p.exprList()...)
-		return n
-
-	// unary expressions
-	case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV:
-		return nodl(p.pos(), op, p.expr(), nil)
-
-	// binary expressions
-	case OADD, OAND, OANDAND, OANDNOT, ODIV, OEQ, OGE, OGT, OLE, OLT,
-		OLSH, OMOD, OMUL, ONE, OOR, OOROR, ORSH, OSEND, OSUB, OXOR:
-		return nodl(p.pos(), op, p.expr(), p.expr())
-
-	case OADDSTR:
-		pos := p.pos()
-		list := p.exprList()
-		x := npos(pos, list[0])
-		for _, y := range list[1:] {
-			x = nodl(pos, OADD, x, y)
-		}
-		return x
-
-	// case OCMPSTR, OCMPIFACE:
-	// 	unreachable - mapped to std comparison operators by exporter
-
-	case ODCLCONST:
-		// TODO(gri) these should not be exported in the first place
-		return nodl(p.pos(), OEMPTY, nil, nil)
-
-	// --------------------------------------------------------------------
-	// statements
-	case ODCL:
-		if p.version < 2 {
-			// versions 0 and 1 exported a bool here but it
-			// was always false - simply ignore in this case
-			p.bool()
-		}
-		pos := p.pos()
-		lhs := npos(pos, dclname(p.sym()))
-		typ := typenod(p.typ())
-		return npos(pos, liststmt(variter([]*Node{lhs}, typ, nil))) // TODO(gri) avoid list creation
-
-	// case ODCLFIELD:
-	//	unimplemented
-
-	// case OAS, OASWB:
-	// 	unreachable - mapped to OAS case below by exporter
-
-	case OAS:
-		return nodl(p.pos(), OAS, p.expr(), p.expr())
-
-	case OASOP:
-		n := nodl(p.pos(), OASOP, nil, nil)
-		n.SetSubOp(p.op())
-		n.Left = p.expr()
-		if !p.bool() {
-			n.Right = nodintconst(1)
-			n.SetImplicit(true)
-		} else {
-			n.Right = p.expr()
-		}
-		return n
-
-	// case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
-	// 	unreachable - mapped to OAS2 case below by exporter
-
-	case OAS2:
-		n := nodl(p.pos(), OAS2, nil, nil)
-		n.List.Set(p.exprList())
-		n.Rlist.Set(p.exprList())
-		return n
-
-	case ORETURN:
-		n := nodl(p.pos(), ORETURN, nil, nil)
-		n.List.Set(p.exprList())
-		return n
-
-	// case ORETJMP:
-	// 	unreachable - generated by compiler for trampolin routines (not exported)
-
-	case OPROC, ODEFER:
-		return nodl(p.pos(), op, p.expr(), nil)
-
-	case OIF:
-		n := nodl(p.pos(), OIF, nil, nil)
-		n.Ninit.Set(p.stmtList())
-		n.Left = p.expr()
-		n.Nbody.Set(p.stmtList())
-		n.Rlist.Set(p.stmtList())
-		return n
-
-	case OFOR:
-		n := nodl(p.pos(), OFOR, nil, nil)
-		n.Ninit.Set(p.stmtList())
-		n.Left, n.Right = p.exprsOrNil()
-		n.Nbody.Set(p.stmtList())
-		return n
-
-	case ORANGE:
-		n := nodl(p.pos(), ORANGE, nil, nil)
-		n.List.Set(p.stmtList())
-		n.Right = p.expr()
-		n.Nbody.Set(p.stmtList())
-		return n
-
-	case OSELECT, OSWITCH:
-		n := nodl(p.pos(), op, nil, nil)
-		n.Ninit.Set(p.stmtList())
-		n.Left, _ = p.exprsOrNil()
-		n.List.Set(p.stmtList())
-		return n
-
-	// case OCASE, OXCASE:
-	// 	unreachable - mapped to OXCASE case below by exporter
-
-	case OXCASE:
-		n := nodl(p.pos(), OXCASE, nil, nil)
-		n.List.Set(p.exprList())
-		// TODO(gri) eventually we must declare variables for type switch
-		// statements (type switch statements are not yet exported)
-		n.Nbody.Set(p.stmtList())
-		return n
-
-	// case OFALL:
-	// 	unreachable - mapped to OXFALL case below by exporter
-
-	case OFALL:
-		n := nodl(p.pos(), OFALL, nil, nil)
-		return n
-
-	case OBREAK, OCONTINUE:
-		pos := p.pos()
-		left, _ := p.exprsOrNil()
-		if left != nil {
-			left = newname(left.Sym)
-		}
-		return nodl(pos, op, left, nil)
-
-	// case OEMPTY:
-	// 	unreachable - not emitted by exporter
-
-	case OGOTO, OLABEL:
-		return nodl(p.pos(), op, newname(p.expr().Sym), nil)
-
-	case OEND:
-		return nil
-
-	default:
-		Fatalf("cannot import %v (%d) node\n"+
-			"==> please file an issue and assign to gri@\n", op, int(op))
-		panic("unreachable") // satisfy compiler
-	}
-}
-
 func builtinCall(op Op) *Node {
 	return nod(OCALL, mkname(builtinpkg.Lookup(goopnames[op])), nil)
 }
-
-func (p *importer) exprsOrNil() (a, b *Node) {
-	ab := p.int()
-	if ab&1 != 0 {
-		a = p.expr()
-	}
-	if ab&2 != 0 {
-		b = p.node()
-	}
-	return
-}
-
-func (p *importer) fieldSym() *types.Sym {
-	name := p.string()
-	pkg := localpkg
-	if !types.IsExported(name) {
-		pkg = p.pkg()
-	}
-	return pkg.Lookup(name)
-}
-
-func (p *importer) sym() *types.Sym {
-	name := p.string()
-	pkg := localpkg
-	if name != "_" {
-		pkg = p.pkg()
-	}
-	linkname := p.string()
-	sym := pkg.Lookup(name)
-	sym.Linkname = linkname
-	return sym
-}
-
-func (p *importer) bool() bool {
-	return p.int() != 0
-}
-
-func (p *importer) op() Op {
-	return Op(p.int())
-}
-
-// ----------------------------------------------------------------------------
-// Low-level decoders
-
-func (p *importer) tagOrIndex() int {
-	if p.debugFormat {
-		p.marker('t')
-	}
-
-	return int(p.rawInt64())
-}
-
-func (p *importer) int() int {
-	x := p.int64()
-	if int64(int(x)) != x {
-		p.formatErrorf("exported integer too large")
-	}
-	return int(x)
-}
-
-func (p *importer) int64() int64 {
-	if p.debugFormat {
-		p.marker('i')
-	}
-
-	return p.rawInt64()
-}
-
-func (p *importer) string() string {
-	if p.debugFormat {
-		p.marker('s')
-	}
-	// if the string was seen before, i is its index (>= 0)
-	// (the empty string is at index 0)
-	i := p.rawInt64()
-	if i >= 0 {
-		return p.strList[i]
-	}
-	// otherwise, i is the negative string length (< 0)
-	if n := int(-i); n <= cap(p.buf) {
-		p.buf = p.buf[:n]
-	} else {
-		p.buf = make([]byte, n)
-	}
-	for i := range p.buf {
-		p.buf[i] = p.rawByte()
-	}
-	s := string(p.buf)
-	p.strList = append(p.strList, s)
-	return s
-}
-
-func (p *importer) marker(want byte) {
-	if got := p.rawByte(); got != want {
-		p.formatErrorf("incorrect marker: got %c; want %c (pos = %d)", got, want, p.read)
-	}
-
-	pos := p.read
-	if n := int(p.rawInt64()); n != pos {
-		p.formatErrorf("incorrect position: got %d; want %d", n, pos)
-	}
-}
-
-// rawInt64 should only be used by low-level decoders.
-func (p *importer) rawInt64() int64 {
-	i, err := binary.ReadVarint(p)
-	if err != nil {
-		p.formatErrorf("read error: %v", err)
-	}
-	return i
-}
-
-// rawStringln should only be used to read the initial version string.
-func (p *importer) rawStringln(b byte) string {
-	p.buf = p.buf[:0]
-	for b != '\n' {
-		p.buf = append(p.buf, b)
-		b = p.rawByte()
-	}
-	return string(p.buf)
-}
-
-// needed for binary.ReadVarint in rawInt64
-func (p *importer) ReadByte() (byte, error) {
-	return p.rawByte(), nil
-}
-
-// rawByte is the bottleneck interface for reading from p.in.
-// It unescapes '|' 'S' to '$' and '|' '|' to '|'.
-// rawByte should only be used by low-level decoders.
-func (p *importer) rawByte() byte {
-	c, err := p.in.ReadByte()
-	p.read++
-	if err != nil {
-		p.formatErrorf("read error: %v", err)
-	}
-	if c == '|' {
-		c, err = p.in.ReadByte()
-		p.read++
-		if err != nil {
-			p.formatErrorf("read error: %v", err)
-		}
-		switch c {
-		case 'S':
-			c = '$'
-		case '|':
-			// nothing to do
-		default:
-			p.formatErrorf("unexpected escape sequence in export data")
-		}
-	}
-	return c
-}
diff --git a/src/cmd/compile/internal/gc/builtin.go b/src/cmd/compile/internal/gc/builtin.go
index ec8f109..04f4cbf 100644
--- a/src/cmd/compile/internal/gc/builtin.go
+++ b/src/cmd/compile/internal/gc/builtin.go
@@ -51,110 +51,106 @@
 	{"decoderune", funcTag, 50},
 	{"countrunes", funcTag, 51},
 	{"convI2I", funcTag, 52},
-	{"convT2E", funcTag, 53},
-	{"convT2E16", funcTag, 52},
-	{"convT2E32", funcTag, 52},
-	{"convT2E64", funcTag, 52},
-	{"convT2Estring", funcTag, 53},
-	{"convT2Eslice", funcTag, 53},
-	{"convT2Enoptr", funcTag, 53},
-	{"convT2I", funcTag, 53},
-	{"convT2I16", funcTag, 52},
-	{"convT2I32", funcTag, 52},
-	{"convT2I64", funcTag, 52},
-	{"convT2Istring", funcTag, 53},
-	{"convT2Islice", funcTag, 53},
-	{"convT2Inoptr", funcTag, 53},
+	{"convT16", funcTag, 54},
+	{"convT32", funcTag, 54},
+	{"convT64", funcTag, 54},
+	{"convTstring", funcTag, 54},
+	{"convTslice", funcTag, 54},
+	{"convT2E", funcTag, 55},
+	{"convT2Enoptr", funcTag, 55},
+	{"convT2I", funcTag, 55},
+	{"convT2Inoptr", funcTag, 55},
 	{"assertE2I", funcTag, 52},
-	{"assertE2I2", funcTag, 54},
+	{"assertE2I2", funcTag, 56},
 	{"assertI2I", funcTag, 52},
-	{"assertI2I2", funcTag, 54},
-	{"panicdottypeE", funcTag, 55},
-	{"panicdottypeI", funcTag, 55},
-	{"panicnildottype", funcTag, 56},
-	{"ifaceeq", funcTag, 59},
-	{"efaceeq", funcTag, 59},
-	{"fastrand", funcTag, 61},
-	{"makemap64", funcTag, 63},
-	{"makemap", funcTag, 64},
-	{"makemap_small", funcTag, 65},
-	{"mapaccess1", funcTag, 66},
-	{"mapaccess1_fast32", funcTag, 67},
-	{"mapaccess1_fast64", funcTag, 67},
-	{"mapaccess1_faststr", funcTag, 67},
-	{"mapaccess1_fat", funcTag, 68},
-	{"mapaccess2", funcTag, 69},
-	{"mapaccess2_fast32", funcTag, 70},
-	{"mapaccess2_fast64", funcTag, 70},
-	{"mapaccess2_faststr", funcTag, 70},
-	{"mapaccess2_fat", funcTag, 71},
-	{"mapassign", funcTag, 66},
-	{"mapassign_fast32", funcTag, 67},
-	{"mapassign_fast32ptr", funcTag, 67},
-	{"mapassign_fast64", funcTag, 67},
-	{"mapassign_fast64ptr", funcTag, 67},
-	{"mapassign_faststr", funcTag, 67},
-	{"mapiterinit", funcTag, 72},
-	{"mapdelete", funcTag, 72},
-	{"mapdelete_fast32", funcTag, 73},
-	{"mapdelete_fast64", funcTag, 73},
-	{"mapdelete_faststr", funcTag, 73},
-	{"mapiternext", funcTag, 74},
-	{"mapclear", funcTag, 75},
-	{"makechan64", funcTag, 77},
-	{"makechan", funcTag, 78},
-	{"chanrecv1", funcTag, 80},
-	{"chanrecv2", funcTag, 81},
-	{"chansend1", funcTag, 83},
+	{"assertI2I2", funcTag, 56},
+	{"panicdottypeE", funcTag, 57},
+	{"panicdottypeI", funcTag, 57},
+	{"panicnildottype", funcTag, 58},
+	{"ifaceeq", funcTag, 60},
+	{"efaceeq", funcTag, 60},
+	{"fastrand", funcTag, 62},
+	{"makemap64", funcTag, 64},
+	{"makemap", funcTag, 65},
+	{"makemap_small", funcTag, 66},
+	{"mapaccess1", funcTag, 67},
+	{"mapaccess1_fast32", funcTag, 68},
+	{"mapaccess1_fast64", funcTag, 68},
+	{"mapaccess1_faststr", funcTag, 68},
+	{"mapaccess1_fat", funcTag, 69},
+	{"mapaccess2", funcTag, 70},
+	{"mapaccess2_fast32", funcTag, 71},
+	{"mapaccess2_fast64", funcTag, 71},
+	{"mapaccess2_faststr", funcTag, 71},
+	{"mapaccess2_fat", funcTag, 72},
+	{"mapassign", funcTag, 67},
+	{"mapassign_fast32", funcTag, 68},
+	{"mapassign_fast32ptr", funcTag, 68},
+	{"mapassign_fast64", funcTag, 68},
+	{"mapassign_fast64ptr", funcTag, 68},
+	{"mapassign_faststr", funcTag, 68},
+	{"mapiterinit", funcTag, 73},
+	{"mapdelete", funcTag, 73},
+	{"mapdelete_fast32", funcTag, 74},
+	{"mapdelete_fast64", funcTag, 74},
+	{"mapdelete_faststr", funcTag, 74},
+	{"mapiternext", funcTag, 75},
+	{"mapclear", funcTag, 76},
+	{"makechan64", funcTag, 78},
+	{"makechan", funcTag, 79},
+	{"chanrecv1", funcTag, 81},
+	{"chanrecv2", funcTag, 82},
+	{"chansend1", funcTag, 84},
 	{"closechan", funcTag, 23},
-	{"writeBarrier", varTag, 85},
-	{"typedmemmove", funcTag, 86},
-	{"typedmemclr", funcTag, 87},
-	{"typedslicecopy", funcTag, 88},
-	{"selectnbsend", funcTag, 89},
-	{"selectnbrecv", funcTag, 90},
-	{"selectnbrecv2", funcTag, 92},
-	{"selectsetpc", funcTag, 56},
-	{"selectgo", funcTag, 93},
+	{"writeBarrier", varTag, 86},
+	{"typedmemmove", funcTag, 87},
+	{"typedmemclr", funcTag, 88},
+	{"typedslicecopy", funcTag, 89},
+	{"selectnbsend", funcTag, 90},
+	{"selectnbrecv", funcTag, 91},
+	{"selectnbrecv2", funcTag, 93},
+	{"selectsetpc", funcTag, 58},
+	{"selectgo", funcTag, 94},
 	{"block", funcTag, 5},
 	{"makeslice", funcTag, 95},
 	{"makeslice64", funcTag, 96},
-	{"growslice", funcTag, 97},
-	{"memmove", funcTag, 98},
-	{"memclrNoHeapPointers", funcTag, 99},
-	{"memclrHasPointers", funcTag, 99},
-	{"memequal", funcTag, 100},
-	{"memequal8", funcTag, 101},
-	{"memequal16", funcTag, 101},
-	{"memequal32", funcTag, 101},
-	{"memequal64", funcTag, 101},
-	{"memequal128", funcTag, 101},
-	{"int64div", funcTag, 102},
-	{"uint64div", funcTag, 103},
-	{"int64mod", funcTag, 102},
-	{"uint64mod", funcTag, 103},
-	{"float64toint64", funcTag, 104},
-	{"float64touint64", funcTag, 105},
-	{"float64touint32", funcTag, 106},
-	{"int64tofloat64", funcTag, 107},
-	{"uint64tofloat64", funcTag, 108},
-	{"uint32tofloat64", funcTag, 109},
-	{"complex128div", funcTag, 110},
-	{"racefuncenter", funcTag, 111},
+	{"growslice", funcTag, 98},
+	{"memmove", funcTag, 99},
+	{"memclrNoHeapPointers", funcTag, 100},
+	{"memclrHasPointers", funcTag, 100},
+	{"memequal", funcTag, 101},
+	{"memequal8", funcTag, 102},
+	{"memequal16", funcTag, 102},
+	{"memequal32", funcTag, 102},
+	{"memequal64", funcTag, 102},
+	{"memequal128", funcTag, 102},
+	{"int64div", funcTag, 103},
+	{"uint64div", funcTag, 104},
+	{"int64mod", funcTag, 103},
+	{"uint64mod", funcTag, 104},
+	{"float64toint64", funcTag, 105},
+	{"float64touint64", funcTag, 106},
+	{"float64touint32", funcTag, 107},
+	{"int64tofloat64", funcTag, 108},
+	{"uint64tofloat64", funcTag, 109},
+	{"uint32tofloat64", funcTag, 110},
+	{"complex128div", funcTag, 111},
+	{"racefuncenter", funcTag, 112},
 	{"racefuncenterfp", funcTag, 5},
 	{"racefuncexit", funcTag, 5},
-	{"raceread", funcTag, 111},
-	{"racewrite", funcTag, 111},
-	{"racereadrange", funcTag, 112},
-	{"racewriterange", funcTag, 112},
-	{"msanread", funcTag, 112},
-	{"msanwrite", funcTag, 112},
-	{"support_popcnt", varTag, 11},
-	{"support_sse41", varTag, 11},
+	{"raceread", funcTag, 112},
+	{"racewrite", funcTag, 112},
+	{"racereadrange", funcTag, 113},
+	{"racewriterange", funcTag, 113},
+	{"msanread", funcTag, 113},
+	{"msanwrite", funcTag, 113},
+	{"x86HasPOPCNT", varTag, 11},
+	{"x86HasSSE41", varTag, 11},
+	{"arm64HasATOMICS", varTag, 11},
 }
 
 func runtimeTypes() []*types.Type {
-	var typs [113]*types.Type
+	var typs [114]*types.Type
 	typs[0] = types.Bytetype
 	typs[1] = types.NewPtr(typs[0])
 	typs[2] = types.Types[TANY]
@@ -208,65 +204,66 @@
 	typs[50] = functype(nil, []*Node{anonfield(typs[21]), anonfield(typs[32])}, []*Node{anonfield(typs[40]), anonfield(typs[32])})
 	typs[51] = functype(nil, []*Node{anonfield(typs[21])}, []*Node{anonfield(typs[32])})
 	typs[52] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2])}, []*Node{anonfield(typs[2])})
-	typs[53] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3])}, []*Node{anonfield(typs[2])})
-	typs[54] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2])}, []*Node{anonfield(typs[2]), anonfield(typs[11])})
-	typs[55] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[1]), anonfield(typs[1])}, nil)
-	typs[56] = functype(nil, []*Node{anonfield(typs[1])}, nil)
-	typs[57] = types.NewPtr(typs[47])
-	typs[58] = types.Types[TUNSAFEPTR]
-	typs[59] = functype(nil, []*Node{anonfield(typs[57]), anonfield(typs[58]), anonfield(typs[58])}, []*Node{anonfield(typs[11])})
-	typs[60] = types.Types[TUINT32]
-	typs[61] = functype(nil, nil, []*Node{anonfield(typs[60])})
-	typs[62] = types.NewMap(typs[2], typs[2])
-	typs[63] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[3])}, []*Node{anonfield(typs[62])})
-	typs[64] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32]), anonfield(typs[3])}, []*Node{anonfield(typs[62])})
-	typs[65] = functype(nil, nil, []*Node{anonfield(typs[62])})
-	typs[66] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[3])}, []*Node{anonfield(typs[3])})
-	typs[67] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[2])}, []*Node{anonfield(typs[3])})
-	typs[68] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[3]), anonfield(typs[1])}, []*Node{anonfield(typs[3])})
-	typs[69] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[3])}, []*Node{anonfield(typs[3]), anonfield(typs[11])})
-	typs[70] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[2])}, []*Node{anonfield(typs[3]), anonfield(typs[11])})
-	typs[71] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[3]), anonfield(typs[1])}, []*Node{anonfield(typs[3]), anonfield(typs[11])})
-	typs[72] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[3])}, nil)
-	typs[73] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62]), anonfield(typs[2])}, nil)
-	typs[74] = functype(nil, []*Node{anonfield(typs[3])}, nil)
-	typs[75] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[62])}, nil)
-	typs[76] = types.NewChan(typs[2], types.Cboth)
-	typs[77] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15])}, []*Node{anonfield(typs[76])})
-	typs[78] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32])}, []*Node{anonfield(typs[76])})
-	typs[79] = types.NewChan(typs[2], types.Crecv)
-	typs[80] = functype(nil, []*Node{anonfield(typs[79]), anonfield(typs[3])}, nil)
-	typs[81] = functype(nil, []*Node{anonfield(typs[79]), anonfield(typs[3])}, []*Node{anonfield(typs[11])})
-	typs[82] = types.NewChan(typs[2], types.Csend)
-	typs[83] = functype(nil, []*Node{anonfield(typs[82]), anonfield(typs[3])}, nil)
-	typs[84] = types.NewArray(typs[0], 3)
-	typs[85] = tostruct([]*Node{namedfield("enabled", typs[11]), namedfield("pad", typs[84]), namedfield("needed", typs[11]), namedfield("cgo", typs[11]), namedfield("alignme", typs[17])})
-	typs[86] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3]), anonfield(typs[3])}, nil)
-	typs[87] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3])}, nil)
-	typs[88] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2]), anonfield(typs[2])}, []*Node{anonfield(typs[32])})
-	typs[89] = functype(nil, []*Node{anonfield(typs[82]), anonfield(typs[3])}, []*Node{anonfield(typs[11])})
-	typs[90] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[79])}, []*Node{anonfield(typs[11])})
-	typs[91] = types.NewPtr(typs[11])
-	typs[92] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[91]), anonfield(typs[79])}, []*Node{anonfield(typs[11])})
-	typs[93] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[1]), anonfield(typs[32])}, []*Node{anonfield(typs[32]), anonfield(typs[11])})
-	typs[94] = types.NewSlice(typs[2])
-	typs[95] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32]), anonfield(typs[32])}, []*Node{anonfield(typs[94])})
-	typs[96] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[94])})
-	typs[97] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[94]), anonfield(typs[32])}, []*Node{anonfield(typs[94])})
-	typs[98] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[47])}, nil)
-	typs[99] = functype(nil, []*Node{anonfield(typs[58]), anonfield(typs[47])}, nil)
-	typs[100] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[47])}, []*Node{anonfield(typs[11])})
-	typs[101] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3])}, []*Node{anonfield(typs[11])})
-	typs[102] = functype(nil, []*Node{anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[15])})
-	typs[103] = functype(nil, []*Node{anonfield(typs[17]), anonfield(typs[17])}, []*Node{anonfield(typs[17])})
-	typs[104] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[15])})
-	typs[105] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[17])})
-	typs[106] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[60])})
-	typs[107] = functype(nil, []*Node{anonfield(typs[15])}, []*Node{anonfield(typs[13])})
-	typs[108] = functype(nil, []*Node{anonfield(typs[17])}, []*Node{anonfield(typs[13])})
-	typs[109] = functype(nil, []*Node{anonfield(typs[60])}, []*Node{anonfield(typs[13])})
-	typs[110] = functype(nil, []*Node{anonfield(typs[19]), anonfield(typs[19])}, []*Node{anonfield(typs[19])})
-	typs[111] = functype(nil, []*Node{anonfield(typs[47])}, nil)
-	typs[112] = functype(nil, []*Node{anonfield(typs[47]), anonfield(typs[47])}, nil)
+	typs[53] = types.Types[TUNSAFEPTR]
+	typs[54] = functype(nil, []*Node{anonfield(typs[2])}, []*Node{anonfield(typs[53])})
+	typs[55] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3])}, []*Node{anonfield(typs[2])})
+	typs[56] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2])}, []*Node{anonfield(typs[2]), anonfield(typs[11])})
+	typs[57] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[1]), anonfield(typs[1])}, nil)
+	typs[58] = functype(nil, []*Node{anonfield(typs[1])}, nil)
+	typs[59] = types.NewPtr(typs[47])
+	typs[60] = functype(nil, []*Node{anonfield(typs[59]), anonfield(typs[53]), anonfield(typs[53])}, []*Node{anonfield(typs[11])})
+	typs[61] = types.Types[TUINT32]
+	typs[62] = functype(nil, nil, []*Node{anonfield(typs[61])})
+	typs[63] = types.NewMap(typs[2], typs[2])
+	typs[64] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[3])}, []*Node{anonfield(typs[63])})
+	typs[65] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32]), anonfield(typs[3])}, []*Node{anonfield(typs[63])})
+	typs[66] = functype(nil, nil, []*Node{anonfield(typs[63])})
+	typs[67] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[3])}, []*Node{anonfield(typs[3])})
+	typs[68] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[2])}, []*Node{anonfield(typs[3])})
+	typs[69] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[3]), anonfield(typs[1])}, []*Node{anonfield(typs[3])})
+	typs[70] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[3])}, []*Node{anonfield(typs[3]), anonfield(typs[11])})
+	typs[71] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[2])}, []*Node{anonfield(typs[3]), anonfield(typs[11])})
+	typs[72] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[3]), anonfield(typs[1])}, []*Node{anonfield(typs[3]), anonfield(typs[11])})
+	typs[73] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[3])}, nil)
+	typs[74] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63]), anonfield(typs[2])}, nil)
+	typs[75] = functype(nil, []*Node{anonfield(typs[3])}, nil)
+	typs[76] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[63])}, nil)
+	typs[77] = types.NewChan(typs[2], types.Cboth)
+	typs[78] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15])}, []*Node{anonfield(typs[77])})
+	typs[79] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32])}, []*Node{anonfield(typs[77])})
+	typs[80] = types.NewChan(typs[2], types.Crecv)
+	typs[81] = functype(nil, []*Node{anonfield(typs[80]), anonfield(typs[3])}, nil)
+	typs[82] = functype(nil, []*Node{anonfield(typs[80]), anonfield(typs[3])}, []*Node{anonfield(typs[11])})
+	typs[83] = types.NewChan(typs[2], types.Csend)
+	typs[84] = functype(nil, []*Node{anonfield(typs[83]), anonfield(typs[3])}, nil)
+	typs[85] = types.NewArray(typs[0], 3)
+	typs[86] = tostruct([]*Node{namedfield("enabled", typs[11]), namedfield("pad", typs[85]), namedfield("needed", typs[11]), namedfield("cgo", typs[11]), namedfield("alignme", typs[17])})
+	typs[87] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3]), anonfield(typs[3])}, nil)
+	typs[88] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3])}, nil)
+	typs[89] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2]), anonfield(typs[2])}, []*Node{anonfield(typs[32])})
+	typs[90] = functype(nil, []*Node{anonfield(typs[83]), anonfield(typs[3])}, []*Node{anonfield(typs[11])})
+	typs[91] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[80])}, []*Node{anonfield(typs[11])})
+	typs[92] = types.NewPtr(typs[11])
+	typs[93] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[92]), anonfield(typs[80])}, []*Node{anonfield(typs[11])})
+	typs[94] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[1]), anonfield(typs[32])}, []*Node{anonfield(typs[32]), anonfield(typs[11])})
+	typs[95] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32]), anonfield(typs[32])}, []*Node{anonfield(typs[53])})
+	typs[96] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[53])})
+	typs[97] = types.NewSlice(typs[2])
+	typs[98] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[97]), anonfield(typs[32])}, []*Node{anonfield(typs[97])})
+	typs[99] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[47])}, nil)
+	typs[100] = functype(nil, []*Node{anonfield(typs[53]), anonfield(typs[47])}, nil)
+	typs[101] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[47])}, []*Node{anonfield(typs[11])})
+	typs[102] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3])}, []*Node{anonfield(typs[11])})
+	typs[103] = functype(nil, []*Node{anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[15])})
+	typs[104] = functype(nil, []*Node{anonfield(typs[17]), anonfield(typs[17])}, []*Node{anonfield(typs[17])})
+	typs[105] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[15])})
+	typs[106] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[17])})
+	typs[107] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[61])})
+	typs[108] = functype(nil, []*Node{anonfield(typs[15])}, []*Node{anonfield(typs[13])})
+	typs[109] = functype(nil, []*Node{anonfield(typs[17])}, []*Node{anonfield(typs[13])})
+	typs[110] = functype(nil, []*Node{anonfield(typs[61])}, []*Node{anonfield(typs[13])})
+	typs[111] = functype(nil, []*Node{anonfield(typs[19]), anonfield(typs[19])}, []*Node{anonfield(typs[19])})
+	typs[112] = functype(nil, []*Node{anonfield(typs[47])}, nil)
+	typs[113] = functype(nil, []*Node{anonfield(typs[47]), anonfield(typs[47])}, nil)
 	return typs[:]
 }
diff --git a/src/cmd/compile/internal/gc/builtin/runtime.go b/src/cmd/compile/internal/gc/builtin/runtime.go
index 140b7f3..fc879ba 100644
--- a/src/cmd/compile/internal/gc/builtin/runtime.go
+++ b/src/cmd/compile/internal/gc/builtin/runtime.go
@@ -61,23 +61,23 @@
 func decoderune(string, int) (retv rune, retk int)
 func countrunes(string) int
 
-// interface conversions
+// Non-empty-interface to non-empty-interface conversion.
 func convI2I(typ *byte, elem any) (ret any)
 
+// Specialized type-to-interface conversion.
+// These return only a data pointer.
+func convT16(val any) unsafe.Pointer     // val must be uint16-like (same size and alignment as a uint16)
+func convT32(val any) unsafe.Pointer     // val must be uint32-like (same size and alignment as a uint32)
+func convT64(val any) unsafe.Pointer     // val must be uint64-like (same size and alignment as a uint64 and contains no pointers)
+func convTstring(val any) unsafe.Pointer // val must be a string
+func convTslice(val any) unsafe.Pointer  // val must be a slice
+
+// Type to empty-interface conversion.
 func convT2E(typ *byte, elem *any) (ret any)
-func convT2E16(typ *byte, val any) (ret any)
-func convT2E32(typ *byte, val any) (ret any)
-func convT2E64(typ *byte, val any) (ret any)
-func convT2Estring(typ *byte, elem *any) (ret any)
-func convT2Eslice(typ *byte, elem *any) (ret any)
 func convT2Enoptr(typ *byte, elem *any) (ret any)
 
+// Type to non-empty-interface conversion.
 func convT2I(tab *byte, elem *any) (ret any)
-func convT2I16(tab *byte, val any) (ret any)
-func convT2I32(tab *byte, val any) (ret any)
-func convT2I64(tab *byte, val any) (ret any)
-func convT2Istring(tab *byte, elem *any) (ret any)
-func convT2Islice(tab *byte, elem *any) (ret any)
 func convT2Inoptr(tab *byte, elem *any) (ret any)
 
 // interface type assertions x.(T)
@@ -153,8 +153,8 @@
 func selectgo(cas0 *byte, order0 *byte, ncases int) (int, bool)
 func block()
 
-func makeslice(typ *byte, len int, cap int) (ary []any)
-func makeslice64(typ *byte, len int64, cap int64) (ary []any)
+func makeslice(typ *byte, len int, cap int) unsafe.Pointer
+func makeslice64(typ *byte, len int64, cap int64) unsafe.Pointer
 func growslice(typ *byte, old []any, cap int) (ary []any)
 func memmove(to *any, frm *any, length uintptr)
 func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
@@ -195,5 +195,6 @@
 func msanwrite(addr, size uintptr)
 
 // architecture variants
-var support_popcnt bool
-var support_sse41 bool
+var x86HasPOPCNT bool
+var x86HasSSE41 bool
+var arm64HasATOMICS bool
diff --git a/src/cmd/compile/internal/gc/bv.go b/src/cmd/compile/internal/gc/bv.go
index e9db35e..5ddfd5f 100644
--- a/src/cmd/compile/internal/gc/bv.go
+++ b/src/cmd/compile/internal/gc/bv.go
@@ -227,17 +227,6 @@
 	uniq  []bvec // unique bvecs, in insertion order
 }
 
-func newBvecSet(size int) bvecSet {
-	// bvecSet is a linear probing hash table.
-	// The hash table has 4n entries to keep the linear
-	// scan short.
-	index := make([]int, size*4)
-	for i := range index {
-		index[i] = -1
-	}
-	return bvecSet{index, nil}
-}
-
 func (m *bvecSet) grow() {
 	// Allocate new index.
 	n := len(m.index) * 2
diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go
index ce575a6..284ecdf 100644
--- a/src/cmd/compile/internal/gc/closure.go
+++ b/src/cmd/compile/internal/gc/closure.go
@@ -16,7 +16,7 @@
 
 	xfunc := p.nod(expr, ODCLFUNC, nil, nil)
 	xfunc.Func.SetIsHiddenClosure(Curfn != nil)
-	xfunc.Func.Nname = p.setlineno(expr, newfuncname(nblank.Sym)) // filled in by typecheckclosure
+	xfunc.Func.Nname = newfuncnamel(p.pos(expr), nblank.Sym) // filled in by typecheckclosure
 	xfunc.Func.Nname.Name.Param.Ntype = xtype
 	xfunc.Func.Nname.Name.Defn = xfunc
 
@@ -93,7 +93,7 @@
 	xfunc.Func.Nname.Sym = closurename(Curfn)
 	disableExport(xfunc.Func.Nname.Sym)
 	declare(xfunc.Func.Nname, PFUNC)
-	xfunc = typecheck(xfunc, Etop)
+	xfunc = typecheck(xfunc, ctxStmt)
 
 	clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype)
 	clo.Type = clo.Func.Ntype.Type
@@ -108,7 +108,7 @@
 		Curfn = xfunc
 		olddd := decldepth
 		decldepth = 1
-		typecheckslice(xfunc.Nbody.Slice(), Etop)
+		typecheckslice(xfunc.Nbody.Slice(), ctxStmt)
 		decldepth = olddd
 		Curfn = oldfn
 	}
@@ -199,7 +199,7 @@
 			Warnl(v.Pos, "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, outermost.Addrtaken(), outermost.Assigned(), int32(v.Type.Width))
 		}
 
-		outer = typecheck(outer, Erv)
+		outer = typecheck(outer, ctxExpr)
 		clo.Func.Enter.Append(outer)
 	}
 
@@ -214,7 +214,7 @@
 	lineno = xfunc.Pos
 	clo := xfunc.Func.Closure
 
-	if clo.Func.Top&Ecall != 0 {
+	if clo.Func.Top&ctxCallee != 0 {
 		// If the closure is directly called, we transform it to a plain function call
 		// with variables passed as args. This avoids allocation of a closure object.
 		// Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE)
@@ -305,7 +305,7 @@
 		}
 
 		if len(body) > 0 {
-			typecheckslice(body, Etop)
+			typecheckslice(body, ctxStmt)
 			xfunc.Func.Enter.Set(body)
 			xfunc.Func.SetNeedctxt(true)
 		}
@@ -314,7 +314,7 @@
 	lineno = lno
 }
 
-// hasemptycvars returns true iff closure clo has an
+// hasemptycvars reports whether closure clo has an
 // empty list of captured vars.
 func hasemptycvars(clo *Node) bool {
 	xfunc := clo.Func.Closure
@@ -337,18 +337,10 @@
 	}
 }
 
-func walkclosure(clo *Node, init *Nodes) *Node {
-	xfunc := clo.Func.Closure
-
-	// If no c