Repository: go
Issue: gollvm: crash of goc
Labels: NeedsInvestigation

<!--
Please answer these questions before submitting your issue. Thanks!
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version unknown linux/amd64
</pre>

### Does this issue reproduce with the latest release?

Yes

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/amarkin/.cache/go-build"
GOENV="/home/amarkin/.config/go/env"
GOEXE=""
GOEXPERIMENT="fieldtrack,regabiwrappers"
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/amarkin/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/amarkin/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/amarkin/repos/gollvm_reference_bin"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/amarkin/repos/gollvm_reference_bin/tools"
GOVCS=""
GOVERSION="unknown"
GCCGO="/home/amarkin/repos/gollvm_reference_bin/bin/llvm-goc"
GOAMD64="v1"
AR="ar"
CC="/usr/bin/cc"
CXX="/usr/bin/c++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3524345951=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
</pre></details>

### What did you do?

```
$ cat mheap.go
package runtime

type mspan struct {
        startAddr uintptr
        specials    *special
}

func (s *mspan) base() uintptr {
        return s.startAddr
}

$ llvm-goc -c mheap.go
mheap.go:5:15: error: use of undefined type 'special'
llvm-goc: /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-materialize.cpp:375: llvm::Value* Llvm_backend::makeFieldGEP(unsigned int, llvm::Value*): Assertion `fieldIndex < llst->getNumElements()' failed.
 #0 0x000055dc900b9880 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (.localalias) /home/amarkin/repos/llvm-reference/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x000055dc900b993b PrintStackTraceSignalHandler(void*) /home/amarkin/repos/llvm-reference/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x000055dc900b75a2 llvm::sys::RunSignalHandlers() (.localalias) /home/amarkin/repos/llvm-reference/llvm/lib/Support/Signals.cpp:97:20
 #3 0x000055dc900b91cc SignalHandler(int) /home/amarkin/repos/llvm-reference/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f7104abd3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #5 0x00007f710455503b raise /build/glibc-sMfBJT/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007f7104534859 abort /build/glibc-sMfBJT/glibc-2.31/stdlib/abort.c:81:7
 #7 0x00007f7104534729 get_sysdep_segment_value /build/glibc-sMfBJT/glibc-2.31/intl/loadmsgcat.c:509:8
 #8 0x00007f7104534729 _nl_load_domain /build/glibc-sMfBJT/glibc-2.31/intl/loadmsgcat.c:970:34
 #9 0x00007f7104546006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
#10 0x000055dc8d7da978 Llvm_backend::makeFieldGEP(unsigned int, llvm::Value*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-materialize.cpp:376:35
#11 0x000055dc8d7dac71 Llvm_backend::materializeStructField(Bexpression*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-materialize.cpp:404:24
#12 0x000055dc8d7e6d32 MaterializeVisitor::visitNodePost(Bnode*) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-materialize.cpp:2056:14
#13 0x000055dc8d7ea3b0 UpdatingNodeWalker<MaterializeVisitor>::walk(Bnode*) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-bnode.h:516:10
#14 0x000055dc8d7e84d5 Bnode* update_walk_nodes<MaterializeVisitor>(Bnode*, MaterializeVisitor&) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-bnode.h:532:8
#15 0x000055dc8d7e32a1 Llvm_backend::materialize(Bexpression*, Varexpr_context) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm-materialize.cpp:2146:42
#16 0x000055dc8d6d0da6 Llvm_backend::assignment_statement(Bfunction*, Bexpression*, Bexpression*, Location) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/bridge/go-llvm.cpp:1880:20
#17 0x000055dc8d6530b7 Assignment_statement::do_get_backend(Translate_context*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/statements.cc:1172:67
#18 0x000055dc8d650073 Statement::get_backend(Translate_context*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/statements.cc:189:38
#19 0x000055dc8d5d1117 Block::get_backend(Translate_context*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/gogo.cc:7114:44
#20 0x000055dc8d655f85 Block_statement::do_get_backend(Translate_context*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/statements.cc:2245:45
#21 0x000055dc8d650073 Statement::get_backend(Translate_context*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/statements.cc:189:38
#22 0x000055dc8d5d1117 Block::get_backend(Translate_context*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/gogo.cc:7114:44
#23 0x000055dc8d5cf334 Function::build(Gogo*, Named_object*) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/gogo.cc:6649:53
#24 0x000055dc8d5d69c4 Named_object::get_backend(Gogo*, std::vector<Bexpression*, std::allocator<Bexpression*> >&, std::vector<Btype*, std::allocator<Btype*> >&, std::vector<Bfunction*, std::allocator<Bfunction*> >&) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/gogo.cc:8900:7
#25 0x000055dc8d5bef21 Gogo::write_globals() /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/gogo.cc:1560:24
#26 0x000055dc8d5b6eb9 go_write_globals() /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/gofrontend/go/go.cc:201:32
#27 0x000055dc8d5980c4 gollvm::driver::CompileGoImpl::invokeFrontEnd() (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/driver/CompileGo.cpp:790:7
#28 0x000055dc8d59545e gollvm::driver::CompileGoImpl::performAction(gollvm::driver::Compilation&, gollvm::driver::Action const&, llvm::SmallVector<gollvm::driver::Artifact*, 3u> const&, gollvm::driver::Artifact const&) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/driver/CompileGo.cpp:192:7
#29 0x000055dc8d598fbc gollvm::driver::CompileGo::performAction(gollvm::driver::Compilation&, gollvm::driver::Action const&, llvm::SmallVector<gollvm::driver::Artifact*, 3u> const&, gollvm::driver::Artifact const&) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/driver/CompileGo.cpp:1005:1
#30 0x000055dc8d587a2a gollvm::driver::Driver::processAction(gollvm::driver::Action*, gollvm::driver::Compilation&, bool) (.localalias) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/driver/Driver.cpp:706:11
#31 0x000055dc8d587bf7 gollvm::driver::Driver::processActions(gollvm::driver::Compilation&) /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/driver/Driver.cpp:729:9
#32 0x000055dc8d57a929 main /home/amarkin/repos/llvm-reference/llvm/tools/gollvm/driver-main/llvm-goc.cpp:228:7
#33 0x00007f71045360b3 __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:342:3
#34 0x000055dc8d579d2e _start (/home/amarkin/repos/gollvm_reference_bin/bin/llvm-goc+0x8e2d2e)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/amarkin/repos/gollvm_reference_bin/bin/llvm-goc -c mheap.go
Aborted (core dumped)
```


### What did you expect to see?

No stack dump

### What did you see instead?

Stack dump